Skip to content
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

ControlNet extension? #131

Open
pj4533 opened this issue Feb 15, 2023 · 17 comments
Open

ControlNet extension? #131

pj4533 opened this issue Feb 15, 2023 · 17 comments

Comments

@pj4533
Copy link

pj4533 commented Feb 15, 2023

My python skills are just not strong enough...anyone have any idea how (or if) ControlNet could be integrated into the CoreML conversion process?

https://github.com/lllyasviel/ControlNet#controlnet-with-canny-edge

@gavtron2000
Copy link

ControlNet looks pretty compelling. I've only just got image to image up and running in my alpha app, and I'm not a python programmer, but if a few people are willing to take on the challenge I would be cheering them on!

@pj4533
Copy link
Author

pj4533 commented Feb 21, 2023

Agreed. Way more confident in my swift skills, but that said, I could probably stumble through python enough to help out, just not even sure where to start for something like ControlNET.

@alelordelo
Copy link

+1!

@twinsant
Copy link

twinsant commented Mar 7, 2023

+1

2 similar comments
@crazyshitass
Copy link

+1

@korzen
Copy link

korzen commented Mar 15, 2023

+1

@GuiyeC
Copy link
Contributor

GuiyeC commented Mar 17, 2023

I was able to get ControlNet working with CoreML on my app Guernika so this is definitely possible, so far I have added preprocessing for poses, depth and HED maps but I have successfully converted all eight existing models.

This does require modifying Unet's inputs so all existing models will not be compatible and will need to be reconverted.

Screenshot 2023-03-15 at 00 38 54

Screenshot 2023-03-15 at 00 44 21

@gavtron2000
Copy link

Great work @GuiyeC ! I just dowloaded and had a play. You've done an excellent job on the UI too.
I'd encourage you to submit a pull request to add control net support to the repo if you are willing.

@pj4533
Copy link
Author

pj4533 commented Mar 17, 2023

Wow! @GuiyeC I commented on the other thread before i saw this. Looks amazing. Seems like you modified the underlying UNET via python, then used that in the conversion process of other models? +1 on a merge if you have time!

@GuiyeC
Copy link
Contributor

GuiyeC commented Mar 17, 2023

@gavtron2000 @pj4533 thank you for your comments!

I have the python scripts in my Guernika repo, you can see how the Unet and ControlNet are implemented for conversion, probably not the cleanest way of passing residuals to the Unet but that's how I managed to do it.

As for the PR, I don't think I'll ever make a PR to this repo as my repo is quite different already, for example, I implemented img2img first and the implementation is different, if I'm not wrong random latents on this repo are generated in python and I do that in Swift, my encoder is just the encoder module. I also implemented instruction pix2pix support, ControlNet and other tweaks here and there, so it would practically mean taking over this repo. At most I would make my fork public but I would like to have some time to give my app an edge and get Guernika going.

@pj4533
Copy link
Author

pj4533 commented Mar 17, 2023

☹️

@gavtron2000
Copy link

Totally understandable @GuiyeC. Really impressive work, and a really excellent app. I wish you every success.

@Zabriskije
Copy link

Good job @GuiyeC! Do you have a Discord server? I have some questions/feedback

@GuiyeC
Copy link
Contributor

GuiyeC commented Mar 18, 2023

@Zabriskije you can contact me on Twitter or Telegram, same name, or you can leave them in Hugging Face or in Reddit :)

@ryu38
Copy link
Contributor

ryu38 commented Apr 8, 2023

I tried adding ControlNet in this PR! #153

@pj4533
Copy link
Author

pj4533 commented Jun 30, 2023

@ryu38 The controlNet support is awesome, I just implemented it in my app. However, one quick question.

You provide the models for ControlNet in the pipeline initialization, but the input images for controlNet in the pipeline configuration. Is there a way to have the pipeline initialized to support a given controlNet model (meaning I include the name during initialization), but then when I process a given frame, I don't include an input frame for controlNet so it doesn't use controlNet?

Right now, it seems like it is all or nothing. If I have a controlNet model specified in the pipeline initialization, I get an out of range error if I send an empty array to controlNetInputs.

My use case is for video, and I'd like to use controlNet for some frames, but not others, without having to re-init the pipeline.

@jrittvo
Copy link

jrittvo commented Jun 30, 2023

Right now, it seems like it is all or nothing. If I have a controlNet model specified in the pipeline initialization, I get an out of range error if I send an empty array to controlNetInputs.

Take a look at this thread: #197

In particular: "Basically you just need to modify the additionalResiduals (the MLShapedArray) generated from the ControlNet, before passing the value to the ControlledUNet. By the way I got error when putting nil to the values. So modify it instead."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants