PD: Tensor Dataset Prepare
Dataset prep that copies, renames and filters your training folder — despite the scary name
- message
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 afindword. 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
.txtcaptions, 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 areR→staron.jpg,T→endon.jpg,T→(delete) on.txt, which match the pack's_R/_Tfilename convention. Each rule only fires on files whose extension matches itsextselector (Allmatches 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.
Inputs (12)
| Name | Type | Default | Description |
|---|---|---|---|
| input_path | STRING | — | |
| output_path | STRING | — | |
| operation_mode | COMBO | Copy All (Dataset Safe) | 2 options: Copy All (Dataset Safe), Strict Filter (Rules Only) |
| find_1 | STRING | R | — |
| replace_1 | STRING | star | — |
| ext_1 | COMBO | .jpg | 4 options: All, .jpg, .png, .txt |
| find_2 | STRING | T | — |
| replace_2 | STRING | end | — |
| ext_2 | COMBO | .jpg | 4 options: All, .jpg, .png, .txt |
| find_3 | STRING | T | — |
| replace_3 | STRING | — | |
| ext_3 | COMBO | .txt | 4 options: All, .jpg, .png, .txt |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| message | STRING | — |