| --- |
| language: |
| - en |
| license: mit |
| task_categories: |
| - image-classification |
| - object-detection |
| tags: |
| - synthetic |
| - geometry |
| - computer-vision |
| - float16 |
| pretty_name: Geometric Shape Dataset |
| size_categories: |
| - 100K<n<1M |
| --- |
| # Geometric Shape Dataset |
|
|
| ## Introduction to Dataset |
| The **Geometric Shape Dataset** is a large-scale, synthetically generated computer vision dataset containing **900,000** instances of various geometric shapes and lines. It is designed for training image classification, feature extraction, and pattern recognition models. |
|
|
| Instead of clean, binary pixel representations, this dataset introduces complex mathematical variations: every shape features dynamic scaling, random rotations, varied boundary thickness (1 to 3 pixels), and a unique distance-based "halo" noise gradient. Additionally, a global background noise is applied to the entire 50x50 canvas. Values are strictly normalized between `0.0` and `1.0`. |
|
|
| ## Shapes Distribution |
| The dataset is perfectly balanced. It contains 6 distinct classes, distributed equally across the 900,000 samples. |
|
|
| <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>150,000</td> |
| <td>Randomly scaled ellipses and perfect circles.</td> |
| <td style="white-space: nowrap; text-align: center;"> |
| <img src="circular/0000001.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;"> |
| <img src="circular/0000002.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;"> |
| <img src="circular/0000003.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;"> |
| <img src="circular/0000004.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;"> |
| </td> |
| </tr> |
| <tr> |
| <td><strong>Triangle</strong></td> |
| <td>150,000</td> |
| <td>3-sided polygons with dynamic edge stretching.</td> |
| <td style="white-space: nowrap; text-align: center;"> |
| <img src="triangular/0000001.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;"> |
| <img src="triangular/0000002.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;"> |
| <img src="triangular/0000003.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;"> |
| <img src="triangular/0000004.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;"> |
| </td> |
| </tr> |
| <tr> |
| <td><strong>Rectangle</strong></td> |
| <td>150,000</td> |
| <td>4-sided orthogonal shapes (squares and rectangles).</td> |
| <td style="white-space: nowrap; text-align: center;"> |
| <img src="rectangular/0000001.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;"> |
| <img src="rectangular/0000002.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;"> |
| <img src="rectangular/0000003.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;"> |
| <img src="rectangular/0000004.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;"> |
| </td> |
| </tr> |
| <tr> |
| <td><strong>Pentagon</strong></td> |
| <td>150,000</td> |
| <td>5-sided regular and dynamically stretched polygons.</td> |
| <td style="white-space: nowrap; text-align: center;"> |
| <img src="pentagonal/0000001.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;"> |
| <img src="pentagonal/0000002.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;"> |
| <img src="pentagonal/0000003.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;"> |
| <img src="pentagonal/0000004.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;"> |
| </td> |
| </tr> |
| <tr> |
| <td><strong>Parallelogram</strong></td> |
| <td>150,000</td> |
| <td>4-sided shapes with forced shear (strictly non-rectangular).</td> |
| <td style="white-space: nowrap; text-align: center;"> |
| <img src="parallelogram/0000001.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;"> |
| <img src="parallelogram/0000002.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;"> |
| <img src="parallelogram/0000003.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;"> |
| <img src="parallelogram/0000004.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;"> |
| </td> |
| </tr> |
| <tr> |
| <td><strong>Line</strong></td> |
| <td>150,000</td> |
| <td>Straight linear segments of varying lengths and angles.</td> |
| <td style="white-space: nowrap; text-align: center;"> |
| <img src="line/0000001.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;"> |
| <img src="line/0000002.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;"> |
| <img src="line/0000003.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;"> |
| <img src="line/0000004.png" width="50" height="50" style="display: inline-block; margin: 2px; border-radius: 4px;"> |
| </td> |
| </tr> |
| <tr> |
| <td><strong>Total</strong></td> |
| <td><strong>900,000</strong></td> |
| <td></td> |
| <td></td> |
| </tr> |
| </tbody> |
| </table> |
| |
| Note: For all samples, you can go to Files and Versions, then click each shape folders to view shape samples |
|
|
| ## 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. |
| * **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 50x50 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: |
| * **Chunked Parquet Files:** The dataset is split into smaller, highly compressed `.parquet` chunks. |
| * **Flattened Arrays:** Parquet does not natively support 2D/3D matrix cells, so the `50x50` images are safely flattened into `1D` arrays of length `2500`. (They can be instantly reshaped during training). |
| * **Pre-Shuffled:** The shapes are heavily shuffled *within* each chunk before saving. If you stream this dataset, you will not get 150,000 circles followed by 150,000 triangles. 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` to fetch data on the fly. Don't forget to reshape the 1D flat array back to `50x50`. |
|
|
| ```python |
| from datasets import load_dataset |
| import numpy as np |
| |
| # Load dataset without downloading to disk |
| iterable_dataset = load_dataset("OmerTurk1/GeometricShapeDataset", 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: |
| # 1. Extract and convert to numpy array |
| flat_image = np.array(data["image"], dtype=np.float16) |
| |
| # 2. Reshape back to 50x50 matrix |
| image_matrix = flat_image.reshape(50, 50) |
| label = data["label"] |
| |
| print(f"Label: {label} | Shape: {image_matrix.shape}") |
| |
| # Feed to your model (train_step) |
| break |
| ``` |
|
|
| ### 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 dataset to your local Hugging Face cache |
| dataset = load_dataset("OmerTurk1/GeometricShapeDataset", split="train") |
| |
| # Accessing a specific index and reshaping |
| 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}") |
| ``` |