NNT TorchVision Data Loader
MNIST and friends, downloaded and normalized for training
- images
- labels
- dataset_info
- num_classes
Every neural-network tutorial starts the same way: load MNIST. NNT TorchVision Data Loader is that first step, built into the pack - it downloads a torchvision dataset, applies transforms, and hands back images and labels tensors plus a num_classes integer. This is the node behind the pack's MNIST and CIFAR10 example workflows, and it's the reason you can go from "fresh install" to "training a digit classifier" in about ten minutes.
It supports ten datasets: MNIST, FashionMNIST, CIFAR10, CIFAR100, EMNIST, SVHN, STL10, ImageNet, LSUN, and CelebA. Which brings us to the first honest caveat - not all of them auto-download.
How it works
Choose dataset_name and split (train/test), and the node loads the torchvision dataset class. Leave data_dir empty and it uses ComfyUI/models/torchvision_datasets/ (registered as a proper ComfyUI folder, so it appears in the file browser); the first load with download=True fetches the data. Then it applies:
normalize_data- Normalize to [-1, 1] via(0.5,)mean/std.enable_augmentation- RandomHorizontalFlip plus a 10° RandomRotation. Off by default here, which is the right call for a first experiment.
start_index and samples_to_return (default 32, max 50000) slice out a manageable chunk - you don't have to train on all 60,000 MNIST digits, and you probably shouldn't on your first run. use_cache keeps a cached copy around so re-runs are fast.
Outputs: images (a TENSOR), labels (a TENSOR), dataset_info (a string), and num_classes (an INT you can wire into downstream nodes).
Where people get burned
The big one is the dataset menu. MNIST, FashionMNIST, CIFAR10, CIFAR100, EMNIST, SVHN, and STL10 auto-download fine. ImageNet and LSUN do not - they require manual downloads (ImageNet needs an account and license agreement, LSUN has had its own hosting drama), and CelebA's URLs have been flaky for years. If you pick one of those and nothing happens, it's not your graph - it's the dataset refusing to self-serve. Stick to the auto-downloadable seven for learning.
Second, the normalization is MNIST-style (0.5,) even for RGB datasets like CIFAR10. It works, but it's not the mean/std normalization you'd use in production, so results are a bit rougher than the classic numbers you see in papers. This is an educational toolkit; the numbers are close enough to learn from.
Third, a warning you'll hit with any ComfyUI training node: this outputs raw TENSOR data, not ComfyUI images. To actually look at a digit, run images through NntTensorElementToImage with convert_mode=L. Same lesson as everywhere else in this pack - tensors are for models, images are for eyes.
Install
Pack-level install:
cd ComfyUI/custom_nodes
git clone https://github.com/inventorado/ComfyUI_NNT.git
cd ComfyUI_NNT
pip install -r requirements.txt
Restart ComfyUI (or Manager → "ComfyUI Neural Network Toolkit NNT"). Requires torchvision (in the requirements). First data download needs internet and takes a bit for CIFAR10/EMNIST. And there's a sibling node, NntTorchvisionDatasets, that does a smaller version of this with a different default path - more on that in its own article. For training runs, this is the one you want.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| dataset_name | COMBO | MNIST | 10 options: CIFAR10, CIFAR100, MNIST, FashionMNIST, EMNIST, SVHN, +4 |
| split | COMBO | train | 2 options: train, test |
| data_dir | STRING | — | |
| download | COMBO | True | 2 options: True, False |
| normalize_data | COMBO | True | 2 options: True, False |
| enable_augmentation | COMBO | False | 2 options: True, False |
| samples_to_return | INT | 321–50000 | — |
| start_index | INT | 00–50000 | — |
| use_cache | COMBO | True | 2 options: True, False |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| images | TENSOR | — |
| labels | TENSOR | — |
| dataset_info | STRING | — |
| num_classes | INT | — |