Skip to content

Guide · Open source

How to use Fashion-MNIST: download, load and benchmark

Updated · written with AI from the project's own documentation and checked against our catalogue data

Fashion-MNIST is an open dataset of 28x28 grayscale images of Zalando clothing and accessories, split into 60,000 training and 10,000 test examples across 10 labeled classes. This guide shows you how to get the data, load it into Python, and find the libraries that already include it. It is written for students, researchers and developers who want a benchmark that is slightly harder than the classic handwritten-digit MNIST.

Fashion-MNISTzalandoresearch/fashion-mnist · ★ 12.9k · MIT

Quick start

  1. 1Clone the repository. Run git clone on the zalandoresearch/fashion-mnist repository. The dataset will be in data/fashion.
  2. 2Install NumPy. The included Python loader needs NumPy. Install it in the Python 3 environment you plan to use.
  3. 3Load the training and test splits. Call mnist_reader.load_mnist with 'data/fashion' and kind set to 'train' or 't10k'.
  4. 4Check the labels. Map the integers 0 to 9 to the clothing names so your results are readable.
  5. 5Train and compare models. Train a classifier on the training split and evaluate it on the test split, or use the scikit-learn benchmark in the repo.

What is Fashion-MNIST and why was it made?

Fashion-MNIST is a dataset of Zalando's article images. Each example is a 28x28 grayscale image with one label from 10 classes. The authors intend it as a direct drop-in replacement for the original MNIST dataset, so it shares the same image size and the same structure of training and testing splits.

The README argues that MNIST is too easy, since convolutional nets can reach 99.7% on it and classic algorithms can also score high. Fashion-MNIST is meant to give machine learning algorithms a harder problem with the same format.

Get the Fashion-MNIST data: download files or clone the repo

You can download four gzipped files directly: training images and labels, and test images and labels. The data uses the same format as the original MNIST data. The README lists an MD5 checksum for each file, so you can check your download.

Alternatively, clone the GitHub repository. The dataset appears under data/fashion, and the repo also contains scripts for benchmark and visualization.

  • train-images-idx3-ubyte.gz: 60,000 training images, about 26 MBytes
  • train-labels-idx1-ubyte.gz: 60,000 training labels, about 29 KBytes
  • t10k-images-idx3-ubyte.gz: 10,000 test images, about 4.3 MBytes
  • t10k-labels-idx1-ubyte.gz: 10,000 test labels, about 5.1 KBytes
git clone git@github.com:zalandoresearch/fashion-mnist.git

Load Fashion-MNIST in Python with the included loader

The repository includes a loader in utils/mnist_reader. It requires NumPy. Point it at data/fashion and choose the split with kind: use 'train' for training data and 't10k' for test data.

If you use TensorFlow, the README warns that if the data is not in data/fashion, TensorFlow will download and use the original MNIST instead. Place the downloaded data in data/fashion first.

  • Requires Python with NumPy
  • Training split: kind='train'
  • Test split: kind='t10k'
import mnist_reader X_train, y_train = mnist_reader.load_mnist('data/fashion', kind='train') X_test, y_test = mnist_reader.load_mnist('data/fashion', kind='t10k')

Know the 10 clothing labels

Each training and test example has one of these labels. The numbers are the values stored in the label files, so map them to names when you display results or report errors.

  • 0: T-shirt/top
  • 1: Trouser
  • 2: Pullover
  • 3: Dress
  • 4: Coat
  • 5: Sandal
  • 6: Shirt
  • 7: Sneaker
  • 8: Bag
  • 9: Ankle boot

Use libraries that already include the dataset

Many machine learning libraries ship Fashion-MNIST as a built-in dataset, so you may not need to download it yourself. You follow each library's own API. Examples listed in the README include Keras, PyTorch, TensorFlow Datasets, Kaggle, Hugging Face Datasets and Apache MXNet Gluon.

The README also notes that some community loaders for other languages exist, but the authors have not tested all of them with Fashion-MNIST, and some may require decompressing the files first.

  • Keras: keras.io/api/datasets/fashion_mnist
  • PyTorch: pytorch.org/vision/stable/datasets.html#fashion-mnist
  • Hugging Face Datasets: huggingface.co/datasets/fashion_mnist
  • Kaggle: kaggle.com/zalando-research/fashionmnist

Run the built-in benchmark

The README says the repo includes an automatic benchmarking system based on scikit-learn. It covers 129 classifiers with different parameters. It does not include deep learning, so use it to compare classical methods only.

If you want neural network results, the README points to an official TensorFlow tutorial that trains a tf.keras classifier on Fashion-MNIST.

What people use it for

  • Students comparing classic classifiers on a format they already know from MNIST
  • Researchers who want a slightly harder benchmark than MNIST for image classification
  • Developers prototyping image classification code before moving to larger data
  • Loading the dataset through a library's built-in API without downloading files manually

Frequently asked questions

Is Fashion-MNIST free to use?

The repository is licensed under the MIT License, as shown by the license badge in the README. Check the LICENSE file in the repo for the full terms.

What do I need to install to use Fashion-MNIST?

To use the included loader, you need Python 3 with NumPy. You also need the data, which you can download directly or get by cloning the repository.

Where do I put the data so the loader can find it?

Put the files in data/fashion. The README says the cloned repo already places the dataset there, and the loader is called with 'data/fashion' as its path.

Why does TensorFlow download the original MNIST instead of Fashion-MNIST?

The README says that if you have not placed the downloaded data in data/fashion, TensorFlow's input_data helper will download and use the original MNIST. Make sure the Fashion-MNIST files are in that folder first.

How is Fashion-MNIST different from MNIST?

It has the same image size, file format and train/test structure as MNIST, but the images show clothing instead of handwritten digits. The README argues it is a harder problem, because MNIST is too easy for modern convolutional nets.

What are good alternatives to Fashion-MNIST?

The source names MNIST, Kuzushiji-MNIST, CIFAR-10 and EMNIST as comparable projects. Pick one based on the kind of images you need to classify.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

Fashion-MNIST is a good fit if you want a familiar MNIST-style format with a harder clothing classification task, or a dataset that many libraries already bundle. Skip it if you need real-world photos, high-resolution images or deep learning benchmark results, since the images are small 28x28 grayscale product shots and the built-in benchmark covers classical classifiers only.

Install options & downloads