-
Notifications
You must be signed in to change notification settings - Fork 85
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
Feature Request: Add ComfyUI as a backend #146
Comments
This would be a nice addition! I haven't personally used ComfyUI, but it looks great. I don't have the bandwidth to do this right now, but I'd love any collaboration! (Each backend has its own API file and it should be pretty straightforward for a developer to add a new one for Comfy). |
There's a ComfyUI addon that allows you to use nodes in blender - running it right through blender - very handy, works well. There could be useful code there. |
Thanks for that info, @Vidyut! |
I added ComfyUI support for a project I made in the latest months. You can check my fork here: I followed @benrugg's implementation for the most part, but my code is still messy and needs some cleanup. ComfyUI is different from the other backends that the add-on supports, so I decided to create separate files and changed the approach during development. The result now mixes two kinds of methods to interact with the ComfyUI API. I don't want to bring the nodes from ComfyUI to a node editor in Blender for now. I find ComfyUI pretty lovely to work with. My idea is to bring a set of selected nodes to Blender UI. |
I'm planning a full rewrite of the ComfyUI support in a new fork. If someone is interested, let's get in touch. |
@RobeSantoro thanks for sharing this. A quick glance at your fork shows that you've done a lot of work! If you end up having time to clean it up, feel free to submit a PR! |
@benrugg Of course, I want to clean it up! How do I proceed with the refactoring of my code? E.g. |
@RobeSantoro ah, interesting - I actually haven't had a chance to look at your code in more detail or run it. Is Comfy that different that there are unique needs for the UI panels? I'll leave it up to you how to best organize it to keep it modular and maintainable. I was mostly going off the fact that you mentioned it needed to be cleaned up 😄 |
Hey @benrugg ! Here's a video recorded in May: With ComfyUI, you can create stable diffusion pipelines and save it as a JSON for API usage. My initial idea was to stick to your implementation of the other backends. While working on it, I decided to change the approach and create a ComfyUI Panel that auto-populates if a specific set of nodes is found in the JSON. So now, in the code, there are some cases in which I'm using the initial approach, and I would like to refactor those. I'll keep separate files for convenience; if you create a ComfyUI Support branch in your repo, I could make a pull request on that branch so that your main stays clean. What do you think? |
@RobeSantoro wow, I didn't realize how different the support for ComfyUI was going to be. I've made a new branch I will do my best to dive deeper into everything you've done as soon as I can. If possible, I will do that this weekend. |
Hey @benrugg! Next week, I'll record a new video with a code walkthrough and a demo of the ComfyUI support achieved so far. |
@RobeSantoro great - I will check this all out on Sunday. Thanks for submitting it! It's cool that you put so much work into it. |
FYI for anyone finding this after Sep 8, 2024:ComfyUI is now supported on the comfyui-support branch. |
@RobeSantoro as this moves forward more, I can take your readme changes and put them in the WIKI |
@afecelis Hey Alvaro, thanks for reporting! I'm creating a short tutorial to make the branch work. To solve the specific issue you're having now, you can just open comfy in the browser on localhost http://127.0.0.1:8188/ and install the missing nodes via the Manager. That specific node is used to apply the alpha of the actual render to the generated image. Let me know if you get it to work! |
Thank you so much @RobeSantoro , I installed the Allor nodes and it solved the alpha Issue, now I'm getting the following error:
Ps. I just found the Lora in civitai: I'm going to try again, how do you disable a Lora in blender's Lora interface? Setting its values to zero? Ps2. How do you use the 3 workflow templates? I'm using the example_api.json file. BTW. this lora can be found here: |
@afecelis Eh, that hexagon seems to be the default cube! Something needs to be fixed at the Compositor stage, I think. Check also the ComfyUI input folder. You should see the temp passes folders: The Bypass the nodes of the Alpha trick I'm using if you want, and have a look: You can modify it as you need and create any workflow you want. You don't need to download the ckpt models or the Lora models I'm testing. The essential things are:
If you want to drive the generation better, you can use controlnet models with the same logic: Of course, you need a KSampler node "main_sampler", but you can create any pipeline you need. At the moment, the list of supported node classes that will appear in Blender UI are the following:
If you need any other node inside Blender, just ask me. To solve your issue, make sure to:
I'm recording a comprehensive tutorial, but it takes much time. I hope you'll be able to solve your issue. |
@RobeSantoro Whoah! thanks for all that info! The addon is implementting more than I had imagied! amazing! Ps. I just ran into your may post video: Checking it out right now |
That video needs to be updated! It shows how to add nodes to the add-on. If you or anyone else has experience with Python and the Blender Python API, please have a look at the code if it smells. I am now setting up a clean Win11 system to test and record a video. |
I created a PR to merge with the respective comfyui-support branch on your repo, so you can check it. Finally, the comfyui-support branch is ready to merge with the main. Do you want me to issue a PR for that, or do you want to merge it by yourself? Cheers |
@RobeSantoro awesome, I just approved that PR. I will check this all out finally - and install Comfy finally! - as soon as I can and then get back to you if I see any changes that need to be made. I really appreciate all your work on this! |
To install ComfyUI, follow my instructions in the README_comfy.md https://github.com/benrugg/AI-Render/blob/comfyui-support/README_comfy.md#installation-of-comfyui On my machines, I found that is better to have Python 3.11 on system and install a 3.11 conda env on top of that. I worked with the addon and the comfyui backend extensively on Windows, but I also did some test on macos. I’ll implement a proper websocket connection and image upload during my next project. So it will be possible to use a remote Comfy server just by changing the address. Thanks to you for sharing your repo. Learned a lot from this code base. |
Great - thank you for calling that all out. I work on a Mac all day, but keep a PC for testing, too, so hopefully we'll cover all the bases 😄 |
Hey @RobeSantoro, I looked through this in detail today (finally!). I'm really impressed with all the work you've put into this. It's such a powerful set of features! 💯 I'd like to move forward with getting this merged in and released in Github, Blender Market and Gumroad. Because so many of my users are not coders, I tried to make the UI as intuitive and simple as possible. (Not sure I totally hit that mark, haha, because Blender is so restrictive 😅). With that in mind, though, I'd like to remove the backend preferences from the Setup panel, just to keep it simpler. Here are my notes as I just tested everything:
Feel free to make a PR to merge the comfyui-support branch to main. You'll need to merge my recent changes or rebase. After we get this merged, I'll probably add the Comfy readme instructions to one of the wiki pages. And when it's all merged in, I'll create the release and update Blender Market and Gumroad. Let me know if you want to discuss anything! |
Hi @benrugg! I want to see my contribution merged into the main and totally agree with you about your considerations. Of course, it's a bad practice to show Preferences in the UI Panels. I did that and the Quick switch to Comfy only for development purposes, I'll remove them as I prepare the PR. The same goes for the allowance for empty prompts. I'll check the OS issue on macOS. It's just a little automation to create folders for animations I used during production to quickly test generation parameters. If I cannot find a solution I will remove it too. I'll check for the upscaler definitions needs and bump up the version. Thanks for taking the time to review the branch. |
Sounds great! Thank you for taking the time to make this all happen. |
Describe the feature you'd like to see:
Hi Ben,
It would be great if besides connecting to A1111 locally, blender could also connect to a running instance of ComfyUI. I've tried using its localhost address, but it cant connect tioit via API. Also, I don't know how much Comfy's node structure would impact what you have already developed around A1111.
Additional information
No response
The text was updated successfully, but these errors were encountered: