File size: 5,502 Bytes
a864039
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46f16a7
a864039
96c8604
9fd15cc
 
 
a864039
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9a9aa8a
a864039
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
---
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](https://huggingface.co/datasets/randall-lab/dsprites-color/resolve/main/animation0.gif)

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

- [randall-lab/dsprites (default, grayscale)](https://huggingface.co/datasets/randall-lab/dsprites)
- [randall-lab/dsprites-noisy](https://huggingface.co/datasets/randall-lab/dsprites-noisy)
- [randall-lab/dsprites-scream](https://huggingface.co/datasets/randall-lab/dsprites-scream)

## Dataset Source
- **Homepage**: [https://github.com/google-research/disentanglement_lib/](https://github.com/google-research/disentanglement_lib/tree/master)
- **License**: Apache License 2.0
- **Paper**: Francesco Locatello et al. _Challenging Common Assumptions in the Unsupervised Learning of Disentangled Representations_. ICML 2019.

## 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:
```python
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}
}
```