Dataset Viewer
Auto-converted to Parquet
Search is not available for this dataset
image
imagewidth (px)
28
28
label
class label
10 classes
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
End of preview. Expand in Data Studio

Colored MNIST Dataset

A comprehensive dataset of MNIST digits with RGB colored backgrounds, designed for multi-objective classification tasks including digit recognition and background color classification.

Blue Example Green Example Red Example

Overview

This dataset extends the classic MNIST digit dataset by adding colored backgrounds (blue, green, red) to create a multi-label classification challenge. Each image contains:

  • Digit label: 0-9 (digit recognition)
  • Color label: blue, green, red (background color classification)
  • Image format: 28Γ—28 RGB PNG files

Dataset Statistics

Training Set (8,835 samples)

Digit Count Digit Count
0 868 5 764
1 1,000 6 893
2 858 7 948
3 909 8 835
4 883 9 877

Test Set (10,000 samples)

Digit Count Digit Count
0 980 5 892
1 1,135 6 958
2 1,032 7 1,028
3 1,010 8 974
4 982 9 1,009

Color Distribution

  • Blue: ~2,946 training samples
  • Green: ~2,968 training samples
  • Red: ~2,921 training samples

Directory Structure

colored_mnist/
β”œβ”€β”€ README.md
β”œβ”€β”€ colored_mnist.py          # HuggingFace dataset loader
β”œβ”€β”€ images/                   # Example images
β”‚   β”œβ”€β”€ blue_312.png         # Blue background, digit 3
β”‚   β”œβ”€β”€ green_8218.png       # Green background, digit 8  
β”‚   └── red_8428.png         # Red background, digit 4
β”œβ”€β”€ training/                 # Training data
β”‚   β”œβ”€β”€ 0/                   # Digit 0 samples
β”‚   β”‚   β”œβ”€β”€ blue_1015.png
β”‚   β”‚   β”œβ”€β”€ green_1000.png
β”‚   β”‚   └── red_1028.png
β”‚   └── ...                  # Digits 1-9
β”œβ”€β”€ testing/                  # Test data
β”‚   β”œβ”€β”€ 0/                   # Digit 0 samples
β”‚   β”‚   β”œβ”€β”€ blue_10.png
β”‚   β”‚   β”œβ”€β”€ green_1084.png
β”‚   β”‚   └── red_1001.png
β”‚   └── ...                  # Digits 1-9
β”œβ”€β”€ training.h5              # HDF5 format (optional)
└── testing.h5               # HDF5 format (optional)

Usage

Loading with HuggingFace Datasets

from datasets import load_dataset

# Load the dataset using the custom script
dataset = load_dataset("FrankCCCCC/colored_mnist", trust_remote_code=True)

print(f"Train samples: {len(dataset['train'])}")
print(f"Test samples: {len(dataset['test'])}")

# Access a sample
sample = dataset['train'][0]
print(f"Image shape: {sample['image'].shape}")  # PIL.Image: Raw Image with shape (28, 28, 3)
print(f"Digit Label: {sample['digit_label']}")  # Integer: Digit class 0-9
print(f"Color Label: {sample['color_label']}")  # String: Color class: 'blue', 'green', 'red'
print(f"filename: {sample['filename']}")        # String: file name
print(f"image_path: {sample['image_path']}")    # String: file path

Applications

This dataset is ideal for:

  1. Multi-task Learning: Train models to simultaneously classify digits and colors
  2. Domain Adaptation: Study how background colors affect digit recognition
  3. Bias Analysis: Investigate color-digit correlations and model robustness
  4. Transfer Learning: Pre-train on one task (digit/color) and fine-tune on another
  5. Curriculum Learning: Start with single-task then progress to multi-task
  6. Attention Mechanisms: Visualize what models focus on (digit vs. background)

Features

  • Multi-label Classification: Both digit and color labels for each image
  • Balanced Colors: Approximately equal distribution across blue, green, red
  • Standard Format: Compatible with PyTorch, TensorFlow, and HuggingFace
  • PIL Integration: Images loaded as PIL objects for easy preprocessing
  • Metadata: Includes original filename and image path information

Dataset Format

Each sample contains:

{
    'image': PIL.Image,           # 28Γ—28 RGB image
    'digit_label': int,           # Digit class (0-9)
    'color_label': str,           # Color class ('blue'|'green'|'red')
    'filename': str,              # Original filename
    'image_path': str             # Full path to image file
}

Requirements

pip install datasets pillow torch torchvision matplotlib numpy

Citation

@misc{colorized-mnist,
  title={Colorized MNIST},
  author={Original MNIST Dataset},
  year={2024},
  url={https://github.com/jayaneetha/colorized-MNIST}
}

License

This dataset follows the same license as the original MNIST dataset. Please cite both the original MNIST work and this colored extension when using this dataset.

Acknowledgments

  • Based on the original MNIST dataset by Yann LeCun et al.
  • Color augmentation creates additional research opportunities for multi-task learning
  • Compatible with modern deep learning frameworks and HuggingFace ecosystem
Downloads last month
560