-
Notifications
You must be signed in to change notification settings - Fork 6k
[Community] reference only control #3435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Community] reference only control #3435
Conversation
The documentation is not available anymore as the PR was closed or merged. |
Should we include the group norm modification in this PR as well: https://github.com/Mikubill/sd-webui-controlnet/pull/1278/files#diff-8c8d004eed5a3078434f6fbde15c178e472565ebfcb3119f308f9292c8eb7514R458 ? Right now using the group norm or reference_adain+attn gives the best results for reference only. I would definitely like to see this get added either in this PR or a subsequent one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me! Thanks!
Think there is one merge conflict that we need to resolve & then we can get this one merged :-) |
Will you add controlnet support? How can we use it with controlnet? @okotaku |
It doesn't work for me for |
When i run the example i get the error: |
You can't use the version from PyPi, you need to pull master branch and install from local (that or wait for next release). |
thanks, i see |
@kadirnar I will add controlnet version after this PR merged. |
@wangdong-ivymobile Thank you for your report. I fixed this bug on latest commit. |
Just fyi, @lllyasviel fixed a bug recently: Mikubill/sd-webui-controlnet#1309 |
This is great 💯 Can we add inpaint feature like in this repo? |
@jfischoff Thank you for your suggestion. I fixed style fidelity rule on latest commit, it is based on Mikubill/sd-webui-controlnet#1309 . |
@okotaku I really appreciate the work you are doing! |
I tried to use this with multiple images (with slight modification), the result is very bad. I wonder if there are some tricks to make it better? |
Also I tried to use multi controlnet with reference on Webui, the result is also not good but different, I wonder maybe the mechanism is different? |
latent_model_input = self.scheduler.scale_model_input(latent_model_input, t) | ||
|
||
# ref only part | ||
noise = torch.randn_like(ref_image_latents) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this should be
noise = randn_tensor(ref_image_latents.shape, generator=generator, device=ref_image_latents.device, dtype=ref_image_latents.dtype)
from the utils import to ensure the generation is deterministic.
@okotaku that makes sense. Thanks for answer my question. |
Cool let's merge this one! |
* add reference only control * add reference only control * add reference only control * fix lint * fix lint * reference adain * bugfix EulerAncestralDiscreteScheduler * fix style fidelity rule * fix default output size * del unused line * fix deterministic
hi. TypeError: Transformer2DModel.forward() got an unexpected keyword argument 'attention_mask' |
@learningyan #3508 |
@okotaku when I comment out these codes, the code is right. but the quality of generated images is poor. So I'm not sure if commenting out these codes is correct. reference image : inference code: pipe = StableDiffusionReferencePipeline.from_pretrained( pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config) result_img = pipe(ref_image=input_image, result_img: the results in sd-webui-controlnet (see Mikubill/sd-webui-controlnet#1236) ![]() So How can I get the similar result as sd-webui-controlnet? |
You need to update diffusers too.
You can change base model.
And this result is reference attention only,
Mikubill/sd-webui-controlnet#1236 (comment) When examining the details more closely, it appears that the actual model being used is anythingv3 and a custom model named animevae.pt, etc. |
i just git from the lastest diffusers and install following the important note but got this error. StableDiffusionReferencePipeline works fine. AttributeError: 'StableDiffusionControlNetReferencePipeline' object has no attribute '_default_height_width' |
@miiiz you can copy the code of that function from reference file to the controlnet reference file |
Hi there, this thread is a bit long and confusing. Is there any documentation somewhere that describes the classes StableDiffusionReferencePipeline and StableDiffusionCobtrolNetReferencePipeline? |
@okotaku Thanks for your diffusers implementation. Based on your code, I achieve a cross-image region drag based on the reference scheme. 1. Use inpaint controlnet to extract inpainted region feature from another image. 2. Use the segment-anything controlnet to keep reasonable pose. |
@gasvn Really cool projects! Thank you for your contribution. |
two questions here:
|
Yes you need to use the |
For anyone coming to this later, you'll definitely need custom_pipeline like so:
|
@djj0s3 does that mean you can't use reference-only with other ControlNets using |
@amrakm are you trying to use reference-only as a controlnet to pass into another pipe with other controlnets? Interesting idea! One option you can try is to import this class directly and use it as |
I see the code has reference_attn and reference_adain, but how to use reference_only? |
I still face with the same issue. Could you please give me any advices? @okotaku |
normalized the reference image into [-1,1] not [0,1] |
@okotaku @patrickvonplaten the |
* add reference only control * add reference only control * add reference only control * fix lint * fix lint * reference adain * bugfix EulerAncestralDiscreteScheduler * fix style fidelity rule * fix default output size * del unused line * fix deterministic
Refer to Mikubill/sd-webui-controlnet#1236
Reference Image
Output Image of
reference_attn=True
andreference_adain=False
Output Image of
reference_attn=False
andreference_adain=True
Output Image of
reference_attn=True
andreference_adain=True