comfyanonymous / ComfyUI

The most powerful and modular stable diffusion GUI, api and backend with a graph/nodes interface.
https://www.comfy.org/
GNU General Public License v3.0
43k stars 4.54k forks source link

[Feature Request] Conditional execution control #313

Open jexom opened 1 year ago

jexom commented 1 year ago

Add nodes that allow to control the flow of execution i.e. conditional nodes that stop or change the execution path. As it stands in, for example, with latent upscale workflow you have to manually connect or disconnect the nodes to enable/disable the upscaling. A node that stops execution based on a condition would allow to make a switch to turn parts of the graph on and off or divert the execution to a different path (i.e. latent upscale vs upscale with a model workflows).

DaemonAlchemist commented 10 months ago

I'm making a Stable Diffusion UI in React using ComfyUI as a backend, and I would also find this kind of "switching" node extremely useful. Something like a Reroute node, but with two inputs and a selector toggle to pick one. Then everything upstream from the unselected input would be ignored.

For example, let's say I make a complex workflow, and want to use it for both SD 1.5 and SD XL+Refiner and both txt2img and img2img. With a switching node, I could use the same workflow for all of these. Without it, though, I would need to either make four separate workflows, or write code to generate a workflow prompt from scratch. That's not too bad in this case, but the complexity would grow exponentially if there are more than a few "feature toggles" to manage.

ltdrdata commented 10 months ago

Add nodes that allow to control the flow of execution i.e. conditional nodes that stop or change the execution path. As it stands in, for example, with latent upscale workflow you have to manually connect or disconnect the nodes to enable/disable the upscaling. A node that stops execution based on a condition would allow to make a switch to turn parts of the graph on and off or divert the execution to a different path (i.e. latent upscale vs upscale with a model workflows).

In fact, this request has been around for quite some time, but due to complex issues, it is currently not implemented. There is a major PR in progress related to execution, and it is expected that this issue will be naturally resolved when this implementation is merged.

Until then, you can temporarily control this through the Switch/Inversed Switch I created. https://www.youtube.com/watch?v=KLe1hShwVDs

robinjhuang commented 2 weeks ago

Will be Fixed by #2666