ComfyUI Node

NNT Dataset To Tensor

NNT Dataset To Tensor — the plainest data conversion in the pack

By inventorado·Created 2 years ago·Updated 2 years ago· 69
NNT Dataset To Tensor
  • dataset
  • TENSOR
  • STRING
column_namelabel

This is the minimal member of the pack's dataset-conversion family, and it's the right one to reach for when your column is already numeric. NntDatasetToTensor takes a dataset and one column and does the obvious thing: torch.tensor(dataset[column]). No resizing, no tokenizing, no label maps - just a tensor.

The inputs

Two inputs, that's the whole node:

  • dataset - the DATASET from the pack's loader nodes.
  • column_name (default label) - the column to convert.

Outputs: TENSOR (the converted column) and STRING (an info message with the shape, dtype, and the first value - genuinely handy for a quick sanity check).

How it works

dataset[column_name] grabs the whole column, torch.tensor(...) wraps it, and the info string tells you what you got. There's no explicit shape-checking, no gradient control, no collation. The result carries whatever dtype the data implies (integers → int64, floats → float32). Gradients are enabled around the conversion, which matches the rest of the pack, but on a raw torch.tensor of a list there's nothing to take gradients of anyway.

When you'd actually use it

  • Your labels are already integers and you need a quick targets tensor.
  • A dataset column of floats you want as model input for a regression toy.
  • You want a fast look at what a column contains - the info string gives you shape, dtype, and first value in one glance.

When you shouldn't use it: for images (use NntDatasetToImageTensor - this node can't resize or normalize), for string labels that need mapping (use NntDatasetToTargetTensor), or for text that needs tokenization (use NntDatasetToTextTensor). This node is the "I just need the numbers" option, and it's honest about it.

Common issues

  • String column - torch.tensor on a list of strings throws. If your column is text, this isn't the node; the pack has the specialized ones for that.
  • Mixed types - ragged or mixed-type columns will make torch.tensor choke. Clean the dataset in the loader first.
  • No error-handling romance - like the rest of the pack, it returns an empty tensor plus an error string on failure rather than crashing your whole graph.

Install

Pack-level, nothing special:

cd ComfyUI/custom_nodes
git clone https://github.com/inventorado/ComfyUI_NNT.git
cd ComfyUI_NNT
pip install -r requirements.txt

or ComfyUI Manager → "ComfyUI Neural Network Toolkit NNT", restart, under NNT Neural Network Toolkit/Data Processing.

CategoryNNT Neural Network Toolkit/Data Processing

Inputs (2)

NameTypeDefaultDescription
datasetDATASET
column_nameSTRINGlabel

Outputs (2)

NameTypeDescription
TENSORTENSOR
STRINGSTRING