Nodes/Comfyui_CXH_joy_caption/Joy_caption_alpha_batch
ComfyUI Node

Joy_caption_alpha_batch

Dataset labeling with JoyCaption Alpha Two and a trigger word

By StartHua·Created 2 years ago·Updated 2 years ago· 624
Joy_caption_alpha_batch
  • JoyPipeline_alpha
  • STRING
img_dir
save_dir
triggertrigger
promptA descriptive caption for this image
format
max_new_tokens1024
temperature0.70
cachefalse
low_vramfalse
seed656545

This is the node that makes the pack worth installing for anyone training LoRAs: point it at a folder of images and it captions every one with JoyCaption Alpha Two, writes a matching .txt next to each image, and prepends your trigger word to every caption. That's the entire boring, soul-destroying part of dataset preparation, automated.

The README frames it as batch marking ("批量打标") and quotes ~4–5 seconds per image on a 4090. For a typical 20–30 image LoRA set you're done in a couple of minutes.

What it does

For each image in img_dir it runs the Alpha Two pipeline (SigLIP → adapter → Llama), then writes two files into save_dir:

  • trigger_<n>.txt - containing trigger,<caption>
  • trigger_<n>.<format> - a copy of the image, renamed to match

The trigger field (default "trigger") is your training activation word. So with trigger=ohwx every caption becomes ohwx, a woman standing in... - exactly the format LoRA trainers want, with the activation baked in. The numbered rename keeps images and captions paired even if your originals had awkward names.

The inputs that matter

  • JoyPipeline_alpha - from Joy_caption_alpha_load.
  • img_dir - folder of source images.
  • save_dir - where labeled pairs go.
  • trigger - the activation word, prepended to every caption.
  • prompt - wire a Joy_caption_alpha_prompt output here for styled captions, or leave the descriptive default.
  • format - png or jpg output.
  • max_new_tokens, temperature - generation controls.
  • cache, low_vram, seed - same semantics as Joy_caption_alpha_run (see that article): cache=True keeps the ~10 GB pipeline resident for a big batch; low_vram=True unloads your diffusion models first so the captioner can breathe.

There's no meaningful output - a STRING comes out but it's not a per-image caption; the real results land 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 restart and make sure the Alpha Two checkpoint is in models/Joy_caption_alpha/ (manual download - see the Joy_caption_alpha_load article).

Troubleshooting

  • "Directory cannot be found": the node does a literal os.path.isdir check and raises FileNotFoundError. Absolute paths work; make sure the folder exists before you hit Run.
  • Slow batch: cache is False by default, so the model unloads after every single image - brutally slow on a large folder. Flip cache=True for a real batch run.
  • Trigger word gotcha: if you change the trigger mid-run, previously written .txt files don't get renamed. Clean the save_dir before re-running.
  • Only NVIDIA, as with everything in this pack.
  • For multi-folder datasets with per-folder triggers, use Joy_caption_alpha_batch_Dirs instead - it derives the trigger from the folder name.
CategoryCXH/LLM

Inputs (11)

NameTypeDefaultDescription
JoyPipeline_alphaJoyPipeline_alpha
img_dirSTRING
save_dirSTRING
triggerSTRINGtrigger
promptSTRINGA descriptive caption for this image
formatCOMBO2 options: png, jpg
max_new_tokensINT102410–4096
temperatureFLOAT0.700–1
cacheBOOLEANfalse
low_vramBOOLEANfalse
seedINT6565450–1000000

Outputs (1)

NameTypeDescription
STRINGSTRING