Ptv Hf Local Dataset
Feed your own JSONL or CSV into a text classifier
- encode
- PTVDATASET
The Hugging Face hub is great until your data isn't on it. This node is the pack's answer for that moment: it loads a text dataset from your own disk and hands back the same PTVDATASET the hub-based nodes produce. If you have a pile of reviews, tickets, or support messages in a JSONL file and you want to classify them in ComfyUI without touching Python, this is the entry point.
How it works
It's a wrapper around the datasets library's load_dataset(file_format, data_files=..., split="train"). Note that split="train" there is just the library's idiom for "load the whole file" - it doesn't mean your file must be a train split, and it doesn't split anything. Each row is then passed through the encode callable exactly like the hub-based sibling node: text becomes token IDs plus an attention mask, label becomes a long tensor.
The inputs that matter
- file_path - relative paths resolve under the pack's
datasets/folder, sofoo/bar_train.jsonlmeans<pack>/datasets/foo/bar_train.jsonl. Absolute paths work too. - file_format - default
json, which also covers JSONL.csvandparquetwork as well. - sample_field_name / label_field_name - defaults
text/label; point them at whatever your file's columns are actually called. - encode - the
PTCALLABLEfromHf Tokenizer EncodeorSp Encode. - remove_html_tags - strips HTML before tokenizing.
- encode_return_dict - set True when your encode is the HF tokenizer (returns a dict), False for the SentencePiece encode (returns a tuple). Same rule as the sibling node.
Wiring it in
Output is a PTVDATASET, so it drops straight into Pt Data Loader → trainer, identical to the hub path. The pack ships an example workflow (distilbert_classification_local_dataset.json) that loads an IMDB dataset in JSONL format this way and fine-tunes DistilBERT on it - drag it in and it's a working reference for the whole local-data chain.
Install
One install gets every node in the pack:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper
Restart ComfyUI, or search "ComfyUI-Pt-Wrapper" in ComfyUI Manager. Dependencies (datasets>=3.4.1, transformers>=4.47.1) come with the pack.
Common issues
- "Couldn't find file" - you gave a relative path that doesn't exist under the pack's
datasets/dir, or the file isn't where you think. Remember: relative means inside the pack folder, not inside ComfyUI's owninput/. - Wrong field names - set
sample_field_name/label_field_nameto your actual columns or you'll hit aKeyErrorper row. Your JSONL hastextandlabelfields already? Then the defaults just work. - File format mismatch - naming a JSONL file
data.csvwhilefile_formatsaysjsoninvites a confusing parse error. Keep the format field honest. encode_return_dictwrong - flip it and you'll seeKeyError: 'input_ids'(or an unpacking error) on the first sample.
It's a small node with one job, and it does it well. If you're wondering whether to put your data on the hub first - don't. Point this node at the file.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| file_path | STRING | — | |
| file_format | STRING | json | — |
| sample_field_name | STRING | text | — |
| label_field_name | STRING | label | — |
| encode | PTCALLABLE | — | |
| remove_html_tags | BOOLEAN | false | — |
| encode_return_dict | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| PTVDATASET | PTVDATASET | — |