π€ Dataset Count
How Big Is This Dataset? π€ Dataset Count Tells You Without Building a Single Row
- dataset
- count
π€ Dataset Count is the smallest node in StableLlama's Hugging Face dataset pack: one input, one output, no widgets, no options. It takes a loaded dataset and hands you the number of rows as an INT. It shipped in pack version 1.1.0 on 2026-09-09, which makes it the newest node in the box, and if you've ever wired a 25,000-row IMDb split into a filter chain before checking what you were feeding it, you already know why it exists.
Why you'd reach for it
Most ComfyUI plumbing exists to fight repetition and illegibility - the two things that make a big graph unreadable. Counting rows is a third, quieter problem: you want to know the size of a thing before you commit to processing it. The obvious alternative is to pull the loader's rows output through Basic/Data List β length, but that only works after every row dict has been materialized, which for a big split is the expensive part.
Dataset Count answers the same question off the dataset socket, on the opaque HUGGINGFACE_DATASET value, for free.
The pack itself is niche and new - first release 2026-09-06 - with essentially no Reddit corpus, so don't expect tutorials. What you get instead is unusually good in-app documentation.
How it works
Under the hood it's one line. The node calls a guard, then len():
def count_rows(self, dataset):
_ensure_materialized(dataset)
return (len(dataset),)
That's the whole mechanism, and it matters that it's len() and not a loop. A materialized datasets.Dataset stores its row count in its metadata, so len() reads a number - it doesn't decode images, doesn't iterate, doesn't touch a row.
The guard is the interesting half. _ensure_materialized checks whether the object has a __len__ at all; if it doesn't, you're holding a datasets.IterableDataset and the node refuses rather than trying. That's deliberate, and it's the right call: a streaming dataset is single-pass, so counting it would consume every row and leave you with nothing to count. You'd pay the full download you enabled streaming to avoid, and get a broken dataset back.
So Dataset Count sits on the opposite side of the fence from the streaming-friendly transform nodes (Shuffle, Skip, Take, Filter, Map Column, Shard, and the column ops all work on both types). It joins Sort, Select, Flatten, Unique and Train/Test Split in the loaded-only club.
Inputs and outputs
| | Name | Type | What it does |
|---|---|---|---|
| In | dataset | HUGGINGFACE_DATASET | The fully-loaded dataset to count, from π€ Dataset Loader or another dataset node. |
| Out | count | INT | The number of rows. |
That's genuinely all of it. Wire the loader's dataset socket in - not rows, which is a Data List and a type error here - and the INT comes out the other side.
Where the INT goes is up to you: a comparison or branch node from the Basic data handling pack to bail out if a split came back suspiciously small, a division to work out what fraction you're keeping, a format node to stamp the size into a filename.
Installing
Via ComfyUI Manager, search "Hugging Face dataset" (that's the registry display name; the publisher is stablellama), install, restart. Or comfy node install from Desktop.
Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-huggingface_dataset.git
pip install -r ComfyUI-huggingface_dataset/requirements.txt
That requirements file contains exactly one line - datasets - and the pack imports it lazily, so ComfyUI starts fine without it and only complains with a clear "pip install datasets" message when you actually try to load something. If you're loading datasets whose images are stored as JPEG XL, you'll additionally want pip install pillow-jxl-plugin; it's optional, and the ComfyUI startup log tells you which way it landed.
Where people get burned
Streaming makes this node fail, by design. With streaming on, the error is explicit - it tells you the input is a datasets.IterableDataset and to disable streaming on the loader that created it. Turn the toggle off, or run a π€ Dataset To Data List / To LIST first and count that instead.
limit is not the dataset size. This trips people constantly. On the loader, limit caps how many rows get materialized into the rows Data List - it does not slice the dataset output, which still carries the whole split. Set limit=50 to preview IMDb, wire dataset into Count, and you'll get 25000, not 50. If you want the count of what you limited, put Basic/Data List β length on rows. If you want a small dataset object, put π€ Dataset Take in front of Count.
One last note on expectations: HUGGINGFACE_DATASET is opaque to the rest of ComfyUI. Nothing outside this pack can accept it, so Count is not a general-purpose counting node - it counts datasets, and it's very good at exactly that.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| dataset | HUGGINGFACE_DATASET | Fully-loaded dataset whose number of entries to count (from the π€ Dataset Loader or another dataset node). |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| count | INT | The number of rows (entries) in the dataset. |