Nodes Browser
ComfyDeploy: How ControlFlowUtils works in ComfyUI?
What is ControlFlowUtils?
Custom nodes to improve flow control and logic + several utilities to enhance capabilities
How to install it in ComfyDeploy?
Head over to the machine page
- Click on the "Create a new machine" button
- Select the
Edit
build steps - Add a new step -> Custom Node
- Search for
ControlFlowUtils
and select it - Close the build step dialig and then click on the "Save" button to rebuild the machine
ControlFlowUtils
Custom nodes for ComfyUI to enable flow control with advanced loops, conditional branching, logic operations and several other nifty utilities to enhance your ComfyUI workflows.
Latest Release: v0.0.6 Alpha (2024-09-28 - "More Bugfixes!")
Quick Demonstration
Here is a clip of one of the sample workflows in action, showcasing utilizing cycles to achieve iterative generation with different models and image sizes:
https://github.com/user-attachments/assets/4f3e7f3e-58fe-45f8-9e12-219e28860939
Furthermore, here is a simpler demonstration of looping in ComfyUI and preserving values across multiple queues with the nodes in this pack:
https://github.com/user-attachments/assets/c7cddfb5-6881-4fe8-858d-a644fb6ea9a3
Included Nodes
These are the nodes currently implemented by this pack along with a basic description of their functionalities so you can have an idea of what this pack currently includes. For more detailed information, click on the title of each node which will direct you to its entry in Wiki.
Loops
These two nodes make it possible to implement in-place looping in ComfyUI by utilzing the new Execution Model, in a simple but very powerful way. With the power of Loops, you are able to repeatedly execute a specific subset of notes in your workflow and automate all sorts of complex tasks!
Cycles
These three nodes in conjunction allow you to implement progressive tasks in ComfyUI by caching data to be processed through multiple successive prompts. Here is what a basic loop chain looks like:
Simply replace the Null Output node with the Data of your choice and it will be sent along with the loop allowing you to process any data iteratively.
If Selectors
This node allows you to easily test for any condition of your choice, including custom programmable conditions to divert execution based on how the condition evaluates to True or False, allowing for dynamic branching under ComfyUI's new execution model.
Universal Switches
This node allows you to map one or multiple inputs to one or multiple outputs according to a specific programmable criteria of your choice. The uses for this node are many but principal among them is forwarding different models, samplers, etc to different sections of your workflow based on specific logical conditions, allowing for branching and dynamic paths when used in conjunction with the IF Selector node.
Halt Execution
This node allows you to instantly cancel the prompt or simply to block execution past a certain point based on a specific condition. You can use it to have your workflow execute different sections based on conditions, allowing for very complex behaviors to be implemented or to abort out of certain operations prematurely.
Memory Storages
Persistent variables for your ComfyUI, that last throughout the entire lifespan of your workflow, no matter how many executions you make. You can save anything in these nodes, text, images, models, whatever you wish, and have them available anywhere, anytime in your workflow. Use these nodes to transmit data between different parts of the workflow or even to cache data to perform different operations on every execution. For instance, you could have a first pass which generates an image, then stores it in an Memory Storage, then another execution retrieves that image and refines and upscales it, and a third pass can compose it with a background of your choice. Really, your creativity is the only limiting factor with what is possible now that you can save data to your heart's content!
Model Unloader
Running out of VRAM is a thing of the past! Now you don't need to rely on ComfyUI to properly manage its memory allocation in order to run complex workflows with heavy models such as Flux. You can take charge of your workflow and forcefully unload models when they're no longer in use. Your Workflow uses many different models at different stages but they don't all need to be loaded to VRAM at once? You'll certainly want this node!
Garbage Collector
This one is for everyone with low RAM (16gb or less) systems that struggle with too much memory usage and keep having to cache or resort to page files which drastically slows down execution. This node will force ComfyUI, Torch and Python to garbage collect, as well as allow for full RAM clearing on Windows, to free up as much memory as possible for your image generation!
Data Monitor
Your one stop shop for all things Data in ComfyUI. This node allows you to visualize the output of any nodes with full passthrough support, serves as a convenient textbox while allowing you to pick the type of the data you wish to convert your output to, supports advanced features including the ability to run advanced mathematical evaluations, data generations, conditions and straight up any valid python code in a safe and non-exploitable manner, and much, much more! For a full list of supported features, consult the wiki entry.
String/List Operations
This node has you covered for essentially any kind of basic string or list data manipulation you may need to perform in your workflow. It's surprising how often these come up and how many nodes from dozens of different packs are typically needed to handle them. Well, now you can have everything in a single easy-to-use node and greatly simplify your workflows in the process!
Wait (Delay Execution)
This node simply allows you to wait a preconfigured amount of seconds (or milliseconds) in between nodes. You can use to ensure you have enough time to clear your memory, to save resources to disk, or even group a bunch of these with 0 delay together to simply pad out a workflow and manipulate its execution order when you have multiple concurrent branches. Just a nifty little addition that has come in handy many times for me!
Image Resolution Adjust
This node will dynamically adjust the sizes of your images for any aspect ratio of your choice by performing the calculations to maintain the ratio for you for any given width, height or scaling factor. A real timesaver, now you don't need to do the math with a bunch of nodes anymore, and you can even change the scaling dynamically!
Fallback Image Previews
Image Previews in ComfyUI have one giant flaw. If you don't pass a valid image to them at any point in your workflow, they will stop your workflow dead in its tracks. This makes conditional branching for generating images at different parts of the workflow a nightmare to deal with. Well no mare. This smart node will silently ignore empty or invalid images or even generate a placeholder image if it's not supplied with a valid image instead!
Fallback Any Batch
This node allows you to create batches with any kind of Data, whether they're images, latents or even primitive data types like strings, tuples and lists. It will dynamically adjust to the data you give it and all the inputs are optional, so you don't have to worry about missing nodes. Invaluable to use within loops and cycles when you're trying to combine multiple image generations but the first iteration of the loop only has the one image!
Folder Search
Easily retrieve a list of files within a folder of your choice for processing within ComfyUI with many options to customize the searching operation, such as filtering by extension or path masks, retrieving folders and files by name, relative, or absolute paths, retrieving one file at a time or all at once and much much more!
File Reading and Writing
These nodes allow you to easily read and write to text files anywhere in your system, allowing you to easily load in wildcards, lora triggers, save logs of your workflow execution or anything else you may need!
Other Convenient Nodes
Check the Wiki page for a full description of these nodes! Attached are the images for some of the more niche however very useful nodes this pack includes for convenience. It's all about the little things!
That's it for now. If you have any issues or feedback feel free to leave a comment in the relevant section of this Github!
This node will be regularly updated with new features that to improve your ComfyUI logic and dynamic workflows even more. Next up, we'll be looking at in-place loops.
Stay tuned and happy Comfy'ing!!
KNOWN ISSUES
- Currently the Memory Storages are a little TOO persistent. They will persist even if you load a new workflow. Make sure to clean them via a __MEM__STORAGE__CLEAR operation before switching workflows or restart ComfyUI if you have issues from this. I'm exploring potential solutions and the next release should have a fix for this.