Nodes/Comfyui_CXH_joy_caption/CXH_IC_Lora_Florence2Run
ComfyUI Node

CXH_IC_Lora_Florence2Run

Captioning image pairs for IC-LoRA clothing datasets

By StartHua·Created 2 years ago·Updated 2 years ago· 624
CXH_IC_Lora_Florence2Run
  • florence2_model
  • caption
tip_pipe
format
max_new_tokens512
dir1
dir2
saveDir
text1
text2
templateRealistic style, [cloth-on], the image pair highlights a transformation from a clothing sample photo to the effect of actually wearing it. [image1] {caption} [image2] a female model is wearing the cloth from [image1] with {caption}
directionright
match_image_sizetrue

CXH_IC_Lora_Florence2Run exists for one very specific job: building training captions for IC-LoRA datasets - the image-conditioned LoRA setup popular in the Chinese community for clothing, where every training sample is a pair: the product/garment photo and a photo of it being worn. Both images are concatenated into one frame, Florence 2 captions the pair, and the node writes out a caption that references both halves.

This is the "IC" workflow the pack's README workflow images are built around, and the default template shows the intent plainly: Realistic style, [cloth-on], the image pair highlights a transformation from a clothing sample photo to the effect of actually wearing it. [image1] {caption} [image2] a female model is wearing the cloth from [image1] with {caption}.

How it works

For each image in dir1, it looks up the same-named file in dir2 (paired by filename - both folders need matching names), stitches the two images into a single frame in the direction you pick (right/down/left/up), and runs Florence 2 to caption the composite. Then it does string surgery on template:

  • {caption} → the model's caption
  • {text1} / {text2} → whatever you typed in those two multiline boxes

The result is written as a .txt next to a saved copy of the pair in saveDir. match_image_size (default on) resizes the second image to match the first before stitching, so pairs stay aligned.

Inputs and outputs

  • florence2_model - from CXH_DownloadAndLoadFlorence2Model.
  • tip_pipe - a string input that the source only prints. It's effectively a leftover; leave it empty.
  • dir1, dir2, saveDir - source folders and output folder.
  • format (png/jpg), max_new_tokens (default 512), text1, text2, template, direction, match_image_size.
  • Output: caption (STRING) - the last generated caption. The real per-image results are the .txt files on disk.

Installing

Standard pack install - ComfyUI Manager (search "Comfyui_CXH_joy_caption") or:

cd ComfyUI/custom_nodes
git clone https://github.com/StartHua/Comfyui_CXH_joy_caption
cd Comfyui_CXH_joy_caption
python -m pip install -r requirements.txt

Then load a Florence 2 model (the loader node) - the model download happens there.

Gotchas

  • Filenames must match across dir1 and dir2. No fuzzy matching; a missing pair just gets skipped with a print you might miss.
  • Empty dir1 raises an error (FileNotFoundError on the folder or "No files in directory").
  • match_image_size off means the stitch can look ragged, which degrades the caption. Keep it on unless you're deliberately captioning mixed-size pairs.
  • The caption output is only the last one - if you need per-image captions, read the .txt files out of saveDir.
  • For a JoyCaption-based version of the same job, use CXH_Ic_lora_Joy_batch; it's the same idea with the stronger caption model and no Florence-2 loader needed.
CategoryFlorence2

Inputs (12)

NameTypeDefaultDescription
tip_pipeSTRING
florence2_modelFL2MODEL
formatCOMBO2 options: png, jpg
max_new_tokensINT51210–4096
dir1STRING
dir2STRING
saveDirSTRING
text1STRING
text2STRING
templateSTRINGRealistic style, [cloth-on], the image pair highlights a transformation from a clothing sample photo to the effect of actually wearing it. [image1] {caption} [image2] a female model is wearing the cloth from [image1] with {caption}
directionCOMBOright4 options: right, down, left, up
match_image_sizeBOOLEANtrue

Outputs (1)

NameTypeDescription
captionSTRING