MNIST-C
Overview
MNIST-C is a corrupted version of MNIST designed for benchmarking the out-of-distribution robustness of computer vision models. It applies 15 corruptions (noise, blur, affine transforms, digital and weather-like artifacts) to both the MNIST training and test sets, at a single fixed severity per corruption. Labels and image order are identical across corruptions, so every corrupted image can be paired with its clean original.
Each corruption is a separate builder config, selected with config_name. The identity config is the uncorrupted MNIST reference shipped in the same archive. Every config has the same splits:
Train: 60,000 images
Test: 10,000 images
All images are 28×28 grayscale. The default config is shot_noise.
Data Structure
When accessing an example using ds[i], you will receive a dictionary with the following keys:
Key |
Type |
Description |
|---|---|---|
|
|
28×28 grayscale corrupted digit image |
|
int |
Digit class label (0-9) |
Corruption Types
Configs grouped by corruption type:
Noise:
shot_noiseimpulse_noise
Blur:
glass_blurmotion_blur
Affine:
shearscalerotatetranslate
Digital:
brightnessstripedotted_linezigzagcanny_edges
Weather:
fogspatter
Reference:
identity(clean MNIST, no corruption)
Usage Example
Basic Usage
from stable_datasets.images.mnist_c import MNISTC
# Load one corruption (the archive is downloaded once and shared by all configs)
ds_test = MNISTC(config_name="fog", split="test")
sample = ds_test[0]
print(sample.keys()) # {"image", "label"}
# Optional: make it PyTorch-friendly
ds_torch = ds_test.with_format("torch")
Typical Workflow
from stable_datasets.images.mnist_c import MNISTC
# Train on clean MNIST
train_data = MNISTC(config_name="identity", split="train")
# ... train your model ...
# Evaluate robustness on each corruption
for config in MNISTC.BUILDER_CONFIGS:
test_data = MNISTC(config_name=config.name, split="test")
# ... evaluate on corrupted images ...
References
Paper: MNIST-C: A Robustness Benchmark for Computer Vision (https://arxiv.org/abs/1906.02337)
License: CC BY 4.0
Citation
@article{mu2019mnist,
title={MNIST-C: A Robustness Benchmark for Computer Vision},
author={Mu, Norman and Gilmer, Justin},
journal={arXiv preprint arXiv:1906.02337},
year={2019}
}