ComfyUI Node

NNT File Data Loader

Get your data into the graph without an API key

By inventorado·Created 2 years ago·Updated 2 years ago· 69
NNT File Data Loader
    • data
    • paired_data
    • info_message
    • batch_size
    data_sourcenumpy
    data_dir/tmp/ComfyUI/models/nnt_datasets
    file_pattern*.npy
    data_typefloat32
    normalizeTrue
    normalize_range0-1
    batch_firstTrue
    shuffleFalse
    image_channels3
    image_size224
    image_interpolationbilinear
    use_cacheTrue
    paired_data_dir
    paired_file_pattern

    Every model needs data, and in the Neural Network Toolkit the "my data lives on disk" path runs through NNT File Data Loader. It's the node that turns plain files - numpy arrays, txt tables, pickles, or folders of images - into TENSORs your compiled model can actually train on. If NntHuggingFaceDataLoader is the "download the benchmark" route, this one is the "I have my own data, thanks" route.

    What it actually does

    You tell it what kind of source you have via data_source, point it at a directory with data_dir and a file_pattern, and it loads everything matching, converts to the data_type you picked (float32, int64, uint8, bool, ...), and applies normalization if you want it. The source options: txt, numpy (.npy files), python_pickle, image_folder, image_text_pairs, and text_text_pairs. The paired modes are the interesting ones - for image_text_pairs you give a second directory with paired_data_dir/paired_file_pattern, and you get both halves of the dataset aligned, which is exactly what you need for a classification or captioning toy model.

    Normalization is handled in-node: normalize_range of 0-1 or -1-1 rescales, and standardize computes mean/std (z-scoring). For images there are image_size (resize to, 224 default), image_channels, and image_interpolation (nearest/bilinear/bicubic). Outputs are data, an optional paired_data, an info_message, and batch_size (the number of samples loaded).

    Inputs that matter

    • data_source - what kind of files you have. Everything else on the node is scoped by this.
    • data_dir - default is the pack's ComfyUI/models/nnt_datasets/ folder (register your files there, or type an absolute path).
    • file_pattern - glob pattern, e.g. *.npy for numpy.
    • normalize + normalize_range - if your model isn't training, a mismatch between your data range and what the network expects is a classic culprit. Standardize is the safe default for most toy models.
    • use_cache - keeps an in-memory cache keyed by your settings; if you're iterating on a workflow, leave it on so reloading a huge dataset is instant. Toggle off if you change files and want fresh data.

    Gotchas

    The image_text_pairs and text_text_pairs modes require both paired_data_dir and paired_file_pattern to be filled in, or the node raises a clear error - that's the honest version of "you forgot the other half." Also, with shuffle on, the node builds a PyTorch DataLoader under the hood; with it off you get a plain tensor. If you're comparing runs, mind the cache: it hashes your parameters, so the same settings give you the same cached tensor even after you swap files. Turn use_cache off when you replace data mid-experiment.

    Installing NNT

    Part of inventorado/ComfyUI_NNT. ComfyUI Manager (search "ComfyUI Neural Network Toolkit") or:

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

    Restart ComfyUI after. The requirements are a heavy scientific stack - torch, numpy, scikit-learn, pandas, Pillow, transformers - so the first install takes a while. The pack's MNIST/CIFAR workflows show the intended data → train → evaluate loop; they also want ComfyUI-Jjk-Nodes for text display, which Manager's "Install Missing Custom Nodes" fetches.

    CategoryNNT Neural Network Toolkit/Data Loading

    Inputs (14)

    NameTypeDefaultDescription
    data_sourceCOMBOnumpy6 options: txt, numpy, python_pickle, image_folder, image_text_pairs, text_text_pairs
    data_dirSTRING/tmp/ComfyUI/models/nnt_datasets
    file_patternSTRING*.npy
    data_typeCOMBOfloat327 options: float32, float64, int32, int64, uint8, bool, +1
    normalizeCOMBOTrue2 options: True, False
    normalize_rangeCOMBO0-13 options: 0-1, -1-1, standardize
    batch_firstCOMBOTrue2 options: True, False
    shuffleCOMBOFalse2 options: True, False
    image_channelsINT31–4
    image_sizeINT22416–2048
    image_interpolationCOMBObilinear3 options: nearest, bilinear, bicubic
    use_cacheCOMBOTrue2 options: True, False
    paired_data_diroptSTRING
    paired_file_patternoptSTRING

    Outputs (4)

    NameTypeDescription
    dataTENSOR
    paired_dataTENSOR
    info_messageSTRING
    batch_sizeINT