YOLOv8 Smart Parking Detection
Binary parking occupancy (free vs not-free) with YOLOv8n. Test mAP50=0.942, mAP50-95=0.798. Early stopped at epoch 74. 30 CVAT-annotated images (22/4/4). Inference: 9 free + 21 occupied per lot @ 41.2ms.
30 CVAT-annotated parking lot images (22/4/4 split)
CVAT polygon → YOLO bbox → YOLOv8n fine-tuning (early stopped ep 74)
Parking space occupancy detection using YOLOv8n on a custom CVAT-annotated dataset.
Dataset & Annotation
- ▸30 parking lot images with CVAT polygon annotations
- ▸2 classes: free_parking_space / not_free_parking_space
- ▸Train: 22 / Val: 4 / Test: 4 (stratified by class ratio)
- ▸Annotations converted from CVAT XML polygons to YOLO normalized bboxes
CVAT XML → YOLO Conversion
# For each polygon in CVAT XML:
x_min, y_min = min(pts_x), min(pts_y)
x_max, y_max = max(pts_x), max(pts_y)
cx = ((x_min + x_max) / 2) / img_width # normalized center x
cy = ((y_min + y_max) / 2) / img_height # normalized center y
w = (x_max - x_min) / img_width
h = (y_max - y_min) / img_height
Training Config
| Parameter | Value |
|---|---|
| Model | YOLOv8n (3.01M params, 73 layers, 8.1 GFLOPs) |
| Max epochs | 100 |
| Early stopping | patience=10 → stopped at epoch 74 |
| Batch size | 16 |
| Image size | 640 |
| Optimizer | AdamW |
Validation Results (best model, 4 images)
| Metric | Value |
|---|---|
| mAP50 | 0.994 |
| mAP50-95 | 0.880 |
| Precision | 0.982 |
| Recall | 0.989 |
Test Set Results (4 images, 110 instances)
| Class | Precision | Recall | mAP50 | mAP50-95 |
|---|---|---|---|---|
| Free spaces | 0.959 | 0.709 | 0.918 | 0.782 |
| Not-free spaces | 0.894 | 0.935 | 0.967 | 0.814 |
| Overall | 0.926 | 0.822 | 0.942 | 0.798 |
Inference Demo (single 352×640 image)
- ▸Detected: 9 free + 21 not-free parking spaces
- ▸Speed: 2.2ms preprocess + 41.2ms inference + 1.4ms postprocess @ confidence=0.25
Application Real-time parking management: camera → YOLOv8n → occupancy counts → display board update. Despite only 30 training images, pretrained COCO weights transfer the object detection priors effectively to this domain-specific binary classification task.