Nodes/ComfyDL/Dataset → Preview
ComfyUI Node

Dataset → Preview

Five rows of text that save you an hour of shape hunting

By Cynthia-lxx·Created 3 months ago·Updated 12 days ago· 7
Dataset → Preview
  • dataset
  • preview
◄head5►

What it is

The least glamorous node in ComfyDL and the one you'll drop first. Cynthia-lxx's pack is a d2l-derived deep-learning toolkit for ComfyUI - readers, adapters, trainers, writers, all passing a universal DATASET object around by reference. Dataset → Preview takes that object and renders its first few rows as plain text.

That's the whole feature, and it matters because a DATASET is an opaque blob on a wire. It has a feature tensor, an optional label tensor, column names and metadata inside, and a mis-parsed file, a missing target column or a shifted header is invisible until a trainer fails with a shape error several nodes downstream. This node is the cheap look inside: does the header line match my file, is the label column actually there, did pandas read one column or five?

How it works

It materialises the dataset with to_dataframe() - which rebuilds a pandas DataFrame from the stored features and labels, using feature_names as the feature columns and the dataset's target name (or label) for the label column - and returns df.head(head).to_string(). A STRING out. No file, no image, no side effects.

One thing worth understanding about head: it limits the printed rows, not the work. The full DataFrame is built first and then sliced, so previewing a 5-row head of a million-row dataset still materialises a million-row frame plus a copy. Keep it on a small subset while you're iterating.

Inputs and outputs

Required: dataset (a forced input socket, so it must be wired). Optional: head, an INT from 1 to 1,000, default 5.

Output: preview, a STRING.

Wiring that string is the only mildly fiddly part, because ComfyUI shows nothing for a bare text output until you attach something that displays text. Options: any of the core text/display nodes, an output node that renders strings, or the pack's own MessageBox node in the utilities category - which is worth one warning, since it's a ctypes call to the native Windows MessageBoxW and simply returns [MessageBox unavailable: not running on Windows] if you're on Linux or macOS. On Windows, set its block toggle off unless you want the workflow to sit there until somebody clicks OK.

Also useful: park a preview node next to each reader while you build. Two side by side - before and after a Tensors → Dataset bundle - show you exactly where column names get lost.

Install

Manager → search ComfyDL, or:

cd ComfyUI/custom_nodes
git clone https://github.com/Cynthia-lxx/ComfyDL
pip install -r ./ComfyDL/requirements.txt

Restart ComfyUI. Requirements are only matplotlib, IPython and matplotlib-inline - pandas, which this node needs for to_dataframe(), comes from your environment and is already present if other packs use it. If it's missing, pip install pandas. And if this node (or any other ComfyDL node) never appears in the menu, read the console: the pack imports each node module in a try/except and prints [ComfyDL] Warning: Failed to load <module> instead of raising, so an import error looks exactly like a node that doesn't exist.

What to look for in the output

The text is a pandas DataFrame.to_string() dump - column names across the top, an index column, aligned to the widest value. Check three things and you'll have caught nearly every reader mistake:

  • Are the column names the ones you expected? If you see 0, 1, 2 instead of real names, your header wasn't parsed - wrong header flag, or a title row in a spreadsheet.
  • Is the label column present? When target matched, it appears as a real column. When it didn't match you wouldn't have got this far, but an empty target gives you a dataset with no label column at all, which is exactly how you spot the mistake before the trainer does.
  • Are the values sane? One client's "1.234,56" European formatting read as text, a spreadsheet's dates, a column of NaNs, a delimited file that collapsed to a single column - all obvious in five rows of text, all invisible in a shape error.

Where people get burned

Expecting images. This previews numbers. For image datasets in the pack, use the image-side preview nodes instead.

head on a huge dataset. As above: the copy happens regardless.

Nothing appears. The node ran - you just haven't wired preview to anything that displays strings. The graph executes fine and shows you silence.

Datasets built from tensors lose their names. Tensors → Dataset synthesises x0, x1, … and an unnamed label, so the preview looks generic. That's accurate, not a bug - go back to the reader if you want real headers.

Categoryd2l/Datasets

Inputs (2)

NameTypeDefaultDescription
datasetDATASET—
headoptINT51–1000—

Outputs (1)

NameTypeDescription
previewSTRING—