File size: 10,442 Bytes
1e792e9
 
 
 
 
 
 
 
 
 
8970a7d
 
 
5a91265
1ddba9e
 
 
8970a7d
 
5a91265
1ddba9e
 
 
8970a7d
 
5a91265
1ddba9e
 
 
1e792e9
295af1c
 
 
8970a7d
295af1c
8970a7d
 
 
295af1c
 
8970a7d
295af1c
1e792e9
 
 
 
 
 
 
 
 
 
 
 
8970a7d
1e792e9
 
8970a7d
 
 
1e792e9
 
 
 
8970a7d
1e792e9
 
8970a7d
 
 
1e792e9
 
 
 
8970a7d
1e792e9
 
8970a7d
 
 
1e792e9
 
 
 
8970a7d
1e792e9
 
8970a7d
 
 
 
 
 
 
 
 
 
 
 
 
1e792e9
 
 
 
8970a7d
1e792e9
 
8970a7d
 
 
1e792e9
 
 
 
8970a7d
 
1e792e9
8970a7d
 
 
1e792e9
 
 
 
8970a7d
1e792e9
 
 
 
 
8970a7d
295af1c
 
 
 
8970a7d
295af1c
 
 
8970a7d
295af1c
 
 
8970a7d
 
 
 
295af1c
 
 
 
 
 
8970a7d
295af1c
 
 
 
 
8970a7d
 
295af1c
 
 
 
 
8970a7d
295af1c
 
8970a7d
295af1c
 
 
 
8970a7d
 
295af1c
 
 
 
 
 
 
 
 
8970a7d
 
295af1c
8970a7d
295af1c
 
 
8970a7d
 
 
295af1c
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
---
language:
- en
license: mit
task_categories:
- image-classification
tags:
- synthetic
- geometry
- computer-vision
configs:
  - config_name: 30x30
    data_files:
      - split: train
        path: "30x30/train/*.parquet"
      - split: test
        path: "30x30/test/*.parquet"
  - config_name: 40x40
    data_files:
      - split: train
        path: "40x40/train/*.parquet"
      - split: test
        path: "40x40/test/*.parquet"
  - config_name: 50x50
    data_files:
      - split: train
        path: "50x50/train/*.parquet"
      - split: test
        path: "50x50/test/*.parquet"
---
# Geometric Shape Dataset

## Introduction to Dataset
The **Geometric Shape Dataset** is a large-scale, synthetically generated computer vision dataset containing **1,680,000** instances of various geometric shapes and lines. It is designed for training image classification, feature extraction, and pattern recognition models across different scales. 

The dataset is available in three distinct resolution configurations: **30x30, 40x40, and 50x50** (560,000 images per resolution).

Instead of clean, binary pixel representations, this dataset introduces complex mathematical variations: every shape features dynamic scaling, random rotations, varied boundary thickness, and a unique distance-based "halo" noise gradient. Additionally, a global background noise is applied to the entire canvas. Values are strictly normalized between `0.0` and `1.0`.

## Shapes Distribution
The dataset is perfectly balanced. It contains 7 distinct classes, distributed equally across the 1,680,000 samples (240,000 images per class in total, or 80,000 per class per resolution).

<table style="width: 100%; text-align: left; border-collapse: collapse;">
  <thead>
    <tr>
      <th>Shape Class</th>
      <th>Count</th>
      <th>Description</th>
      <th style="text-align: center;">Examples (50x50)</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><strong>Circle</strong></td>
      <td>240,000</td>
      <td>Randomly scaled ellipses and perfect circles.</td>
      <td style="white-space: nowrap; text-align: center;">
        <img src="50x50/samples/circular/0000001.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;">
        <img src="50x50/samples/circular/0000002.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;">
        <img src="50x50/samples/circular/0000003.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;">
      </td>
    </tr>
    <tr>
      <td><strong>Triangle</strong></td>
      <td>240,000</td>
      <td>3-sided polygons with dynamic edge stretching.</td>
      <td style="white-space: nowrap; text-align: center;">
        <img src="50x50/samples/triangular/0000001.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;">
        <img src="50x50/samples/triangular/0000002.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;">
        <img src="50x50/samples/triangular/0000003.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;">
      </td>
    </tr>
    <tr>
      <td><strong>Rectangle</strong></td>
      <td>240,000</td>
      <td>4-sided orthogonal shapes (squares and rectangles).</td>
      <td style="white-space: nowrap; text-align: center;">
        <img src="50x50/samples/rectangular/0000001.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;">
        <img src="50x50/samples/rectangular/0000002.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;">
        <img src="50x50/samples/rectangular/0000003.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;">
      </td>
    </tr>
    <tr>
      <td><strong>Pentagon</strong></td>
      <td>240,000</td>
      <td>5-sided regular and dynamically stretched polygons.</td>
      <td style="white-space: nowrap; text-align: center;">
        <img src="50x50/samples/pentagonal/0000001.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;">
        <img src="50x50/samples/pentagonal/0000002.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;">
        <img src="50x50/samples/pentagonal/0000003.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;">
      </td>
    </tr>
    <tr>
      <td><strong>Hexagon</strong></td>
      <td>240,000</td>
      <td>6-sided regular and dynamically stretched polygons.</td>
      <td style="white-space: nowrap; text-align: center;">
        <img src="50x50/samples/hexagonal/0000001.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;">
        <img src="50x50/samples/hexagonal/0000002.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;">
        <img src="50x50/samples/hexagonal/0000003.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;">
      </td>
    </tr>
    <tr>
      <td><strong>Parallelogram</strong></td>
      <td>240,000</td>
      <td>4-sided shapes with forced shear (strictly non-rectangular).</td>
      <td style="white-space: nowrap; text-align: center;">
        <img src="50x50/samples/parallelogram/0000001.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;">
        <img src="50x50/samples/parallelogram/0000002.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;">
        <img src="50x50/samples/parallelogram/0000003.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;">
      </td>
    </tr>
    <tr>
      <td><strong>Line</strong></td>
      <td>240,000</td>
      <td>Curved Quadratic Bezier lines mimicking imperfect hand-drawn strokes.</td>
      <td style="white-space: nowrap; text-align: center;">
        <img src="50x50/samples/line/0000001.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;">
        <img src="50x50/samples/line/0000002.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;">
        <img src="50x50/samples/line/0000003.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;">
      </td>
    </tr>
    <tr>
      <td><strong>Total</strong></td>
      <td><strong>1,680,000</strong></td>
      <td></td>
      <td></td>
    </tr>
  </tbody>
</table>
Note: For all samples, you can go to Files and Versions, then click into the respective resolution's `samples` folders.

## Dataset Characteristics & Generation Details
To prevent models from easily memorizing shapes, several advanced data augmentation techniques were mathematically baked into the generation process:
* **Float16 Precision:** Continuous pixel values rather than 8-bit integers, preserving the exact mathematical noise distribution.
* **Curved Strokes:** Lines are generated using Bezier curves with varying bend amounts, perfectly simulating the imperfections of human drawing.
* **Dynamic Thickness:** The solid boundaries of the shapes randomly vary between 1, 2, or 3 pixels.
* **Halo Noise Gradient:** A localized noise layer surrounds the shape, inversely proportional to the distance from the solid boundary (fading out over a 4-pixel radius).
* **Global Noise:** A uniform random noise between `-0.1` and `0.1` applied globally (clipped to stay within `[0, 1]`).
* **Safety Scaling:** Bounding boxes guarantee that no shape clips outside the canvas boundaries, even under extreme rotation or shear.

## Storage Structure
To optimize both disk space and loading speeds, the dataset is architected with modern streaming in mind:
* **Configurations by Resolution:** Choose between `30x30`, `40x40`, or `50x50` subsets right from the Hugging Face viewer.
* **Chunked Parquet Files:** The dataset is split into smaller, highly compressed `.parquet` chunks (5,600 images per chunk).
* **Flattened Arrays:** Parquet does not natively support 2D/3D matrix cells, so the images are safely flattened into `1D` arrays. Depending on the configuration, the array length will be `900` (for 30x30), `1600` (for 40x40), or `2500` (for 50x50). They can be instantly reshaped during training.
* **Pre-Shuffled:** The shapes are heavily shuffled *within* each chunk before saving. You will receive perfectly mixed, heterogeneous batches starting from the very first megabyte.

## How to Use

Because of the chunked Parquet structure, you can either download the entire dataset or use **Iterable Streaming** (lazy loading) to train models without consuming any hard drive space.

### 1. Streaming Mode
Use `streaming=True` and specify the `name` argument (e.g., `"50x50"`) to fetch data on the fly. Don't forget to reshape the 1D flat array back to a 2D matrix matching your chosen resolution.

```python
from datasets import load_dataset
import numpy as np

# Load dataset configuration "50x50" without downloading to disk
iterable_dataset = load_dataset("OmerTurk1/GeometricShapeDataset", name="50x50", split="train", streaming=True)

# You can add a buffer shuffle for even more randomness during training
shuffled_dataset = iterable_dataset.shuffle(buffer_size=10000, seed=42)

for data in shuffled_dataset:
    # Extract and convert to numpy array
    flat_image = np.array(data["image"], dtype=np.float16)
    
    # Reshape back to 50x50 matrix (Change to 30, 30 if using the 30x30 config)
    image_matrix = flat_image.reshape(50, 50)
    label = data["label"]
    
    print(f"Label: {label} | Shape: {image_matrix.shape}")

    # Rest is up to you
```

### 2. Standard Download
If you have enough RAM and want to load the entire dataset into memory:

```python
from datasets import load_dataset
import numpy as np

# This will download the 30x30 dataset configuration to your local Hugging Face cache
dataset = load_dataset("OmerTurk1/GeometricShapeDataset", name="30x30", split="train")

# Reshape back to 50x50 matrix (Change to 30, 30 if using the 30x30 config)
first_image = np.array(dataset[0]["image"], dtype=np.float16).reshape(50, 50)
first_label = dataset[0]["label"]

print(f"First image is a {first_label} with shape {first_image.shape}")

# Rest is up to you
```