--- dataset_info: features: - name: image_id dtype: int64 - name: image dtype: image - name: width dtype: int32 - name: height dtype: int32 - name: objects struct: - name: id list: int64 - name: area list: int64 - name: bbox list: list: float32 length: 4 - name: category list: int64 splits: - name: train num_bytes: 31928785 num_examples: 500 - name: validation num_bytes: 7004874 num_examples: 100 - name: test num_bytes: 3954856 num_examples: 50 download_size: 42902433 dataset_size: 42888515 configs: - config_name: default data_files: - split: train path: data/train-* - split: validation path: data/validation-* - split: test path: data/test-* task_categories: - object-detection tags: - yolo - ultralytics - yolov8 - yolov11 - detection - synthetic license: apache-2.0 size_categories: - n<1K --- # 🎯 YOLO Object Detection Dataset A synthetic object detection dataset with **5 classes**, ready for training YOLOv8/v11 models. ## 📊 Dataset Summary | | Train | Validation | Test | |---|---|---|---| | **Images** | 500 | 100 | 50 | | **Hard negatives** | 75 (15%) | 15 (15%) | 7 (15%) | | **Image size** | 640×640 | 640×640 | 640×640 | ## 🏷️ Classes | ID | Class | Visual | |---|---|---| | 0 | `car` | Red car-shaped rectangles with windows & wheels | | 1 | `person` | Blue stick figures with body parts | | 2 | `dog` | Brown dog shapes with legs & tail | | 3 | `cat` | Orange cat shapes with ears & eyes | | 4 | `bicycle` | Green bicycle with wheels & frame | ## 📁 Two Formats Available ### 1. HF Datasets (Parquet) — Browse & Load Programmatically ```python from datasets import load_dataset ds = load_dataset("dharshanzeb/yolo-detection-dataset") print(ds["train"][0]) # {'image_id': 0, 'image': , 'width': 640, 'height': 640, # 'objects': {'id': [...], 'area': [...], 'bbox': [[x,y,w,h], ...], 'category': [...]}} ``` ### 2. YOLO Format (Zips) — Direct Training with Ultralytics Download from [`yolo_format/`](yolo_format/): - `train.zip` — 500 images + labels - `val.zip` — 100 images + labels - `test.zip` — 50 images + labels - `data.yaml` — YOLO config file **Annotation format** (YOLO txt — one `.txt` per image): ``` # All values normalized 0-1 0 0.492188 0.403125 0.212500 0.315625 1 0.720312 0.150000 0.080000 0.120000 ``` ## 🚀 Train YOLOv8 (Quick Start) ### Google Colab / Local ```python # Install !pip install ultralytics from ultralytics import YOLO # Download and prepare dataset from huggingface_hub import hf_hub_download import zipfile, os for split in ["train", "val", "test"]: zip_path = hf_hub_download( repo_id="dharshanzeb/yolo-detection-dataset", filename=f"yolo_format/{split}.zip", repo_type="dataset" ) with zipfile.ZipFile(zip_path) as z: z.extractall("./dataset/") # Download data.yaml yaml_path = hf_hub_download( repo_id="dharshanzeb/yolo-detection-dataset", filename="yolo_format/data.yaml", repo_type="dataset" ) # Update path in data.yaml to point to extracted folder import yaml with open(yaml_path) as f: cfg = yaml.safe_load(f) cfg["path"] = os.path.abspath("./dataset") with open("data.yaml", "w") as f: yaml.dump(cfg, f) # Train! model = YOLO("yolov8n.pt") # nano model for fast training results = model.train( data="data.yaml", epochs=50, imgsz=640, batch=16, device=0, # GPU pretrained=True, mosaic=1.0, mixup=0.1, project="runs/train", name="yolo_custom", ) # Evaluate metrics = model.val() print(f"mAP50: {metrics.box.map50:.3f}") print(f"mAP50-95: {metrics.box.map:.3f}") # Predict results = model.predict("test_image.jpg", conf=0.25) results[0].show() ``` ### Convert HF Dataset → YOLO Format (Alternative) ```python from datasets import load_dataset from pathlib import Path ds = load_dataset("dharshanzeb/yolo-detection-dataset") for split_name, split_key in [("train","train"), ("val","validation"), ("test","test")]: img_dir = Path(f"dataset/images/{split_name}") lbl_dir = Path(f"dataset/labels/{split_name}") img_dir.mkdir(parents=True, exist_ok=True) lbl_dir.mkdir(parents=True, exist_ok=True) for idx, row in enumerate(ds[split_key]): stem = f"img_{idx:05d}" row["image"].save(img_dir / f"{stem}.jpg") lines = [] W, H = row["width"], row["height"] for bbox, cat in zip(row["objects"]["bbox"], row["objects"]["category"]): x, y, w, h = bbox cx, cy = (x + w/2) / W, (y + h/2) / H lines.append(f"{cat} {cx:.6f} {cy:.6f} {w/W:.6f} {h/H:.6f}") with open(lbl_dir / f"{stem}.txt", "w") as f: f.write("\n".join(lines)) ``` ## 📋 Dataset Details - **Hard negatives**: 15% of images contain no objects (empty label files). This is critical for reducing false positives during training — a technique from the synthetic-to-real YOLO paper (arXiv:2509.15045). - **Backgrounds**: Gradient and textured backgrounds with noise for visual diversity. - **Augmentation-ready**: Designed for use with YOLO's built-in Mosaic + Mixup augmentations. - **Bounding boxes**: COCO format `[x_min, y_min, width, height]` in the HF dataset; YOLO normalized format in the zip files. ## 📜 License Apache 2.0