Image Loader Crawl Batch (CRT)
Grab a deterministic window of images from a folder, seed by seed
- images
- file_names
- file_paths
- batch_count
- total_images
- sidecar_txt_prompt
Loading one image is easy; crawling through a folder a batch at a time, deterministically, so that seed 5 gives you a different window than seed 3 - that's the annoying part of dataset-driven rendering. Image Loader Crawl Batch (CRT) does exactly that, and it's a quiet workhorse of the CRT pack's batch workflow.
The name says it: it "crawls" a folder and loads batch_count images at once. The trick is how it picks them. The starting image is (seed × batch_count) % total_images, and it loads batch_count consecutive images from there, wrapping around the folder when it hits the end. Change the seed, change the window. Same seed, same window, every time - which is exactly what you want when you're pairing image batches with seeds for reproducible renders.
How it works
Point it at a folder, and it lists the images (natural-sorted, so img2.png sorts before img10.png - the kind of thing naive sort gets wrong), then:
- loads the window of images at
batch_countresolution, - resizes each to your target
megapixelswith Lanczos, preserving aspect ratio, - and if the batch has mixed aspect ratios, center-crops everything to the average aspect ratio so they stack into one tensor.
Outputs are images (the batch tensor), file_names and file_paths (newline-joined strings, one per image - handy for saving sidecar metadata or naming outputs), batch_count, and total_images (so downstream nodes know how many windows exist). It can also recurse into subfolders via crawl_subfolders, and remove_extension strips file extensions from the returned names.
There's a genuinely thoughtful bit under the hood: it prefetches the next seed's window in a background thread while the current one is being processed, so your resize/load work overlaps with GPU inference instead of stalling the pipeline. It keeps only one future batch cached, so memory stays bounded on long runs.
The inputs that matter
folder_path- the directory. Empty or missing → a blank batch and an error string infile_names, so watch for that.batch_count- images per load (1–128).seed- the window selector. This is the knob you'll sweep.megapixels- target resolution; 1.0 is a good default for most work.print_index- logs each selected file and index to the console. Leave it on while debugging, off for clean logs.
Where it fits
It's the image side of the CRT batch loop. Load a window of images → feed them to CRT's KSampler Batch (which encodes them and samples variations per item) → sweep the seed and every run picks a fresh set of images with fresh prompts. If you're rendering through a Z-Image or Flux batch pipeline, this is the loader that keeps the folder→latent pipeline automatic.
Install and gotchas
Pack install, same as everything else in CRT-Nodes:
cd ComfyUI/custom_nodes
git clone https://github.com/PGCRT/CRT-Nodes.git
pip install -r requirements.txt
or ComfyUI Manager → "CRT-Nodes". It honors sidecar .txt files (same name, .txt extension) - worth knowing if your dataset carries prompt files beside images. Real gotchas: mixed aspect ratios get center-cropped, not padded, so wildly different ARs in one folder mean content loss at the edges - keep batches roughly uniform. And the seed math means a batch with total_images smaller than your window just wraps and repeats, so set batch_count below the folder size unless repetition is the plan.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| folder_path | STRING | — | |
| batch_count | INT | 11–128 | Number of images to load. Window starts at seed × batch_count and wraps around the folder. |
| seed | INT | 00–18446744073709550000 | Selects the starting image: index = (seed × batch_count) % total_images. |
| megapixels | FLOAT | 1.000.1–16 | Target resolution in megapixels. Ignored when No resize is enabled. |
| No resize | BOOLEAN | false | Bypass resampling. Mixed-size batches are center-padded to the largest image. |
| crawl_subfolders | BOOLEAN | false | — |
| remove_extension | BOOLEAN | false | — |
| print_index | BOOLEAN | true | Print each selected file index and name to the console. |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |
| file_names | STRING | — |
| file_paths | STRING | — |
| batch_count | INT | — |
| total_images | INT | — |
| sidecar_txt_prompt | STRING | — |