Nodes Browser
ComfyDeploy: How ComfyUI-Loop works in ComfyUI?
What is ComfyUI-Loop?
A pair of nodes (Load Image and Save Image) to create a simple loop in your ComfyUI inpainting workflow, without the need of loading your last saved image
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
ComfyUI-Loop
and select it - Close the build step dialig and then click on the "Save" button to rebuild the machine
ComfyUI-Loop
ComfyUI-Loop is essentially a pair of nodes designed to create a simple image loop within your workflows. The operating principle is straightforward: the Save Image (LOOP) node saves an image by overwriting the file specified in the 'image path' field, making it automatically available for the next iteration. This functionality is primarily intended for inpainting workflows.
The current code is relatively basic, but special care has been taken to preserve image data quality and prevent degradation. Visually, there is no noticeable loss in quality even after 150 iterations, and ~~theoretically, this should~~(a) remain true after a thousand consecutive loops and saves.
01/07/25 : tired of writing paths ? I added a browser to the Image Loader (now use 'output' folder only). Use fix node to recreate the node in your graph.
01/05/25 update : The day after releasing the initial version on GitHub, I added two more nodes from my toolkit: Cut Image (LOOP) and Paste Image (LOOP). These nodes facilitate working with large images by cutting a specific part of an image, sending it to your inpainting workflow, KSampler, or other processes, and then pasting it back in place afterward. You can find an example workflow in the example_workflow folder.
Install
No additional dependencies are required. Search for 'Loop' in the ComfyUI Custom Nodes Manager or copy the ComfyUI-Loop folder into the Custom Nodes directory — and you're ready to go!
Usage
- in Load Image (LOOP) node browse for an image from output folder (or feed the field with its name e.g. 'image.png'). Always work on a copy of your source file (if you don't want it to be overwritten).
- Connect the path output from Load Image (LOOP) to the image_path input of Save Image (LOOP).
- The mask input in Save Image (LOOP) is optional.
- Enable save steps if you want to keep a copy of the file at each iteration.
Limitations
- No support for image lists or batch inputs in 'Save Image (LOOP)'. If a list is provided, only the first image will be saved and displayed repeatedly.
- Mask format compatibility: If a mask is used, it must match the image format to be saved in the alpha channel. Otherwise, the output will be saved in RGB mode instead of RGBA.
- No preview in the 'Load Image (LOOP)' node (But you know what you’ve loaded, right? :) ). This design choice prevents ComfyUI from hanging when loading large 64Mpixels images :).
- Large file sizes due to uncompressed output for maximum quality preservation.
Troubleshoot
With KJNodes Resize Mask. If you get an error 'Cannot handle this data type: (1, 1, 1), |u1', do a Convert Mask to Image > KJNodes Resize Image > Convert Image to Mask as a workaround.
Future plans
This is an alpha version created in one evening. I plan to revisit the code later but it works well for basic use (I’m currently working on something else, smarter... but don't judge a fish by its ability to climb a tree, I will just do my best :D). If you encounter issues or have suggestions, ask on the repo ! :)
If you enjoy this project and want to help its development, consider buying me a coffee . your support makes a difference! ♥️
(a) Finally tested on 1000 loops, so you don’t have to wear out your SSD for proofing. A diff returns a perfectly black image in GIMP.