[Experiment] Transfer Control to Other SD1.X Models #12
Replies: 21 comments 37 replies
-
Great! How about make it into an automatic1111 webui plugin? Something like applying the control net to other fine-tuned models without conversion etc.. |
Beta Was this translation helpful? Give feedback.
-
Amazing job on this resource, coolest thing I’ve ever seen. I think this secures the stable diffusion 1.5 dominance forever. My use case is posing characters using depth2img and this blows it out of the water. EDIT: Works great with almost every SD 1.5 checkpoint I try! |
Beta Was this translation helpful? Give feedback.
-
Hi everybody! Thanks for the great work of the author! Can someone share with me the model after the merge "control_any3.pth"? Thank you very much! |
Beta Was this translation helpful? Give feedback.
-
Hey! Thanks a lot for your work, it's awesome! Thinking how we can integrate it in our gamedev studio process! |
Beta Was this translation helpful? Give feedback.
-
I uploaded models that merged Anything 3.0 and ControlNet to huggingspace. Those who cannot merge due to lack of VRAM, feel free to use it! |
Beta Was this translation helpful? Give feedback.
-
Canny edge works very well too! I wonder when ControlNet with Anime Line Drawing will be released. |
Beta Was this translation helpful? Give feedback.
-
Can this be transferred to a 2.x SD model (like the newly release WD1.5) as well, or is that outside its present capabilities? |
Beta Was this translation helpful? Give feedback.
-
Can someone make a Low RAM (16Gb) version of the tool_transfer_control.py script? Even if it involves unloading/reloading models plus saving/deleting temporary models multiple times? |
Beta Was this translation helpful? Give feedback.
-
Has anyone tried using ControlNet to control Dreambooth models? |
Beta Was this translation helpful? Give feedback.
-
Hey man can you modify the code so it extracts just controlnet weights and leaves off SD.15 thats built in in weights from huggingface ? |
Beta Was this translation helpful? Give feedback.
-
Could we just save the "SD15_control_openpose – SD15" and add the customized model when we actually use it? Could this way skip the transfer model step? |
Beta Was this translation helpful? Give feedback.
-
@toyxyz Could you also try the chilloutmix_Ni model? |
Beta Was this translation helpful? Give feedback.
-
Hi, May I ask whats the difference between: control_sd15_canny.pth control_canny-fp16.safetensors and |
Beta Was this translation helpful? Give feedback.
-
Dear author, very amazing work!!! Though I can intuitively understand that the ControlNet trained together with SD can thansfer to other SD-like architecture model, but is there any official explaination for that, or any relevant literature that I need to read to figure it out. Besides, seems the control net only contain the encoder and a middle block of the Unet.
If Any3.model.diffusion_model.weights, SD15.model.diffusion_model.weights only denotes those weights contained in the control net, instead of all the model weights? Otherwise, the weight number will not be the same. Many thanks. Best. |
Beta Was this translation helpful? Give feedback.
-
Hi Lvmin, got some question regarding the weights add/subtracts as I'm not an expert in data science field. I don't know if model weights are commutative in the sense that is:
the same as:
Currently in the community, there is an "extracted" version of the SD1.5 ControlNet weights, which I'm presuming is the diff of
My understanding is that it should be commutative or else there was no point to extract this in the first place. With the diff weights I assume we can just do:
But I'm also reading feedbacks from the community that the custom merged ControlNet models seems to be different from using the diff models and that the custom merged models seem to be better. Would this be the case? |
Beta Was this translation helpful? Give feedback.
-
Could you please explain the following step: "...hack the gradio codes to read your new models, and hack the CLIP encoder with "clip_skip=2" and 3x token length." I did both tests (hacking and not hacking the gradio codes), both ways actually work (and generate good quality images), but they generate different results (using same prompt, seed, sampler etc.) |
Beta Was this translation helpful? Give feedback.
-
So guys I know this is a highly technical thread and for what I can I am trying to following through... I've just installed ControlNet in WebUI and could verify the basics seem to be working ok with SD base model and a few other models I quickly went through... |
Beta Was this translation helpful? Give feedback.
-
Hi, do I need to transfer ControlNet to custom models based on SD 1.5 (e.g. Dreamshaper, Deliberate, Anything) when using Diffusers? Or is it already taken care of by Diffusers. Thanks! |
Beta Was this translation helpful? Give feedback.
-
May be a stupid question but now that:
I wonder how and why from a technical point of view this is possible in the first place? ControlNet paper v2: "Transferring to community models. Since ControlNets do not change the network topology of pretrained SD models, it can be directly applied to various models in the stable diffusion community, such as Comic Diffusion [60] and Pro- togen 3.4 [16], in Figure 12." |
Beta Was this translation helpful? Give feedback.
-
News
This post is out-of-date and obsolete. Please directly use Mikubill' A1111 Webui Plugin to control any SD 1.X models. No transfer is needed. Results are a bit better than the ones in this post.
Previous Method (Obsolete)
This is guideline to transfer the ControlNet to any other community model in a relatively “correct” way.
This post is prepared for SD experts. You need to have some understandings about the neural network architecture of Stable Diffusion to perform this experiment.
Let us say we want to use OpenPose to control Anything V3, then the overall method is
More specifically,
You can download necessary files from
AnythingV3: https://huggingface.co/Linaqruf/anything-v3.0
SD1.5: https://huggingface.co/runwayml/stable-diffusion-v1-5/tree/main
ControlNet: https://huggingface.co/lllyasviel/ControlNet/tree/main/models
Important things to keep in mind:
Replacing the base model in control net MAY work but is WRONG. This is because control net may be trained with some SD layers unlocked. See the ending part of “SD_locked” in the official training guideline. You need to compute the offset even in the base diffusion model.(Obsolete) Some experiments show that results are equally good without such offsets. Please directly use Mikubill' A1111 Webui Plugin.I have done all these preparations for you.
You may open the "tool_transfer_control.py" and then edit some file paths
You can define the output filename with "path_output". You need to make sure that all other 3 filenames are correct and exist. Then
Then you will get the file
Then, you need to hack the gradio codes to read your new models, and hack the CLIP encoder with "clip_skip=2" and 3x token length.
Taking openpose as an example, you can hack "gradio_pose2image.py" in this way
Then, results will be like:
("1girl")
("1girl, masterpiece, garden")
And other controls like Canny edge:
("1girl, garden, flowers, sunshine, masterpiece, best quality, ultra-detailed, illustration, disheveled hair")
Beta Was this translation helpful? Give feedback.
All reactions