Go to Map Courses Lab Glossary How it works Troubleshooting Start →
ITEN
← Course 02 · Seeing (Lesson 02.03 · 20 minutes · Camera · First model)

Finding objects.

Counting the apples on the table means finding them one by one. Here you'll follow a detector from the YOLO family, from the thousands of boxes it proposes to the few that are left, and try the one that runs on your phone.

What you learn
  1. How a model describes an object with a box and four numbers
  2. What IoU measures and why it helps remove duplicates
  3. What resolution costs and what you lose when you lower it
You need to know

If you don't remember one of these, the link takes you to the chapter that explains it.

How do you want to follow it
Preparing the scene…
  1. 01 The question

    What's there, and where it is too.

    On the table there are three apples and a mug. Classifying the photo isn't enough anymore, because there are many answers and each one has its own place. Detection01.04 finds every object, gives it a class and puts it inside a box. Counting the apples gets easy, you just count the boxes.

    In practice. If you only need to know whether something is there, classifying is simpler and faster. Detection is for when it matters where things are or how many there are.

01 / 07
(Go deeper)

A few more numbers.


(01)

The YOLO family

Joseph Redmon presented YOLO in 2016. The detectors of the time looked at the photo thousands of times, one piece at a time, and took seconds. YOLO looked at it only once and reached 45 frames per second on a computer GPU.

Since then many versions have come out, written by different teams. Ultralytics distributes YOLOv8 and the versions after it in five sizes, from nano to extra large. Check the license before you use them in a product, because it's the AGPL and it asks you to publish your own code too. The detector you can try below is EfficientDet-Lite0 from Google, with an Apache license.

  • 3.2 Mweights in YOLOv8 nano
  • 8.7 Goperations per photo at 640 pixels
  • 37.3mAP on COCO, the score for detectors
(02)

How you score a detector

A box counts as right if it has the right class and an IoU of at least 0.5 with the one drawn by hand. Then for each class you look at two things. How many of the model's answers are right, and how many of the real objects the model found. When you raise the confidence threshold, the first goes up and the second goes down.

You try every threshold and take the average, first for each class and then across the classes. The result is called mAP, mean average precision. The COCO dataset makes the score stricter and also averages over ten IoU thresholds, from 0.5 to 0.95.

(03)

COCO, the 80 starting classes

Almost all ready-made detectors are trained on COCO, a dataset published by Microsoft in 2014. It has 80 classes of common objects, like person, bicycle, cup and fork, and more than 200,000 photos with boxes drawn by hand.

If your objects are among those 80 classes, you can use a ready-made model. If not, you train it again on your own photos, starting from the weights it already learned on COCO. Here, though, taking photos isn't enough. On every photo you have to draw a box around each object, and that work is the longest part.

(Try it on your phone)

Live detector


Point the camera at the table or the room. A detector already trained on the 80 COCO classes draws the boxes live, with the class and the confidence. With the slider you change the threshold and see which boxes are left.

The tool needs JavaScript turned on.

The model downloads only once, then it works in airplane mode too. The camera images stay on your phone. Try counting small objects from far away and then up close.

(Quiz)

4 questions to close the lesson.

When you have answered them all, the lesson counts as done and its stone on the map turns yellow. Answering is what counts, not the score.


  1. (01)

    What does detection add compared to classification?

  2. (02)

    Two boxes match perfectly. What is their IoU?

  3. (03)

    Three boxes are left on the same apple. What reduces them to one?

  4. (04)

    You go from 640 to 320 pixels. What happens?

To close the lesson, answer the quiz

← A good image dataset Back to the map
(Next lesson · 02.04) Cutting out pixel by pixel