The Dataset Field Guide

object detection from first photo to blinking Raspberry Pi — collection, consent, labeling, balance, training, honest evaluation, and edge deployment. written around Ultralytics YOLO, true for any detector. everything on this page runs offline, right here.

collect consent label balance train evaluate deploy 🥧 the dashed road: evaluation always sends you back to collect more

1Collect like the deployment, not like the demo

A detector learns exactly the world you show it. The most common failure is a dataset that looks like your desk on a sunny afternoon, deployed into a warehouse at night. Before one photo, write down where the model will run — then collect that.

coverage check · does your plan have holes?

2Consent — the chapter people skip, and shouldn’t

Every photo of a person is a photo of a person. The craft standard: collect people only with their knowledge and agreement, minimize what you keep, strip what you don’t need.

Rules differ by country and context — this is craft guidance and kindness, not legal advice. When in doubt, photograph your own things.

consent calls · five photos, five decisions

3Label with craft — the box is the curriculum

Your boxes teach the model what an object is. Loose boxes teach it that ducks include a foot of pond. A visible-but-unlabeled object is an active lie — the model learns to ignore it, then keeps ignoring it in production.

YOLO stores one .txt per image — one object per line, normalized 0–1:

class  x_center  y_center  width  height
0      0.481     0.634     0.212  0.187
2      0.104     0.512     0.334  0.406

the IoU sandbox · box the marked subject

subject:

drag to draw a box (or focus the canvas: Enter places a box, arrows move, shift+arrows resize, Enter judges). IoU — intersection over union — scores you exactly the way evaluation will score your model.

no box yet. the subject waits, judgmentally.

4Balance — the quiet saboteur

If 90% of your instances are one class, the model becomes an enthusiast of that class and shrugs at the rest. Count instances per class early — yolo prints the table at train time, but by then you’ve already collected.

balance auditor · distribute your instances

380
260
120
25

5Train & track — dials worth touching

What the model actually is

input 640×640 backbone extracts features (edges → parts → objects) neck fuses scales small+large context head boxes + classes P3 · small things P4 · medium P5 · large

backbone → neck → head. modern YOLO is anchor-free: the head predicts box coordinates directly at three scales.

Pick a size you can afford

params and COCO mAP are approximate — the shape of the tradeoff is the lesson.
modelparamsCOCO mAP50-95who it’s for
yolov8n~3.2M~37edge devices, the Pi — start here
yolov8s~11M~45laptops, decent CPUs
yolov8m~26M~50desktop GPUs
yolov8l/x~44–68M~53–54server GPUs, when accuracy pays rent

Arguments worth touching (and leaving alone)

dialstart attouch it when…
epochs100curves still improving at the end → more; val worsens early → fewer + patience
imgsz640tiny objects → up; edge latency hurts → 320–416
batchlargest that fitsout-of-memory errors → down
patience50early-stops too eagerly on noisy small datasets → up
lr0defaultalmost never first — data fixes beat learning-rate séances
seedset onealways — reproducibility is a gift to future-you
Augmentation (mosaic, HSV shifts, flips) is on by default and sensible. Turn fliplr off if left/right matters (reading text, traffic).

Track your runs or repeat your mistakes

Loss curves and per-epoch mAP live in runs/ — but a tracker turns runs into an experiment log. Search by name: Weights & Biases (W&B — Ultralytics integrates it; enable and every run logs itself), TensorBoard, MLflow. Whatever you use, log: the dataset version, the full args, and per-class AP. The question you’ll ask in three weeks is “what changed?” — make it answerable.

Train loss falling while val mAP falls = memorization, not learning. That’s your cue for more data or earlier stopping — not more epochs.

6Evaluate — read the numbers like a skeptic

The metric is a summary; the errors are the lesson. After every run, look at the 20 worst val images — they usually indict chapter 1 or 3, not the model.
Touch the test set once, at the very end. Every early peek quietly turns it into a second validation set.

threshold explorer · one model, every confidence cutoff

a toy detector made 24 predictions on a val set with 20 real objects. slide the cutoff and watch precision buy its gains with recall’s money.

0.40

evaluation exercises · diagnose the run

7Deploy — the Raspberry Pi 4 road

The main road of this guide: train on your PC, shrink, and run on a Raspberry Pi 4 (4GB). It has no neural accelerator — just four honest ARM cores — which makes it the perfect teacher: every millisecond you save, you understand.

train on PCyolov8n exportNCNN / ONNX copy to Pi64-bit OS saved images firstoffline test cameraUSB / CSI measureshrink until fast

The beginner walkthrough

  1. Train small, elsewhere. yolov8n, your dataset, on your PC or a free cloud notebook. The Pi is for running models, never training them.
  2. Validate before you ship. yolo val — check per-class AP, not just the average.
  3. Export for ARM: yolo export format=ncnn imgsz=320 — NCNN is the ARM-CPU specialist. (ONNX is the portable fallback.) Export at the size you’ll run.
  4. Prepare the Pi: 64-bit Raspberry Pi OS, then install the Ultralytics package. A fan or heatsink keeps the cores from throttling mid-demo.
  5. Test offline first. Run detection on 20 saved photos and eyeball every output — before any camera, network, or audience is involved.
  6. Then attach the camera and time it honestly: milliseconds per frame, averaged over a minute, box drawn on screen.
  7. Too slow? In order: drop to imgsz=320 → skip frames (detect every 3rd) → INT8 quantization → and only then, exotic hardware.

Export formats — the comparison

All exports come from one command — yolo export format=… — but they are not interchangeable citizens. On the Pi road the choice that matters most is NCNN vs ONNX:

Pi 4 speeds are ballpark relative figures for orientation (NCNN = 1×) — measure on your own bench.
formatbest onPi 4 CPU speedwhy you’d choose it
ncnnARM CPUs (the Pi)~1× · fastest herehand-tuned ARM kernels; the Pi specialist. Less tooling elsewhere.
onnxalmost everywhere~1.3–1.6× slowerthe portable interchange — one file, many runtimes (ONNX Runtime), easiest Python, the right default when you don’t know your final hardware yet.
tflitephones, MCUs~1.2–1.5× slowerwhere INT8 quantization lives; the road to NPUs and microcontrollers.
.pt (raw PyTorch)your training PC~2–3× slowerzero export friction, worst edge speed — fine for the saved-images test, not for the demo.
tensorrt · coreml · openvinoNVIDIA · Apple · Inteln/a on Pivendor specialists — huge wins, only on their own hardware.
The practical rule: export onnx the moment training ends (your portable insurance copy), then export ncnn specifically for the Pi. Same weights, two costumes — compare them yourself in the demo below.

Quantization — smaller numbers, faster math

FP32 · 4 bytes/weight · full accuracy · training default FP16 · half the size · ~free accuracy-wise · easy first step INT8 · quarter size · ~1–3 mAP cost · needs calibration images · mandatory on NPUs
INT8 calibration wants a few hundred representative images — your val set’s cousins, not random noise. Bad calibration is where INT8 accuracy quietly dies.

The hardware, honestly compared

latency figures are ballparks for orientation, not benchmarks — measure on your own bench.

Raspberry Pi 4 · 4GB the main road
brain
4× Cortex-A72 @ 1.5GHz · no NPU
memory
4GB RAM — roomy; the model is the least of it
realistic model
yolov8n · imgsz 320–640
ballpark latency
~150–300ms @320 · ~0.5–1s @640 (NCNN, CPU)
export path
NCNN (best) or ONNX · FP32 fine, INT8 helps
best for
learning deployment end-to-end; full Linux, real Python, easy debugging
Grove Vision AI V2 the specialist
brain
Himax WiseEye2 · Cortex-M55 + Ethos-U55 NPU
memory
megabytes, not gigabytes — the model must be tiny
realistic model
quantized yolov8n-class @ 192–256px
ballpark latency
~40–80ms — the NPU earns its keep
export path
TFLite INT8 mandatory, compiled for the NPU (SenseCraft flow)
best for
fast inference on coin-cell power; less flexible, more magical
ESP32-S3 the ascetic
brain
2× LX7 @ 240MHz · SIMD, no NPU
memory
~512KB SRAM + up to 8MB PSRAM
realistic model
full YOLO does not fit. micro-models (FOMO-class) @ 96×96
ballpark latency
~200–600ms for micro-models, INT8 only
export path
TFLite Micro / ESP-DL · INT8 mandatory
best for
presence/counting on a few dollars; honesty about limits required

safe offline demo · simulated inference, no camera

a simulation — no camera, no network, no real model. it renders a scene, “detects” your subject with device-appropriate wobble, and quotes the ballpark latency. the concepts are real; the ducks are drawings.

Where to go from here — search by name (names age better than links): Ultralytics YOLO docs (“Raspberry Pi” and “NCNN” guides), Label Studio / CVAT for annotation, Weights & Biases for tracking, Edge Impulse for the microcontroller road, and the COCO paper for where the metrics were born.