Guides · Architecture
How YOLO object detection works, explained simply for developers.
A plain-English guide to YOLO: what object detection is, bounding boxes, confidence scores, non-max suppression, model sizes.
Key takeaways
- YOLO ("You Only Look Once") finds and labels objects in an image in a single pass of a neural network.
- The output is a set of boxes, each with a class, such as "car", and a confidence score.
- Thresholds decide which detections to keep. Too low gives false alarms, and too high misses real objects.
- A detector tells you where objects are. It does not know distance or danger.
What object detection is
Image classification says what is in a picture. Object detection goes further: it finds each object, draws a bounding box around it and gives it a label. A frame from a road video might produce boxes for a car, a truck and a person.
The idea behind YOLO
Older detectors first proposed regions and then classified each one, in two stages. YOLO treats detection as one task: the network looks at the whole image once and directly predicts boxes and classes. This made detection fast enough for video.
The details differ by version, but the shape of the output is the same: a list of detections with coordinates, class and confidence.
What a detection contains
- Box: position and size, such as centre x, centre y, width and height.
- Class: one of the categories the model was trained on.
- Confidence: a number from 0 to 1, how sure the model is.
Confidence threshold
You choose a minimum confidence, such as 0.25 or 0.5. Lower values catch more objects but add false positives. Higher values are cleaner but miss faint or small objects. Tune this on your own footage.
Non-maximum suppression
A model may draw several overlapping boxes around one object. Non-maximum suppression (NMS) keeps the best box and removes others that overlap it too much, measured by intersection over union (IoU). Some newer designs reduce or remove this step, but you will still often meet the concept.
Model sizes
YOLO families come in sizes, typically labelled nano, small, medium, large and extra-large. Smaller models run faster and use less memory but are less accurate. Larger ones are more accurate but need a good GPU for real-time video. Pick the smallest size that meets your accuracy needs.
Pretrained and custom models
Pretrained models know common classes, such as people, cars, bicycles and animals, from a large public dataset. For anything specific, such as a particular product or plate, you can fine-tune with your own labelled images. Data quality matters more than quantity: varied lighting, angles and backgrounds.
Video
For video, run detection on each frame, or every few frames, and optionally track objects between frames so each keeps an identity. Processing speed depends on resolution, model size and hardware. FFmpeg is often used to read and write frames. See FFmpeg commands.
What a detector cannot tell you
A box in a flat image is not a distance. Judging "how close" or "how dangerous" needs extra rules or sensors. In R.A.S, I used a simple rule based on box size to colour overlays, which is a rough guide and not a safety system. The case study lists weaknesses I found in it.
Common problems
- Small or far objects missed.
- Night or motion blur.
- Class confusion between similar objects.
- Different results between image sizes.
- Training data that does not match real use.
Frequently asked questions
Is YOLO free?
Several versions are open source, but licences differ. Check the licence before using it in a product.
Do I need a GPU?
For real-time video, usually yes. For single images or slow processing, a CPU may be enough.
How do I measure accuracy?
Use metrics such as precision, recall and mean average precision on a labelled test set from your own domain.
R.A.S uses YOLOv8 to find vehicles, people and animals in ride footage.
See R.A.S