DataLoader Info
Num_batches, batch_size, dataset_size
- dataloader
- num_batches
- batch_size
- dataset_size
Every DataLoader in ComfyDL carries three numbers you'll want to know before you train: how many batches it serves per epoch, how big each batch is, and how many total samples it holds. CdlDataLoaderInfo reads those off any cdlDataloader and hands them back as plain integers you can wire anywhere. It's a tiny inspection node - but if you've ever wired up training utilities and wondered "is this thing even seeing all 60,000 samples?", this is the answer in three numbers.
It belongs to the inspection trio in ComfyDL's Datasets category, alongside DataLoader Preview (which shows you the actual images) and Dataset Stats (which breaks down the labels). Where those two give you pictures, this one gives you arithmetic - and it's the most useful of the three as a wiring tool, because those INT outputs can drive anything downstream.
How it works
The mechanism is deliberately simple. num_batches is just len(dataloader), which PyTorch computes without iterating the data. batch_size comes from peeking at the first batch and reading the leading dimension of its first tensor. dataset_size is then computed as batch_size × num_batches.
That last step is worth understanding, because it means dataset_size is an estimate, not a precise count. Standard math: a dataset of 60,000 samples at batch size 64 gives 937 full batches plus one partial 32-sample batch - PyTorch reports len() as 938, and multiplying 64 × 938 yields 60,032, not 60,000. Fine for ballparking your epochs; not fine for a census.
Inputs and outputs that matter
dataloader- anycdlDataloader: the output ofFashion-MNIST,Bananas Detection,Load Array, and so on.
Three outputs, all plain INT:
num_batches- batches per epoch.batch_size- samples per batch (from the first batch's leading dimension).dataset_size-batch_size × num_batches, the estimate above.
All three are ordinary integers, which makes them genuinely useful plumbing: wire num_batches into a loop or display node, or feed batch_size onward so a downstream node can stay in sync with whatever the loader actually uses.
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) and there are no downloads - this node only reads what you connect. If ComfyUI Manager can't find "ComfyDL", clone it; the pack is young.
Gotchas
Two honest caveats. First, dataset_size is that multiply-out estimate, so don't use it where an exact sample count matters - it's off by up to a batch. Second, the node pulls a batch to learn batch_size, which forces a tiny real iteration; on an enormous dataset that first-batch fetch can be slower than you'd expect from a node that "just reads metadata." Neither is a reason to avoid it - just know what the numbers mean before you wire them into something that assumes exactness.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| dataloader | cdlDataloader | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| num_batches | INT | — |
| batch_size | INT | — |
| dataset_size | INT | — |