--- 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).
Shape Class Count Description Examples (50x50)
Circle 240,000 Randomly scaled ellipses and perfect circles.
Triangle 240,000 3-sided polygons with dynamic edge stretching.
Rectangle 240,000 4-sided orthogonal shapes (squares and rectangles).
Pentagon 240,000 5-sided regular and dynamically stretched polygons.
Hexagon 240,000 6-sided regular and dynamically stretched polygons.
Parallelogram 240,000 4-sided shapes with forced shear (strictly non-rectangular).
Line 240,000 Curved Quadratic Bezier lines mimicking imperfect hand-drawn strokes.
Total 1,680,000
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 ```