Nodes/Comfyui_CXH_joy_caption/Joy_caption_alpha_batch_Dirs
ComfyUI Node

Joy_caption_alpha_batch_Dirs

Per-folder captioning that reads your trigger from the folder name

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

If Joy_caption_alpha_batch automates the boring part of one dataset, this node automates the boring part of many. Joy_caption_alpha_batch_Dirs walks every subfolder under img_dir, captions each one with JoyCaption Alpha Two, and - here's the trick - pulls the trigger word out of the folder name itself. The README's rule: name your folders 名字_trigg (name_trigger), e.g. blue_jacket_ohwx. The node splits on the underscore and uses the second part as the activation word for everything in that folder.

This is a quality-of-life node for people managing a whole wardrobe of clothing LoRAs or a batch of character sets at once, where every subfolder is its own training dataset with its own trigger. Instead of running the single-folder batch once per dataset and manually retyping the trigger each time, you name the folders right and hit Run once.

How it works

For each subdirectory of img_dir it runs the same Alpha Two captioning loop as Joy_caption_alpha_batch, but:

  • trigger comes from get_trigger_from_string(subdir) - split the folder name on _, take the second part. mydataset_xyz → trigger xyz.
  • Output lands in save_dir/<subdir>/, preserving the per-dataset structure.
  • Files are written as trigger_<n>.txt (containing trigger,<caption>) and trigger_<n>.<format>.

If the folder name has no underscore, no trigger is written - captions still get saved, just without the activation prefix. Keep your folder names consistent if you want every caption to carry the trigger.

Inputs

  • JoyPipeline_alpha - from Joy_caption_alpha_load.
  • img_dir - parent folder; each subfolder is treated as a dataset.
  • save_dir - mirrored output structure, one subfolder per dataset.
  • prompt - default descriptive, or wire in a Joy_caption_alpha_prompt for styled captions.
  • format (png/jpg), max_new_tokens, temperature, cache, low_vram, seed - same semantics as the single-folder batch: set cache=True for a real multi-folder run, low_vram=True if the captioner is OOMing next to your checkpoint.

Output is a STRING that's effectively a completion marker; the real work lands on disk.

Installing

Same 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

Restart, and make sure the Alpha Two checkpoint is at models/Joy_caption_alpha/ (manual download - see Joy_caption_alpha_load).

Gotchas

  • No underscore, no trigger. The node quietly captions without the activation word, and you may not notice until you're reviewing captions later.
  • Empty subfolder raises FileNotFoundError. Check your dataset tree before a long run.
  • cache=False default means the model reloads between images - on a many-folder job that's hours of waiting. Flip it on.
  • NVIDIA only, as with the whole pack.
CategoryCXH/LLM

Inputs (10)

NameTypeDefaultDescription
JoyPipeline_alphaJoyPipeline_alpha
img_dirSTRING
save_dirSTRING
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