Datasets:
Modalities:
Image
Formats:
imagefolder
Sub-tasks:
image-captioning
Languages:
English
Size:
10K - 100K
Tags:
computer-vision
synthetic-data
geometric-shapes
motion-analysis
multi-object
spatial-reasoning
License:
File size: 9,633 Bytes
8a6e094 3356e2c 8a6e094 2a3bff2 8a6e094 03e2836 8a6e094 3356e2c |
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 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
---
license: mpl-2.0
task_categories:
- image-to-text
- visual-question-answering
task_ids:
- image-captioning
language:
- en
size_categories:
- 1K<n<10K
tags:
- computer-vision
- synthetic-data
- geometric-shapes
- motion-analysis
- multi-object
- spatial-reasoning
---
# π SHAPES Motion Dataset
<div align="center">




*A high-quality synthetic dataset of geometric shapes in motion with rich textual descriptions*
</div>
## π Dataset Highlights
- **10,000 high-resolution images** (1024Γ1024 pixels)
- **Rich captions** with motion dynamics and spatial relationships
- **Diverse geometric shapes** with realistic motion trails
- **Multi-object scenes** with complex interactions
- **Synthetic but realistic** rendering with gradient backgrounds
## π Dataset Structure
```bash
set_SHAPES/
βββ images/
β βββ 00001.jpg
β βββ 00002.jpg
β βββ ... (10,000 files)
βββ captions.csv
```
### π Metadata Columns
- `filename`: Unique image identifier
- `caption`: Detailed natural language description
- `motion_type`: [moving, sliding, drifting, streaking, arcing]
- `dynamics`: [constant, accelerating, decelerating, rotating, curving]
- `num_objects`: Number of objects in scene (1-3)
## π¨ Visual Features
### π¦ Geometric Shapes
- **Basic**: Circle, Square, Rectangle, Ellipse
- **Complex**: Triangle, Pentagon
- **Size Variations**: Tiny β Huge (5 scales)
- **Color Palette**: 14 distinct colors with contrasting outlines
### π¬ Motion Dynamics
```python
# Motion Types
MOTION_VERBS = ['moving', 'sliding', 'drifting', 'streaking', 'arcing']
# Dynamics
MOTION_DYNAMICS = [
'at constant speed',
'while accelerating',
'while decelerating',
'while rotating',
'in a curve while rotating'
]
```
### π― Spatial Relations
- **Positional**: top-left, center, bottom-right, etc.
- **Relative**: passing by, near, adjacent to
- **Size comparisons**: larger than, smaller than
## π Example Captions
**Motion Scene**:
*"A large wide blue rectangle with a yellow outline is sliding while accelerating from the top left towards the bottom center, passing by a static medium standard red circle with a black outline in the middle."*
**Static Scene**:
*"An image with a huge green pentagon with magenta outline in the bottom right and a tiny tall orange ellipse with cyan outline in the top center."*
## π Quick Start
### Installation
```bash
pip install datasets pillow
```
### Load Dataset
```python
from datasets import load_dataset
dataset = load_dataset("Maazwaheed/set_SHAPES")
print(f"Dataset size: {len(dataset['train'])}")
print(f"Sample caption: {dataset['train'][0]['caption']}")
```
### fast load
```python
import os
import logging
from concurrent.futures import ThreadPoolExecutor, as_completed
from datasets import load_dataset
from PIL import Image
import pandas as pd
from tqdm import tqdm
import io
import threading
# Configuration
DATASET_NAME = "Maazwaheed/set_SHAPES"
OUTPUT_DIR = "advanced_motion_dataset"
IMAGES_DIR = os.path.join(OUTPUT_DIR, "images")
MAX_WORKERS = 16 # Adjust based on system capabilities
HF_TOKEN = os.getenv("HF_TOKEN") # Ensure HF_TOKEN is set in environment
LOG_DIR = "logs"
LOG_FILE = os.path.join(LOG_DIR, "download.log")
# Setup logging
os.makedirs(LOG_DIR, exist_ok=True)
logging.basicConfig(
filename=LOG_FILE,
level=logging.INFO,
format="%(asctime)s - %(levelname)s - %(message)s"
)
# Thread-safe counter for tracking downloaded images
download_counter = 0
counter_lock = threading.Lock()
def setup_directories():
"""Create output directories if they don't exist."""
try:
os.makedirs(OUTPUT_DIR, exist_ok=True)
os.makedirs(IMAGES_DIR, exist_ok=True)
logging.info(f"Created directories: {OUTPUT_DIR}, {IMAGES_DIR}")
except Exception as e:
logging.error(f"Failed to create directories: {e}")
raise
def download_image(item, index):
"""Download and save a single image with its filename."""
try:
image = item["image"]
filename = item.get("filename", f"{str(index+1).zfill(5)}.jpg")
image_path = os.path.join(IMAGES_DIR, filename)
# Convert to RGB if needed and save as JPEG
if image.mode != "RGB":
image = image.convert("RGB")
image.save(image_path, "JPEG", quality=95)
# Increment counter thread-safely
global download_counter
with counter_lock:
download_counter += 1
return filename, item.get("caption", ""), None
except Exception as e:
logging.error(f"Failed to download image at index {index}: {e}")
return None, None, str(e)
def download_dataset():
"""Download the dataset efficiently using parallel processing."""
try:
# Load dataset
logging.info(f"Loading dataset: {DATASET_NAME}")
dataset = load_dataset(DATASET_NAME, split="train", use_auth_token=HF_TOKEN)
logging.info(f"Dataset loaded with {len(dataset)} items")
# Setup directories
setup_directories()
# Prepare metadata
metadata = []
# Download images in parallel
logging.info(f"Starting parallel download with {MAX_WORKERS} workers")
with ThreadPoolExecutor(max_workers=MAX_WORKERS) as executor:
future_to_index = {executor.submit(download_image, dataset[i], i): i for i in range(len(dataset))}
progress_bar = tqdm(total=len(dataset), desc="Downloading images")
for future in as_completed(future_to_index):
index = future_to_index[future]
filename, caption, error = future.result()
if filename and caption is not None:
metadata.append([filename, caption])
else:
logging.warning(f"Skipped item at index {index} due to error: {error}")
progress_bar.update(1)
progress_bar.close()
# Save captions.csv
try:
csv_path = os.path.join(OUTPUT_DIR, "captions.csv")
with open(csv_path, "w", newline="", encoding="utf-8") as f:
writer = pd.DataFrame(metadata, columns=["filename", "caption"])
writer.to_csv(f, index=False)
logging.info(f"Saved captions to {csv_path}")
except Exception as e:
logging.error(f"Failed to save captions.csv: {e}")
raise
logging.info(f"Downloaded {download_counter} images to {IMAGES_DIR}")
print(f"Dataset downloaded successfully! {download_counter} images saved to {IMAGES_DIR}, captions saved to {csv_path}")
except Exception as e:
logging.error(f"Dataset download failed: {e}")
raise
if __name__ == "__main__":
try:
download_dataset()
except Exception as e:
print(f"Error downloading dataset: {e}")
logging.error(f"Main execution failed: {e}")
raise
```
### Advanced Usage
```python
# Filter motion scenes
motion_scenes = [item for item in dataset['train']
if 'moving' in item['caption'] or 'sliding' in item['caption']]
# Get multi-object scenes
multi_object = [item for item in dataset['train']
if 'and' in item['caption']]
```
## π Statistics
| Metric | Value |
|--------|-------|
| Total Images | 10,000 |
| Motion Scenes | ~6,000 |
| Static Scenes | ~4,000 |
| Avg. Caption Length | 35 words |
| Color Variations | 14 colors |
| Shape Types | 6 shapes |
## π― intended Use
### β
Primary Tasks
- **Image Captioning** - Rich descriptions for training
- **Visual Question Answering** - Spatial reasoning
- **Motion Understanding** - Dynamic scene analysis
- **Object Detection** - Multi-object recognition
- **Synthetic-to-Real Transfer** - Domain adaptation
### β οΈ Limitations
- Synthetic data (not real-world)
- Limited to geometric shapes
- Predetermined color palette
- Simplified physics model
## π§ Technical Details
### Generation Process
1. **Background**: Gradient generation with smooth transitions
2. **Shapes**: Anti-aliased rendering with outlines
3. **Motion**: BΓ©zier curves with trail effects
4. **Composition**: Multi-object placement with occlusion handling
5. **Captions**: Rule-based natural language generation
### Technical Specs
- **Format**: JPEG (quality=95)
- **Color Space**: RGB
- **Resolution**: 1024Γ1024
- **Size per Image**: ~150-250KB
- **Total Dataset Size**: 561MB
## π License
**MPL-2.0** - Allows commercial use, modification, and distribution with appropriate attribution.
## π€ Contributing
We welcome contributions! Please:
1. Fork the repository
2. Create a feature branch
3. Submit a pull request
4. Open issues for suggestions
## π Contact
**Maintainer**: Maaz Waheed
**Email**: [Your Email]
**Hugging Face**: [Maazwaheed](https://huggingface.co/Maazwaheed)
## π Acknowledgments
- Hugging Face for dataset hosting
- PIL/Pillow community for image processing
- Open-source community for inspiration
---
<div align="center">
**β Star this dataset if you find it useful!**
[](https://huggingface.co/datasets/Maazwaheed/set_SHAPES)
[](https://www.mozilla.org/en-US/MPL/2.0/)
</div> |