Dataset Stats
Is your dataset actually balanced? Dataset Stats will tell you
- dataloader
- stats_text
- stats_image
Class imbalance quietly ruins classifiers. If 90% of your data is class 0, a model that predicts "always 0" scores 90% accuracy while learning nothing - and no accuracy number will tell you. CdlDataLoaderStats is the check before that happens: it runs through your entire cdlDataloader, counts how many samples fall into each class, and hands you both a text summary and a bar chart of the distribution. If you're about to train a classifier on a ComfyDL dataset, running this once is cheap insurance.
It's the third of the Datasets inspection trio - DataLoader Info gives you batch arithmetic, DataLoader Preview shows you samples, and this one tells you whether your labels are fair.
How it works
The node iterates the whole loader, flattening every label tensor it finds. Then it makes a smart decision about what kind of data it's looking at: if the labels are integer values that fall inside [0, num_classes), it treats them as class indices and counts occurrences per class. If instead they're continuous values or out-of-range integers, it switches strategy and buckets them into a histogram over num_classes bins - so the same node handles classification and regression targets. The class_names input, when provided (comma-separated), labels the categories; otherwise it falls back to generic names or numeric ranges.
Two outputs come back: stats_text, a formatted STRING with total samples and a per-class count with percentage, and stats_image, the rendered bar chart as a standard IMAGE. The text is great for copying into notes; the image is great for wiring into a preview.
Inputs and outputs that matter
dataloader- anycdlDataloaderwith labels (Fashion-MNIST and Bananas both qualify, though note the detection labels have a box structure that mostly gets skipped).num_classes(default 10) - how many classes (or histogram bins) to expect. Fashion-MNIST is 10; set it to your actual count.class_names(optional STRING) - comma-separated names, e.g.t-shirt,trouser,pullover,dress,coat. They appear on the chart and in the text output.
Outputs stats_text (STRING) and stats_image (IMAGE).
Installing ComfyDL
cd ComfyUI/custom_nodes
git clone https://github.com/Cynthia-lxx/ComfyDL ./ComfyDL
pip install -r ./ComfyDL/requirements.txt
Restart ComfyUI. ComfyDL's requirements are minimal (matplotlib, IPython, matplotlib-inline - matplotlib draws the chart) and there are no downloads for the node itself. ComfyUI Manager may not list this young pack; clone if so.
Gotchas
This node actually consumes the whole dataset - it's a full pass, not a peek at batch zero. On the 60,000-image Fashion-MNIST train split that's fine; on something enormous it's a real scan, so don't leave one wired into a graph you run constantly. Also, label structure matters: it expects plain scalar labels, so object-detection batches with box tensors get skipped by the counting logic (the total will read near zero) - for the banana dataset, use DataLoader Preview to see boxes instead, not this. And remember class_names wants commas; ComfyDL's Fashion-MNIST node outputs newline-separated names, so convert them if you pipe one into the other.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| dataloader | cdlDataloader | — | |
| num_classes | INT | 101–1000 | — |
| class_namesopt | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| stats_text | STRING | — |
| stats_image | IMAGE | — |