YG Auto Image Cycler
YG Auto Image Cycler
- image
- mask
- filename
- current_index
- total_count
Ever wanted to run a workflow on fifty different input images and go make tea instead of clicking "load next image" fifty times? That's the whole job of YG Auto Image Cycler. It's a drop-in replacement for ComfyUI's built-in Load Image, except instead of you picking a file every run, it picks the next file in a folder for you. Set your queue to run N times, and each run sees the next image.
How it works
The clever bit is how the node forces ComfyUI to actually advance. A normal loader node gets cached - run once, and the engine decides nothing upstream changed so it skips re-executing. YG Auto Image Cycler opts out of that with the IS_CHANGED trick (returning a fresh hash every prompt), so it always fires and advances its counter. The counter is persisted to /tmp/yg_auto_cycler_state.json, keyed by your cycle_id, so a 100-run queue doesn't reset halfway through.
Images get in via the "📁 Upload Images" button on the node - the pack ships a web extension that posts your files to a /yg_cycler/upload endpoint on the server. They land in ComfyUI/input/yg_cycler/<cycle_id>/. Or you can point the folder input at any absolute server-side path and skip uploading entirely.
The inputs and outputs that matter
cycle_id- the job name. Use a different one for each cycler in a graph; state stays separate.folder-"upload"(the default) means "use the upload button." Set it to an absolute path to read an existing folder instead.mode-sequentialorrandom. Sequential walks the sorted file list; random does a pseudo-random pick per run (seeded from the counter, so no two runs repeat within a cycle).start_index- where the counter starts.wrap- loop back to the first image after the last (off means it sticks on the last one).reset_now- flip it on for one run to rewind the counter.
Outputs mirror Load Image, so wiring is familiar: image and mask go into whatever your pipeline eats, and filename, current_index, and total_count are there when you want the batch number in a filename or a save node. The mask is a transparency mask (inverted alpha), so images with alpha come through with a proper mask, matching how ComfyUI's built-in loader behaves.
Installing it
It's one of twelve nodes in the comfyui_yg_nodes pack, a MIT-licensed utility grab-bag by Mallikarjuna Rao Koliparthi (published to the Comfy Registry as "YG Custom Nodes", v1.0.4). Zero extra Python dependencies - nothing to pip-install. Either grab it in ComfyUI Manager (search comfyui_yg_nodes), or:
cd ComfyUI/custom_nodes
git clone https://github.com/mallikarjunaraokoliparthi/comfyui_yg_nodes.git
Restart ComfyUI and it shows up in the YG_Nodes menu.
Where people get burned
The node errors out loudly if the folder is empty - "No images found" - which is the common first-run mistake: you forget to actually click the upload button. Also remember the counter state lives in /tmp, so a reboot resets it while the uploaded files stay in input/. That's usually what you want, but it's worth knowing if a cycle suddenly starts over. And because the node re-executes every run, it forces whatever's downstream to run too - that's the point here, but it does defeat caching for everything behind it, so don't leave one in a graph where you only want a single pass.
For what it is - a hand-rolled "cycle a folder across queue runs" node - it does the job with less ceremony than wiring up a folder loader plus a counter and a bunch of index math yourself.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| cycle_id | STRING | default | — |
| folder | STRING | upload | — |
| mode | COMBO | sequential | 2 options: sequential, random |
| start_index | INT | 00–99999 | — |
| wrap | BOOLEAN | true | — |
| reset_now | BOOLEAN | false | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| filename | STRING | — |
| current_index | INT | — |
| total_count | INT | — |