R-山竹kontext路径保存
The 'before' half of a Kontext training pair, named exactly how T2ITrainer wants it
- image
The R-山竹kontext路径保存 node (class RSZImageTaggerSave) is one half of the reason this pack exists. ComfyUI_SZtools is a small, Chinese-first pack built to prep training sets for lrzjason's T2ITrainer - a local trainer for Flux Kontext LoRAs that expects its data named xxx_R.png + xxx_T.png with a matching .txt caption. This node is the "R" side: it takes the reference images of your A/B pairs, renames them comfyui0001_R.png, comfyui0002_R.png, and optionally drops a .txt next to each.
Kontext is BFL's 12B instruction-based editor: you feed it an image plus a sentence and it edits the image. Training a Kontext LoRA means feeding it pairs - the "before" image and the "after" image plus the instruction that turned one into the other. T2ITrainer wants the before named _R and the after named _T. Load your raw set, wire this node in for the references, and the T variant for the edits, and the folder comes out ready to train. The repo even ships an example workflow showing the whole pass: load folder → Florence2 interrogation → join text → save both sides.
How it works
Mechanically it's a save node, not a clever one. It takes an IMAGE batch, converts each tensor back to a PIL image, and writes it to custom_path (or, if you leave that blank, ComfyUI's default output folder). The filename is {filename_prefix}{counter:04d}_R.png - the default prefix is comfyui, so you get comfyui0001_R.png, with a per-node-instance counter that runs 0001→9999 then wraps.
Two details actually matter here:
- It can skip the text file. Unlike the T node,
tag_textis a plain widget (not a forced input), and if it's empty the node saves just the image and no.txt. That's the "可/不可保存反推文本" (may or may not save reverse-inference text) the README talks about - keep the reference caption or don't. formatis png or jpg, andquality(80–100, default 100) maps onto PNG compression level too, so 100 keeps things essentially lossless. JPG drops alpha and converts RGBA to RGB.
The inputs that matter
Just set custom_path (where the renamed images land), filename_prefix, and tag_text if you want captions. preview (default on) just shows the last image in the UI - harmless, leave it.
Install and gotchas
Install is the shared pack story: ComfyUI Manager (search "ComfyUI_SZtools") or git clone https://github.com/Rocky-Lee-001/ComfyUI_SZtools into custom_nodes/, then restart. Dependencies are light - torch, numpy and Pillow already ship with ComfyUI; the pack only adds imageio and tifffile, and you won't touch those with this node.
Watch out for the counter: it's per node instance and resets every time ComfyUI restarts, so running the same workflow twice silently overwrites the previous files. Point custom_path at a real folder, ideally an empty one for each pass. And set expectations: this pack has essentially zero Western community footprint - the README is Chinese-first, node names are Chinese, and the author (山竹老师, "Teacher Mangosteen") posts on Bilibili. It works fine; it's just a personal-toolkit vibe, so don't expect tutorials in English.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| tag_text | STRING | — | |
| custom_path | STRING | — | |
| filename_prefix | STRING | comfyui | — |
| format | COMBO | 2 options: png, jpg | |
| quality | INT | 10080–100 | — |
| preview | BOOLEAN | true | — |
Outputs (0)
No outputs