Nodes/ComfyUI_SZtools/R-山竹kontext路径保存
ComfyUI Node

R-山竹kontext路径保存

The 'before' half of a Kontext training pair, named exactly how T2ITrainer wants it

By Rocky-Lee-001·Created about a year ago·Updated about a year ago· 2
R-山竹kontext路径保存
  • image
    tag_text
    custom_path
    filename_prefixcomfyui
    format
    quality100
    previewtrue

    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_text is 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.
    • format is png or jpg, and quality (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.

    CategoryR-山竹Kontext路径保存

    Inputs (7)

    NameTypeDefaultDescription
    imageIMAGE
    tag_textSTRING
    custom_pathSTRING
    filename_prefixSTRINGcomfyui
    formatCOMBO2 options: png, jpg
    qualityINT10080–100
    previewBOOLEANtrue

    Outputs (0)

    No outputs