DataLoader Preview
DataLoader Preview
- dataloader
- image
You can wire a fresh dataset into a training loop and never actually look at it. That's a mistake - the fastest way to discover your images are mislabeled, your crops are wrong, or your normalization is inverted is to eyeball a grid of actual samples before you burn an hour training on garbage. CdlDataLoaderPreview renders a batch from any ComfyDL cdlDataloader as a matplotlib grid and hands it back as a standard ComfyUI IMAGE. It's the "trust, then verify" node of the Datasets category.
The reason it earns its keep over the (nearly identical) DataLoader Preview (Output) node is a matter of taste in your workflow: this version is a normal node that emits an IMAGE, so you can route that grid onward - into a save node, into other image-processing nodes, or into a PreviewImage of your choice - instead of having ComfyUI decide where it goes.
How it works
The node pulls one batch via next(iter(dataloader)) - just the first batch, no full scan - and inspects the data to figure out what it's looking at. If the batch is a (X, Y) pair it has labels to display; if not, it renders samples alone. Then it adapts to the tensor layout: 3-channel (C, H, W) images get permuted for display, values get normalized into [0, 1], single-channel and 2D tensors render in grayscale, and anything unrecognizable prints its shape in the cell instead of crashing. The preview grid is built with num_rows × num_cols cells, up to max_samples.
The image processing happens on CPU via matplotlib with an Agg backend - meaning it works headless, no display server needed - and the figure is rasterized back into a ComfyUI IMAGE tensor.
Inputs and outputs that matter
dataloader- anycdlDataloader(Fashion-MNIST, Bananas Detection, Load Array, …).num_rows(default 2),num_cols(default 4) - the grid dimensions.max_samples(optional, default 32) - caps how many samples get shown, in caserows × colsexceeds it.
One output: image, a standard IMAGE tensor you wire into PreviewImage, a save node, or ComfyDL's image utilities.
Installing ComfyDL
cd ComfyUI/custom_nodes
git clone https://github.com/Cynthia-lxx/ComfyDL ./ComfyDL
pip install -r ./ComfyDL/requirements.txt
Restart ComfyUI. Requirements are light (matplotlib, IPython, matplotlib-inline - matplotlib is what renders the grid) and nothing downloads for this node itself. If ComfyUI Manager doesn't list "ComfyDL", cloning is the reliable path.
Gotchas
It only looks at the first batch. If your dataset is ordered in a way that makes batch zero unrepresentative (shuffling off, classes grouped), the preview can lie to you about what the rest looks like. And because the grid is capped by max_samples, don't set rows × cols to 256 expecting 256 tiles if the default cap of 32 is still on - raise it. Finally, the output is just an IMAGE tensor: if you don't connect it to a preview/save node yourself, this variant shows nothing. If you'd rather the grid just appear in your UI automatically, grab DataLoader Preview (Output) instead.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| dataloader | cdlDataloader | — | |
| num_rows | INT | 21–16 | — |
| num_cols | INT | 41–16 | — |
| max_samplesopt | INT | 321–256 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |