Object Detection Model Training
A YOLOv8n model trained from scratch — not a pretrained checkpoint — on a self-assembled ~30,000-image dataset covering fire, person, and smoke detection.
What was asked
Collect a sufficient number of images for training and testing an object-detection model using TensorFlow, OpenCV, or YOLO. Training your own model is required — using a pre-existing model is explicitly not sufficient.
Dataset
Sourced and assembled via Roboflow: fire-and-person-surveillance-detection (version 2), 3 classes.
| Split | Images | fire | person | smoke |
|---|---|---|---|---|
| train | 21,831 | 4,773 | 73,646 | 336 |
| valid | 5,488 | 663 | 20,966 | 173 |
| test | 2,441 | 237 | 10,840 | 37 |
| total | 29,760 | 5,673 | 105,452 | 546 |
The class distribution is heavily imbalanced — person instances outnumber smoke roughly 193:1 — which is a plausible explanation for smoke's lower recall (see below).
Training pipeline
| Parameter | Default | Description |
|---|---|---|
EPOCHS | 300 | maximum training epochs |
IMG_SIZE | 640 | input image size |
BATCH | 16 | batch size |
PATIENCE | 50 | early-stopping patience |
LR0 / LRF | 0.01 / 0.1 | initial / final learning rate |
train/train.py downloads the dataset, trains YOLOv8n with early stopping, and
exports the best weights to ONNX. detect/detect_webcam.py runs live webcam
inference with an FPS overlay for local testing before deployment to the Hailo accelerator
(see the Inference node). Device selection auto-detects
CUDA → Apple MPS → CPU.
Results
- Precision (84%) — of all boxes the model predicts, 84% are correct.
- Recall (70%) — of all actual fire/person instances present, the model catches about 70%; roughly 30% are missed.
- mAP@50 (77%) — mean average precision at a loose 0.5 IoU threshold: a detection only needs to roughly cover the object to count as correct.
- mAP@50-95 (49%) — the same metric at much stricter overlap thresholds. The gap versus mAP@50 shows the model reliably finds objects but doesn't always draw tight boxes — typical for the nano-sized YOLOv8 variant chosen for edge inference.
Per-class breakdown
| Class | Images | Instances | Precision | Recall | mAP@50 | mAP@50-95 |
|---|---|---|---|---|---|---|
| all | 5,488 | 27,289 | 0.842 | 0.697 | 0.772 | 0.493 |
| fire | 1,060 | 1,667 | 0.799 | 0.704 | 0.757 | 0.428 |
| person | 3,834 | 24,799 | 0.902 | 0.755 | 0.843 | 0.604 |
| smoke | 715 | 823 | 0.824 | 0.633 | 0.718 | 0.447 |
smoke has the lowest recall (63%) and mAP@50-95 (0.447) of the three classes —
consistent with it being by far the most underrepresented in training (546 instances vs.
105k for person). fire performs closer to the class average despite
also being a minority class.
Deployment target
The trained model is exported to ONNX and compiled for the Hailo-8L accelerator that powers the inference node — a Pi 5 + Hailo AI HAT+ pairing that runs real-time inference on the sensor node's MJPEG stream and reports detections to the backend (Task 7).