Support ControlNet models with different number of channels in control images#3815
Conversation
patrickvonplaten
left a comment
There was a problem hiding this comment.
Works for me! @williamberman wdyt?
|
Hello @JCBrouwer. Thanks for your contribution. While @williamberman reviews your PR, I wanted to check if you'd like to:
I think the community would benefit a lot from this info. |
|
The documentation is not available anymore as the PR was closed or merged. |
|
Hi there, thanks for the response!
|
|
@JCBrouwer - thank you for sharing your progress! I tried running it but my results were poor. If you have any known good inputs to your script, I can try them out and share any issues I see |
…l images (huggingface#3815) support ControlNet models with a different hint_channels value (e.g. TemporalNet2)
…l images (huggingface#3815) support ControlNet models with a different hint_channels value (e.g. TemporalNet2)
What does this PR do?
I'd like to be able to load TemporalNet2 into a ControlNetModel.
This ControlNet concatenates the previous image in a video and the optical flow together to form a 6-channel tensor as the control image.
At the moment the
convert_original_controlnet_to_diffusers.pyscript does not support converting the checkpoint, raising the following error due to the control image having more channels than expected:Traceback
Adding the --num_in_channels argument doesn't help as this changes the in channels for the whole UNet (?).
Diving into the ControlNetModel code, I found that the model parameter giving the above error is controlled by the
conditioning_channelsvariable which wasn't exposed in the UNet config. I've added it into the UNet config creation function inconvert_from_ckpt.pybased on thehint_channelsspecified in the ControlNet .yaml/.json file.I'm not 100% that
hint_channelsis the right config value to read from (not too familiar with ControlNet), but with this change I'm able to convert the TemporalNet2 checkpoint as expected and able to load it into a ControlNetModel. The results seem to work fine based on some test videos.Are there any tests I can add to verify that the change works?
@patrickvonplaten @sayakpaul
Before submitting
documentation guidelines, and
here are tips on formatting docstrings.