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

A good image dataset.

A model is only as good as the photos it learns from. Here you'll see the mistakes people make when they take them and how to avoid them, from the snow behind the wolves to the test photos that must never be shown.

What you learn
  1. Why a model also learns things you didn't mean to teach it
  2. How to choose the variety and the number of photos for each class
  3. Why you need a class that says there's nothing there
  4. How to split the photos without inflating the result
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 Shortcuts

    The model learns everything you show it.

    In 2016, three researchers deliberately trained a model to tell wolves from huskies, with the wolves always on snow. The model seemed good. In reality it was looking at the snow, not the animal. Learning a detail that comes along with the answer, instead of the answer itself, is called a shortcut. If all your mugs are in the kitchen, the model might learn the kitchen.

    In practice. Look at all the photos of a class together. If they share something that isn't the object, like the background or the light, the model will use it.

01 / 07
(Go deeper)

A few more numbers.


(01)

How many photos you really need

There's no right number for every problem. With a body that's already trained, you start from 20 or 30 photos per class and look at where the model gets it wrong. Classes that look alike, like two olive varieties, need many more photos than two different objects like a mug and keys.

The honest way to find out is to measure. Train with 10, 20, 40 and 80 photos per class, and each time write down the accuracy on the test photos. If the curve is still going up, you need more photos. If it has flattened out, the problem is somewhere else, usually in the variety or in the labels.

(02)

A mistake that made it into journals

In 2021 a team at the University of Cambridge reviewed 62 studies that used artificial intelligence to spot COVID in chest X-rays and CT scans. None of them was ready for a hospital. One of the most common reasons was the data itself.

In some studies the images of healthy people came from an archive of children, so the model learned to recognize children instead of the disease. In others the same images showed up both among the ones for learning and among the test ones. Those are the shortcut and the data leakage from this lesson, made by expert researchers.

  • 62studies reviewed
  • 0ready for clinical use
(03)

Labels make mistakes too

In 2021 a team at MIT looked for label errors in ten famous datasets. Among the 50,000 test photos of ImageNet they found almost 3,000 with the wrong answer, about 6 percent. A dog marked as another kind of dog, an object with the name of the one next to it.

In your dataset the mistakes are easier to find, because you took the photos yourself. But they do happen, especially when you collect in a hurry. A photo in the wrong class teaches the model the very mistake you want to avoid.

(Try it on your phone)

The dataset check


Open the photos you took in the lab, or a gallery folder with photos for a problem of your own, and check these points one by one.

  1. (01) Every class has at least 20 photos
  2. (02) The biggest class has no more than twice as many photos as the smallest one
  3. (03) Every class was photographed in at least four different places
  4. (04) There's a nothing class, with varied backgrounds and objects that look like yours
  5. (05) You removed the duplicates and the photos that ended up in the wrong class
  6. (06) The test photos come from a separate session

Fix the missing points before you train again. It almost always improves the model more than any setting does.

(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)

    All the mugs are photographed in the kitchen, all the keys on the couch. What might the model learn?

  2. (02)

    You have 180 photos of mugs and 20 of keys, and the model has 90 percent accuracy. What do you check?

  3. (03)

    Why should the test photos come from a separate session?

  4. (04)

    Which change is a bad idea for augmenting the data of a model that reads digits?

To close the lesson, answer the quiz

← Classifying a photo Back to the map
(Next lesson · 02.03) Finding objects