Nodes/ComfyUI-Pt-Wrapper/Ptv Dataset Len
ComfyUI Node

Ptv Dataset Len

A sanity check for your training data

By HowToSD·Created about a year ago·Updated about a year ago· 7
Ptv Dataset Len
  • dataset
  • INT

Ptv Dataset Len is the most honest node in the pack: it takes a dataset and returns how many samples are in it. One input (dataset, a PTVDATASET), one output (INT). It wraps Python's len() - literally, len(dataset) - and that's the entire job.

So why does a trivial wrapper exist at all? Because when you're assembling a training pipeline out of nodes, you need a way to see what you're about to train on. The pack's PtvDataset node downloads and configures a torchvision dataset, and before you wire it into a data loader and kick off a training run, you want to confirm it actually loaded what you think it did. Did the download land? Did you pick the train split or accidentally get the test split? Is it 60,000 samples or 3? One glance at this node's INT output answers all of that.

It's also useful for the math side. Connect this INT into an arithmetic node and you can compute epochs-to-steps, batch counts, or a sensible train/val split ratio right in the graph, instead of doing it in your head or keeping notes elsewhere. Cheap, wired-in, and it keeps the workflow self-documenting.

The one honest caveat: it's a convenience, not a feature. If you're tight on nodes in your graph, you can skip it - the training nodes will happily chug through whatever dataset you give them, and the pack's print/debug nodes can show you the same information. But for a beginner standing up their first training workflow, this is a nice early win: get the dataset wired up, confirm the count, and then worry about training.

Install

ComfyUI Manager (search "ComfyUI-Pt-Wrapper"), or:

cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper

Restart ComfyUI. The pack's requirements are heavy (transformers, datasets, peft, accelerate, scikit-learn, pandas, seaborn, matplotlib, gensim, sentencepiece) so the first launch is slow. No model files to download.

Common issues

There isn't much to break here. If you get an unexpected number, check the dataset node's parameters - a {"train": False} in there flips you to the test split, which changes the count dramatically. And if the node errors instead of returning a count, the dataset itself probably failed to load or download - fix it upstream.

CategoryTraining

Inputs (1)

NameTypeDefaultDescription
datasetPTVDATASET

Outputs (1)

NameTypeDescription
INTINT