Nodes/ComfyUI-Pt-Wrapper/Ptv Hf Local Dataset
ComfyUI Node

Ptv Hf Local Dataset

Feed your own JSONL or CSV into a text classifier

By HowToSD·Created about a year ago·Updated about a year ago· 7
Ptv Hf Local Dataset
  • encode
  • PTVDATASET
file_path
file_formatjson
sample_field_nametext
label_field_namelabel
remove_html_tagsfalse
encode_return_dictfalse

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, so foo/bar_train.jsonl means <pack>/datasets/foo/bar_train.jsonl. Absolute paths work too.
  • file_format - default json, which also covers JSONL. csv and parquet work as well.
  • sample_field_name / label_field_name - defaults text / label; point them at whatever your file's columns are actually called.
  • encode - the PTCALLABLE from Hf Tokenizer Encode or Sp 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 own input/.
  • Wrong field names - set sample_field_name/label_field_name to your actual columns or you'll hit a KeyError per row. Your JSONL has text and label fields already? Then the defaults just work.
  • File format mismatch - naming a JSONL file data.csv while file_format says json invites a confusing parse error. Keep the format field honest.
  • encode_return_dict wrong - flip it and you'll see KeyError: '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.

CategoryTraining

Inputs (7)

NameTypeDefaultDescription
file_pathSTRING
file_formatSTRINGjson
sample_field_nameSTRINGtext
label_field_nameSTRINGlabel
encodePTCALLABLE
remove_html_tagsBOOLEANfalse
encode_return_dictBOOLEANfalse

Outputs (1)

NameTypeDescription
PTVDATASETPTVDATASET