Nodes/Comfyui_PDuse/PD: Tensor Dataset Prepare
ComfyUI Node

PD: Tensor Dataset Prepare

Dataset prep that copies, renames and filters your training folder — despite the scary name

By 7BEII·Created 2 years ago·Updated 15 days ago· 53
PD: Tensor Dataset Prepare
    • message
    input_path
    output_path
    operation_modeCopy All (Dataset Safe)
    find_1R
    replace_1star
    ext_1.jpg
    find_2T
    replace_2end
    ext_2.jpg
    find_3T
    replace_3
    ext_3.txt

    The name is a lie - there's no tensor anywhere in it

    PD_TensorTraining, displayed as "PD: Tensor Dataset Prepare", sounds like it should be doing something deep with model weights. It isn't. Open the source and it's a file utility: it copies .jpg, .png and .txt files from an input folder to an output folder, optionally renaming them as it goes, and it can filter to only files you've defined rules for. The "tensor" is aspirational marketing for a folder copier.

    Don't let that put you off - the folder copier is useful. Dataset curation beats every training knob you can turn, as the KB's lora-training.md hammers home, and this is one of the few ComfyUI-native ways to prepare a training folder without leaving the graph. It's the natural companion to the pack's batch-workflow convention where every image has a matching .txt caption sidecar - the pair-of-files layout the KB's image-io-metadata.md describes as the standard training-set format.

    How it works

    You give it an input_path and an output_path, pick an operation_mode, and define up to three find/replace rules, each scoped to an extension. The node walks the top level of the input folder, and for every supported file:

    • In Copy All (Dataset Safe) mode it copies everything (shutil.copy2, so originals are untouched), applying the rename rules only where a file's name actually contains a find word. This is the safe default - nothing gets dropped.
    • In Strict Filter (Rules Only) mode, only files whose extension falls inside an active rule's scope get copied; everything else is skipped. Useful when you want only the .txt captions, or only the .jpgs, to move over.

    Output folder is created automatically, name collisions get a _1, _2 suffix, and the single output (message) is a report string with counts and the first 20 operations. There's no model, no VRAM, no risk to the source folder.

    The inputs that matter

    • input_path / output_path - source and destination. Absolute paths work.
    • operation_mode - the big decision. Start with Copy All until you're sure the strict mode won't surprise you.
    • find_1..3, replace_1..3, ext_1..3 - three independent rules. Defaults are Rstar on .jpg, Tend on .jpg, T→(delete) on .txt, which match the pack's _R/_T filename convention. Each rule only fires on files whose extension matches its ext selector (All matches everything).
    • Output: message - the human-readable report. Wire it to a Show Text node.

    Installing it

    It's part of Comfyui_PDuse:

    cd ComfyUI/custom_nodes
    git clone https://github.com/7BEII/Comfyui_PDuse.git
    cd Comfyui_PDuse
    pip install -r requirements.txt
    

    Or via ComfyUI Manager (search "Comfyui_PDuse") and restart.

    Where it trips you up

    Three things. First, only .jpg, .png and .txt are ever touched - .webp, .jpeg (the four-letter extension), .json all pass silently. Second, in Copy All mode the rules rename only; they never filter, so if you were expecting strict-mode behavior you'll get a full copy and wonder where the filtering went. Third, an empty replace deletes the keyword (T → `` turns 1_T.txt into 1_.txt), which is a feature when you want it and a surprise when you don't. It also only scans the top level of the folder - no recursion into subdirectories, which matters if your dataset is nested.

    CategoryPandyTool/File

    Inputs (12)

    NameTypeDefaultDescription
    input_pathSTRING
    output_pathSTRING
    operation_modeCOMBOCopy All (Dataset Safe)2 options: Copy All (Dataset Safe), Strict Filter (Rules Only)
    find_1STRINGR
    replace_1STRINGstar
    ext_1COMBO.jpg4 options: All, .jpg, .png, .txt
    find_2STRINGT
    replace_2STRINGend
    ext_2COMBO.jpg4 options: All, .jpg, .png, .txt
    find_3STRINGT
    replace_3STRING
    ext_3COMBO.txt4 options: All, .jpg, .png, .txt

    Outputs (1)

    NameTypeDescription
    messageSTRING