Tensors → Dataset
The two-socket node that lets any tensor in the graph become data
- X
- y
- dataset
What it is
ComfyDL is Cynthia-lxx's pack for running deep-learning recipes as ComfyUI graphs - d2l textbook material (linear regression, SGD, CNNs, attention) as nodes. Its centre of gravity is a universal DATASET type: a bundle of a feature tensor, an optional label tensor, column names and metadata, passed by reference between nodes so a big table costs nothing to route.
Tensors → Dataset is the smallest node in that family and one of the most useful. It takes a TENSOR of features, an optional TENSOR of labels, and bundles them into a DATASET.
Why care? Because a dozen things in the graph produce tensors - the pack's own converters, a normalization or activation from the core node library (ComfyDL deliberately reuses ComfyUI's canonical TENSOR type name, so its sockets interoperate), anything downstream of a Dataset → Tensors split you reshaped. The writers, the adapters and the trainers all want a DATASET. This is the adapter that bridges them, and without it you'd be stuck writing files just to move data between nodes.
How it works
It calls CdlDataset.from_tensors(X, y). A few details worth knowing, because they're the reason it's forgiving:
Xdoesn't have to be a tensor yet. Anything array-like is coerced withtorch.as_tensor.- A 1-D
Xis treated as a single feature column - it gets unsqueezed to(n, 1). That's handy when you're feeding one variable, and the source of a genuine surprise later: your "n samples" became "n samples, 1 feature". - If
yisn't wired, you get a dataset withlabels = None. That's a legal object - writers and previews work, trainers don't. - Feature names aren't exposed as inputs, so they're auto-generated:
x0,x1,x2, … and the label column is unnamed.
Inputs and outputs
Required: X (TENSOR, features, [n, f]). Optional: y (TENSOR, labels, [n] or [n, 1]).
Output: a single dataset.
Because the labels socket is optional and unconnected optional inputs simply arrive as nothing in ComfyUI, you can wire X from an image or a feature tensor and leave y alone when you only need to hand data to a writer. Wire both when you intend to train.
Install
Manager → search ComfyDL, or:
cd ComfyUI/custom_nodes
git clone https://github.com/Cynthia-lxx/ComfyDL
pip install -r ./ComfyDL/requirements.txt
Restart, and look for [ComfyDL] Loaded <n> deep learning nodes. in the console. The pack's requirements file lists only matplotlib, IPython and matplotlib-inline - pandas and torch come from your ComfyUI install (torch obviously; pandas usually arrives with other packs). One quirk to file away: the pack imports each node module inside a try/except and prints [ComfyDL] Warning: Failed to load <module>, so a missing dependency presents as a node that isn't in the menu.
When to reach for it, and when not to
Use it when the producer is a node and the consumer wants a dataset - a tensor you just computed, normalized, or pulled out of an image. If your data already lives in a file, skip this node entirely: the readers build a DATASET in one step, with proper column names, and you'll write CSV headers that mean something.
The one thing it can't do is name your columns. Feature names are synthesised and the label is unnamed, so a dataset built this way writes out with x0, x1, … headers and a label column. If those headers matter, read from a file instead - or expect to rename afterward.
Where people get burned
Row counts must agree. X and y are bundled as-is, and a mismatch between n samples in each isn't caught here - it surfaces later as a shape error inside the trainer, which is a worse place to debug it. Check the shapes with the pack's tensor info nodes before wiring them together.
1-D X becomes one feature. If you expected three features, you either passed a flattened tensor or need to reshape before this node.
Labels are kept as-is. A y of (n,) or (n, 1) both work downstream, since the trainer reshapes it - but a y with extra dimensions won't silently fix itself.
It's a reference, not a copy. The dataset points at your tensors, so anything downstream sees the same storage. That's the design (it's why routing a big table is free), and it also means in-place tensor edits anywhere in the graph are visible here.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| X | TENSOR | — | |
| yopt | TENSOR | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| dataset | DATASET | — |