CXH_IC_lora_reversal
The caption reverser that doubles your IC-LoRA dataset
- caption
Here's the trick this pack is quietly built around: IC-LoRA captioning only writes captions in one direction ("here's the garment, here's it being worn"). CXH_IC_lora_reversal manufactures the reverse - captions that describe the same pair going the other way ("here's the model wearing it, here's the garment") - without re-running the vision model at all. You get a second, direction-reversed training set for free, which materially helps a LoRA generalize rather than just memorizing one arrangement.
It's a text-processing node wearing a caption node's clothes. No model input, no image captioning happens - it reads the captions you already generated, flips the framing, and writes new pairs.
How it works
For each image in dir1, it needs:
- The paired image in
dir2(same filename), - An existing caption
.txtintext_dir(same base filename).
It reads the existing caption, slices out the segment between slic_start (default [image1]) and slic_end (default [image2]) - i.e. the actual model-written description - and feeds it into a reversed template whose default reads: Realistic style, [cloth-on], the image pair highlights a transformation from a female model wearing the cloth to its clothing sample photo. [image1] a female model is wearing a cloth with {caption} [image2] the clothing sample photo of what the model is wearing in [image1] with {caption}.
The rewritten caption plus a re-stitched image pair (same direction/match_image_size logic as the other IC nodes) land in save_dir. If the output file already exists, it skips - so re-runs are cheap and resume-friendly.
Inputs
dir1,dir2- the image pair folders.text_dir- where the source.txtcaptions live.save_dir- reversed output goes here.slic_start,slic_end- the markers around the caption you want to reuse; default to[image1]and[image2], matching the templates used by the captioning nodes.text1,text2,template,direction,match_image_size,format.- Output:
caption(STRING) - last processed caption; real output is on disk.
Installing
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
No model downloads - this node never touches a model.
Gotchas
- Missing pair or missing
.txt→ skipped silently. It prints "Second image not found" but there's no error dialog. Check your file counts. - The slice assumes your source captions contain
[image1]and[image2]markers. If your captioner ran with a template that omitted them,.index()raises an error. Use the pack's own IC caption nodes upstream so the markers exist. - Skipping existing files is the resume feature - but if you changed the template, stale files won't be regenerated. Clear
save_dirwhen you change anything.
Inputs (12)
| Name | Type | Default | Description |
|---|---|---|---|
| dir1 | STRING | — | |
| dir2 | STRING | — | |
| text_dir | STRING | — | |
| save_dir | STRING | — | |
| slic_start | STRING | [image1] | — |
| slic_end | STRING | [image2] | — |
| format | COMBO | 2 options: png, jpg | |
| text1 | STRING | — | |
| text2 | STRING | — | |
| template | STRING | Realistic style, [cloth-on], the image pair highlights a transformation from a female model wearing the cloth to its clothing sample photo. [image1] a female model is wearing a cloth with {caption} [image2] the clothing sample photo of what the model is wearing in [image1] with {caption} | — |
| direction | COMBO | right | 4 options: right, down, left, up |
| match_image_size | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| caption | STRING | — |