Class 10 · Unit 4: Computer vision · Lesson 4.3 · 40 min
A no-code image classifier
Your sorter is 100% right on the table. Move it to the floor and it falls apart. What did it really learn?
Today you will: Train a three-class smart sorter · Test it honestly on new photos · Catch a model learning the wrong thing
Story
Rahat's group builds a waste sorter for the school canteen: plastic, paper, food. They photograph everything on the white table in the lab, train it, and test it. Perfect. Every photo right.
On Monday they take it to the canteen. Gul Kaka drops a plastic bottle on the steel counter.
Paper, says the screen.
He tries a chapati. Plastic.
Rahat: “It worked on Friday.”
Hiba looks at their training photos. Every plastic bottle is on the white table. Every scrap of paper is on Rahat's brown notebook.
Hiba: “It didn't learn plastic. It learned the table.”
Watch
Build a sorter, then break it — — scan code 10.4.3 in the printed book.
Learn it
A no-code tool can train an image classifier in minutes, from labelled photos. But a model learns whatever separates the classes in its photos: if every plastic bottle sits on a white table and every paper scrap on a brown notebook, the easiest pattern is the background, and it learns that instead. This is learning a shortcut. Testing on new photos, in new places, is how you catch it.
Words to know
- No-code vision tools CBSE names Teachable Machine, Lobe and Orange (with its image add-on).
- Class one category the model sorts into, like plastic, paper or food.
- Shortcut a pattern that separates the classes in the training photos but has nothing to do with the object: a background, the lighting, a ruler in the photo.
- 3 × 3 confusion matrix for three classes: actual classes down the side, predicted across the top, nine boxes in all.
- Varied training photos the same objects on different backgrounds, in different light, at different angles, so the object is the only thing a class has in common.
Step by step: catching a shortcut in a leaf sorter
A sorter for healthy / scab leaves scores 100% on its training photos.
- Look at the training photos first: every healthy leaf was photographed in sunlight; every scab leaf indoors, under a tube light.
- Guess the shortcut: the model may have learned bright = healthy, yellowish = scab.
- Test on new photos: healthy leaves photographed indoors. The model calls them scab.
- Build the confusion matrix: most mistakes are healthy-called-scab, all from indoor photos. The pattern of mistakes points straight at the shortcut.
- Fix it: add healthy leaves photographed indoors and scab leaves in sunlight, retrain, and test the same photos again.
Careful: more photos do not always fix a shortcut. More of the same white-table photos makes it stronger. Vary the background, the light and the place on purpose, so the only thing the photos share is the object.
On the laptop
You need: Teachable Machine (online) · LibreOffice Calc · the photo sets in datasets/sorter/
Mission 1: Train it (10 min, in groups of 3–4)
- ☐1
Teachable Machine → Image Project → Standard. Make three classes:
plastic,paper,food. - ☐2
Upload the photos from
datasets/sorter/train/— about 15 per class. Look at them first: where was each class photographed? - ☐3
Press Train. Test it with one training photo from each class. It should be very sure.
Mission 2: Test it honestly (12 min)
- ☐4
Predict: on photos taken somewhere else, how many out of 9 will it get right? Write it down.
- ☐5
Test each photo in
datasets/sorter/test/— 9 photos, 3 per class, on a different background. Record actual and predicted for each in Calc. - ☐6
Build the 3 × 3 confusion matrix: actual down the side, predicted across the top. Count how many are right.
Mission 3: Fix it (6 min)
- ☐7
Add the photos in
datasets/sorter/mixed/to training — the same objects on floors, counters and hands. Retrain, and test the same 9 photos again. What changed?
Finished early?
Hold up something that is none of the three — your pencil box. What does the model say, and how sure is it? What should a sorter do with things it doesn't know?
No laptop today?
Your teacher shows the training photos and the test photos side by side on one screen. Pairs predict what the model will say for each test photo and why. Then look at the shortcut figure in Learn and find what every photo in each class has in common.
Debate it
Real companies have found their vision models learning shortcuts: skin-disease models that had learned what a ruler in the photo meant, because doctors photographed worrying moles with a ruler beside them.
- Why is a shortcut so hard to spot from the model's accuracy alone?
- What would you check before trusting a vision model trained somewhere far from Kashmir?
Check yourself — practice, not a test
1. A sorter is perfect on its training photos and poor on new ones. The most likely reason is:
- ○ The camera was too good
- ○ It learned something other than the object, like the background
- ○ It had too many classes
- ○ Teachable Machine is broken
2. Adding training photos with different backgrounds can help a model learn the object instead of the table.
- ○ True
- ○ False
3. A confusion matrix for three classes is a ______ × 3 table.
4. Which are no-code tools CBSE lists for computer vision? (choose all that apply)
- ○ Teachable Machine
- ○ Lobe
- ○ Orange Data Mining
- ○ Thonny
5. Put the steps in order:
- 1. Make a class for each category
- 2. Train the model
- 3. Add labelled photos to each class
- 4. Test it on photos it has never seen
Remember
A model learns what the pictures have in common — make sure it's the right thing.
Typing practice
Skill: short labels, fast and exact (5 min)
-
On typing.com: the lesson your teacher sets.
-
Type three times, eyes on the screen:
classes = ["plastic", "paper", "food"] # three classes -
Goal this term: 38–44 WPM at 95%.