Task 6

Object Detection Model Training

ai-model/

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.

SplitImagesfirepersonsmoke
train21,8314,77373,646336
valid5,48866320,966173
test2,44123710,84037
total29,7605,673105,452546

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

ParameterDefaultDescription
EPOCHS300maximum training epochs
IMG_SIZE640input image size
BATCH16batch size
PATIENCE50early-stopping patience
LR0 / LRF0.01 / 0.1initial / 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
0.843
Recall
0.695
mAP@50
0.772
mAP@50-95
0.493
  • 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

ClassImagesInstancesPrecisionRecallmAP@50mAP@50-95
all5,48827,2890.8420.6970.7720.493
fire1,0601,6670.7990.7040.7570.428
person3,83424,7990.9020.7550.8430.604
smoke7158230.8240.6330.7180.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).