dsprites-color / README.md
haodoz0118's picture
Update README.md
96c8604 verified
metadata
license: apache-2.0

Dataset Card for Color dSprites

Dataset Description

The Color dSprites dataset is a synthetic 2D shapes dataset designed for benchmarking algorithms in disentangled representation learning and unsupervised representation learning.

It is a variant of the original dSprites dataset introduced in the β-VAE paper. In this version, each object is randomly colored per sample, while the background remains black. This allows researchers to evaluate robustness to color variation and assess how well models can learn disentangled representations under color transformations.

The dataset consists of procedurally generated images of 2D sprites, under controlled variations of 6 known factors of variation:

  • Object color (1 value in original dSprites, but here a random RGB color ∈ [0.5,1.0] is applied to each object at runtime)
  • Object shape (3 values: square, ellipse, heart)
  • Object scale (6 values)
  • Object orientation (40 values)
  • Object position X (32 values)
  • Object position Y (32 values)

All possible combinations of these factors are present exactly once, generating a total of 737,280 images at a resolution of 64×64 pixels. Each image is provided along with Discrete latent classes (indices for each factor), Continuous latent values and Actual object color used (colorRGB field).

These variants allow systematic testing under random color of object.

Dataset Visualization

The dataset is commonly used for benchmarking disentanglement learning, and can be used in conjunction with other variants:

Dataset Source

Dataset Structure

Factors Possible Classes (Indices) Values
color white=0 (original label, fixed) Random RGB color ∈ [0.5,1.0] stored in colorRGB
shape square=0, ellipse=1, heart=2 1.0, 2.0, 3.0 (categorical)
scale 0,...,5 [0.5, 1.0] linearly spaced (6 values)
orientation 0,...,39 [0, 2π] radians (40 values)
posX 0,...,31 [0, 1] normalized position (32 values)
posY 0,...,31 [0, 1] normalized position (32 values)

Note: In this Color variant, the color and colorValue fields remain 0 to match the original dSprites format. The actual applied color is provided in colorRGB, a list of [R, G, B] values ∈ [0.5,1.0]. Each image corresponds to a unique combination of these 6 factors. The images are stored in a row-major order (fastest-changing factor is posY, slowest-changing factor is color).

Why no train/test split?

The Color dSprites dataset does not provide an official train/test split. It is designed for representation learning research, where the goal is to learn disentangled and interpretable latent factors. Since the dataset is a complete Cartesian product of all factor combinations, models typically require access to the full dataset to explore factor-wise variations.

Example Usage

Below is a quick example of how to load this dataset via the Hugging Face Datasets library:

from datasets import load_dataset

# Load the dataset
dataset = load_dataset("randall-lab/dsprites-color", split="train", trust_remote_code=True)

# Access a sample from the dataset
example = dataset[0]
image = example["image"]
label = example["label"]         # [color_idx, shape_idx, scale_idx, orientation_idx, posX_idx, posY_idx]
label_values = example["label_values"]  # corresponding continuous values
colorRGB = example["colorRGB"]   # Actual RGB color used in this sample

# Label Classes
color = example["color"]         # 0
shape = example["shape"]         # 0-2
scale = example["scale"]         # 0-5
orientation = example["orientation"]   # 0-39
posX = example["posX"]           # 0-31
posY = example["posY"]           # 0-31

# Label Values
color_value = example["colorValue"]         # 1
shape_value = example["shapeValue"]         # 1.0, 2.0, 3.0
scale_value = example["scaleValue"]         # [0.5, 1]
orientation_value = example["orientationValue"]   # [0, 2π]
posX_value = example["posXValue"]           # [0, 1]
posY_value = example["posYValue"]           # [0, 1]

# Actual color applied to object
print(f"Actual RGB color: {colorRGB}")

image.show()  # Display the image
print(f"Label (factors): {label}")
print(f"Label values (factors): {label_values}")

If you are using colab, you should update datasets to avoid errors

pip install -U datasets

Citation

@inproceedings{locatello2019challenging,
  title={Challenging Common Assumptions in the Unsupervised Learning of Disentangled Representations},
  author={Locatello, Francesco and Bauer, Stefan and Lucic, Mario and Raetsch, Gunnar and Gelly, Sylvain and Sch{\"o}lkopf, Bernhard and Bachem, Olivier},
  booktitle={International Conference on Machine Learning},
  pages={4114--4124},
  year={2019}
}