Nodes/ComfyUI-ZFRNodes/Dataset Prep
ComfyUI Node

Dataset Prep

Batch-generate a LoRA dataset in one node run

By zfrsgtcu·Created 3 months ago·Updated 13 days ago· 32
Dataset Prep
  • images
  • images
  • log
  • count
modeimage_to_image
prompt
unet_name
vae_name
clip_name
clip_typeflux2
lora_name
lora_strength1.00
trigger_words
width960
height1200
steps8
cfg1.0
guidance3.5
denoise1.00
sampler_nameeuler
schedulersimple
seed0
seed_modeincrement
reference_size_modematch_reference
num_images0
output_dirdataset
filename_prefixdata

Generating a LoRA training set used to mean queuing a single-image generator a hundred times and hoping nothing OOMs halfway through. Dataset Prep is the ZFRNodes answer to that: it takes a whole folder of references as one IMAGE batch and runs the full generation loop over every image inside a single node, saving each result to disk. One queue run instead of a hundred.

This is the unglamorous half of training, and it matters more than any hyperparameter. The standing advice is that dataset curation beats every knob in the config - so the workflow here is worth setting up once. The pack's dataset pipeline looks like: Reference Image Loader (Path)Dataset PrepCaption Generator, and this node is the middle of that chain.

How it works

Mechanically it's the same Flux2-style generation as the pack's Simple Image Generator (Multiple): it loads the UNET, VAE, CLIP, and optional LoRA once and reuses them across every image, which is why it's so much faster than re-running a single-image node in a loop. Two modes:

  • image_to_image (default) - every input image becomes a reference. Your prompt describes the transform - the classic job is pushing a folder of scraped photos toward one consistent style.
  • text_to_image - inputs are ignored; the prompt alone generates num_images fresh images (or one per input image if num_images is 0).

Each image is VAE-encoded and injected into the positive conditioning via Flux2's ReferenceLatent, the same reference mechanism the rest of the pack uses. seed_mode defaults to increment so outputs vary instead of repeating, and it frees GPU memory between images so big folders don't run out of VRAM mid-batch. Everything gets saved to disk - output_dir and filename_prefix control where and what it's called.

Inputs that matter

  • images - the IMAGE batch, straight from Reference Image Loader (Path).
  • mode - the image_to_image / text_to_image switch.
  • prompt - what you want done to (or generated from) each image.
  • The model loaders: unet_name, vae_name, clip_name, and clip_type (default flux2).
  • num_images - how many to produce in text-to-image mode (0 = one per input).
  • reference_size_mode - match_reference keeps each image's own aspect ratio; fit_to_width_height fits them into the width×height box, aspect preserved.

Outputs: images (all results as one batch, handy for a quick preview), log (per-image seed/size/save status), and count.

Install

Standard ZFRNodes install - search ComfyUI-ZFRNodes in ComfyUI Manager, or:

cd /path/to/ComfyUI/custom_nodes
git clone https://github.com/zfrsgtcu/ComfyUI-ZFRNodes.git

Dependencies are just numpy, torch, and Pillow, which ComfyUI already has. Then fully restart - a browser refresh won't do, because the pack's frontend script registers on load.

Common issues

  • Errors inside sampling - a clip_type that doesn't match the model you loaded will blow up mid-run. The pack is built and tested against flux-2-klein with a Qwen text encoder (clip_type = flux2); the i2i path relies on ReferenceLatent, so models without reference-latent conditioning won't behave in image_to_image mode. text_to_image mode still works fine.
  • Long runs - a big folder in one shot is a long queue. Test on a handful first (cap it upstream with max_images on the loader), then let the whole folder rip.
  • Getting captions after - note there's no graph wire between this node and Caption Generator; that one reads its own folder from disk. Run Dataset Prep, then point Caption Generator's folder picker at Dataset Prep's output folder, and you've gone from "a folder of source photos" to "a captioned dataset" in two node runs.
Categoryzfr-nodes

Inputs (24)

NameTypeDefaultDescription
imagesIMAGE
modeCOMBOimage_to_image2 options: image_to_image, text_to_image
promptSTRING
unet_nameCOMBO0 options:
vae_nameCOMBO0 options:
clip_nameCOMBO0 options:
clip_typeCOMBOflux228 options: stable_diffusion, stable_cascade, sd3, stable_audio, mochi, ltxv, +22
lora_nameCOMBO1 options: None
lora_strengthFLOAT1.00-10–10
trigger_wordsSTRING
widthINT96064–8192
heightINT120064–8192
stepsINT81–200
cfgFLOAT1.00–30
guidanceFLOAT3.50–100
denoiseFLOAT1.000–1
sampler_nameCOMBOeuler44 options: euler, euler_cfg_pp, euler_ancestral, euler_ancestral_cfg_pp, heun, heunpp2, +38
schedulerCOMBOsimple9 options: simple, sgm_uniform, karras, exponential, ddim_uniform, beta, +3
seedINT00–18446744073709550000
seed_modeCOMBOincrement3 options: increment, fixed, random
reference_size_modeCOMBOmatch_reference2 options: match_reference, fit_to_width_height
num_imagesINT00–100000
output_dirSTRINGdataset
filename_prefixSTRINGdata

Outputs (3)

NameTypeDescription
imagesIMAGE
logSTRING
countINT