Nodes/ComfyUI Neural Network Toolkit NNT /NNT HuggingFace Data Loader
ComfyUI Node

NNT HuggingFace Data Loader

Grab MNIST (or any dataset) by ID

By inventorado·Created 2 years ago·Updated 2 years ago· 69
NNT HuggingFace Data Loader
    • dataset
    • info
    • metadata
    repo_idmnist
    splittrain
    use_auth_tokenFalse
    token
    cache_dir
    num_samples1000
    start_idx0
    shuffleTrue
    seed42

    The fastest way to get a classic dataset into an NNT workflow is NNT HuggingFace Data Loader. Type a dataset ID, pick a split, and it pulls it down from the Hugging Face Hub with the datasets library - no API key, no CSV wrangling, no download_click_here drama. mnist is the default repo_id precisely because that's the dataset the pack's own examples train on.

    What it actually does

    It calls datasets.load_dataset(repo_id, split=split) under the hood, then applies your selection window. start_idx and num_samples slice out a contiguous chunk (start at 0, take 1000 samples, for example); shuffle with a seed randomizes before the slice if you want a random subset instead. Outputs are dataset (the Hugging Face Dataset object), info (a STRING summary of what was loaded - split, sample count, columns, cache location), and metadata (a DICT with features, column names, and total size). From there, the pack's NntDatasetToImageTensor / NntDatasetToTensor family nodes convert it into trainable tensors.

    Inputs that matter

    • repo_id - any public dataset on the Hub, e.g. mnist, cifar10, fashion_mnist, imdb. Names are case-sensitive and some classic names live under namespaces, so if a bare ID fails, check the Hub page for the exact path.
    • split - train, test, or validation. mnist has train/test but no validation, so don't pick validation for it.
    • num_samples / start_idx - the selection window; cap it small while experimenting so downloads stay snappy.
    • use_auth_token + token - only needed for gated/private datasets. For public data leave it False and empty.
    • cache_dir - leave empty for the default Hugging Face cache; set it if you want datasets stored somewhere specific.

    Gotchas

    First, some datasets are gated and will reject an anonymous download - that's what the token fields are for (generate an access token in your HF account). Second, dataset IDs occasionally need the namespace: mnist works, but other classics like fashion_mnist may resolve under fashion_mnist or a namespaced path depending on how they're hosted; when in doubt, check the Hub. And remember num_samples is a cap, not a guarantee - if the split is shorter, you get whatever's there. The node also returns errors as a None dataset plus the message in info, so when a downstream node complains about a missing dataset, read info first.

    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. This node specifically needs the datasets library (and huggingface-hub), both in the requirements - the full list is a heavy scientific stack (torch, scikit-learn, pandas, transformers, shap), so the first install takes a while. The pack's MNIST workflow in workflows/ is the canonical demo, and it also wants ComfyUI-Jjk-Nodes for text output.

    CategoryNNT Neural Network Toolkit/Data Loading

    Inputs (9)

    NameTypeDefaultDescription
    repo_idSTRINGmnist
    splitCOMBOtrain3 options: train, test, validation
    use_auth_tokenCOMBOFalse2 options: True, False
    tokenSTRING
    cache_dirSTRING
    num_samplesINT10001–100000
    start_idxINT00–100000
    shuffleCOMBOTrue2 options: True, False
    seedINT420–99999999

    Outputs (3)

    NameTypeDescription
    datasetDATASET
    infoSTRING
    metadataDICT