Object Detection and Segmentation
A two-task computer vision pipeline built from raw MNIST: find each digit with a box and a label, and classify every pixel by digit. 120,000 synthetic 128×128 scenes, YOLOv8 Small fine-tuned for detection, a 4-level U-Net written from scratch for segmentation, trained on 2 T4 GPUs in one notebook. My BCO074C minor project.
- Reading
- 94.39%detection F1, YOLOv8 Small10,000 held-out scenes, 20,000 digits, all from the unseen MNIST test digits
- Limitation
- Synthetic scenes with exactly two digits on a noisy background; nothing here is tested on real photographs. Precision (0.9111) trails recall (0.9792): the detector raises more false detections than it misses digits.
Problem
MNIST holds one centred digit per image. Reading meters, forms or postcodes needs several digits at once, anywhere in the frame, on varied backgrounds.
Approach
Generate the data with labels for free: two random MNIST digits per 128×128 scene on a noisy coloured background, scaled and rotated in training only, with boxes and per-pixel masks saved alongside. The test split uses the official MNIST test digits, never seen in training. YOLOv8 Small handles detection; a 4-level U-Net written from scratch handles segmentation.
Result
On 10,000 held-out scenes YOLOv8 Small finds 19,585 of 20,000 digits: recall 0.9792, precision 0.9111, F1 0.9439. The U-Net reaches mean IoU 0.9595 and pixel accuracy 0.9996, with every digit class above 0.94 IoU.
Limitation
Synthetic scenes with exactly two digits on a noisy background; nothing here is tested on real photographs. Precision (0.9111) trails recall (0.9792): the detector raises more false detections than it misses digits.
Finding
Moving from 60,000 to 100,000 training scenes and from YOLOv8 nano to small raised detection F1 from 92.87% to 94.39%. Loading all 120,000 scenes into RAM (about 3.2 GB) took GPU use from 10 to 40% up to 86 to 90%.
| Measure | Value |
|---|---|
| Detection precision | 0.9111 |
| Detection recall | 0.9792 |
| Detection F1 | 0.9439 |
| Segmentation mean IoU | 0.9595 |
| Foreground accuracy | 0.9745 |
| Pixel accuracy | 0.9996 |
| Measure | Value |
|---|---|
| Digit 0 | 0.9318 |
| Digit 1 | 0.9105 |
| Digit 2 | 0.9439 |
| Digit 3 | 0.9706 |
| Digit 4 | 0.9577 |
| Digit 5 | 0.9504 |
| Digit 6 | 0.9509 |
| Digit 7 | 0.9454 |
| Digit 8 | 0.9478 |
| Digit 9 | 0.9390 |
| Measure | Value |
|---|---|
| Digit 0 | 0.9656 |
| Digit 1 | 0.9522 |
| Digit 2 | 0.9625 |
| Digit 3 | 0.9617 |
| Digit 4 | 0.9469 |
| Digit 5 | 0.9492 |
| Digit 6 | 0.9606 |
| Digit 7 | 0.9535 |
| Digit 8 | 0.9626 |
| Digit 9 | 0.9403 |
Specification
- Dataset
- 120,000 scenes at 128×128: 100,000 train, 10,000 validation, 10,000 test from the MNIST test digits
- Detector
- YOLOv8 Small, 11.2M parameters, COCO-pretrained, fine-tuned for 10 classes; batch 256, AdamW, cosine decay, fp16, DDP on 2 T4s
- Segmenter
- U-Net from scratch, 4 levels (32 to 256 channels, 512 at the bottleneck), about 7.8M parameters; batch 512, AdamW, mixed precision, DataParallel
- Detection, per digit
- F1 from 0.9105 (digit 1) to 0.9706 (digit 3), at IoU 0.5 and confidence 0.25
- Segmentation, per digit
- IoU from 0.9403 (digit 9) to 0.9656 (digit 0); background 0.9998
- Engineering
- Batch size set from available VRAM; all scenes held in RAM; early stopping with the best checkpoint reloaded
- Course
- BCO074C Minor Project, JECRC University