Train a picture model in the Pattern Trainer, then test it on photos it has never seen. It works on photos like its training photos and fails on others, so to fix a model you change its data.
Recycling centres use cameras and trained models to sort paper from plastic on a fast conveyor belt. Before a centre trusts one, someone has to test it on items it has never seen.
A recycling centre wants a camera that sorts Paper from Plastic. You will train a model in the Pattern Trainer, then test it on the board's photos: paper and plastic items your model has never seen, in different places and light.
To train a model: open the Pattern Trainer in a new tab and choose Pictures. Name the first class Paper, then + Add a class and name it Plastic. Add about 20 photos of each (hold the item up to the camera and Hold to record, or Upload photos), and click Train model. Then click Download my_model.json, and on the board click Open your model file and choose it.
No webcam, or no paper and plastic on your desk? Download photos to upload instead (unzip them, then in each class choose Upload photos and select every photo in its folder): plain photos and varied photos.
Make your prediction first. Help opens once you've locked it in.
Train Paper and Plastic with about 20 photos each, all on the same plain desk (or upload the plain photos). Download your model and Open your model file on the board. Compare the plain background and messy bench scores.
Train two classes (Paper and Plastic) on one plain background, open your model file and test it.
Use the board. This ticks when you get there.
Accuracy is the number correct divided by the number tested. A score for each group of test photos (plain, messy, low light) shows where a model fails, not just how often.
To find what is wrong, look at the ✗ photos and ask what they have in common that is not the item: the background, the light, the angle. Then compare that with the training photos.
| Step | What to write | Why |
|---|---|---|
| 1 | overall = 23 ÷ 32 = 72% | Accuracy is correct ÷ total |
| 2 | plain 8/8, messy 4/8, low light 5/8, neither 0/8 | Groups show where it fails |
| 3 | The messy failures all have a cluttered background | Look for what the failures share |
| 4 | The training photos were all on one plain desk | The model can't tell item from background |
| 5 | Fix: add training photos on cluttered backgrounds | Change the data, not the settings |
Same model, different results: it fails only in low light. Work through steps 3 to 5 for it.
A model gets 23 of 32 test photos right. What is its accuracy, as a percentage (to the nearest whole number)?
Retrain your model with photos of the items on at least three different backgrounds (or upload the varied photos). Download it again and open the new file on the board.
Look at the not paper or plastic group: the model gives a can or a jar a label anyway, often with high confidence. A model always picks one of its classes. Add a third class called Neither with photos of other things (cans, glass, fruit), retrain and test again.
Retrain with photos on at least three different backgrounds. Get the messy bench to 75% or more.
Use the board. This ticks when you get there.
The model labels a can or a bottle of glass as paper or plastic. Add a Neither class and get the 'not paper or plastic' group to 75% or more.
Use the board. This ticks when you get there.
Use what you found: varied backgrounds and light, balanced classes, and a Neither class. Then ask a classmate to bring three items your model has never seen. Does it still work?
Build a sorter that gets 80% or more overall and 75% or more in low light.
Use the board. This ticks when you get there.
Write one or two sentences: which items or conditions your sorter would still get wrong, and what a real recycling centre would need to test before trusting it.
Revision summary
Lesson done. You've finished every step you need.
Students train a Paper/Plastic picture model in the Pattern Trainer, test it on photos it has never seen, and fix it by changing the training data. About 50 minutes.
Open the teacher guide: answers, solutions, slides and a worksheet.
The idea: a model learns only from the examples it is given. It works on new inputs that look like its training photos and fails on ones that don't. The fix is always in the data, not the settings.
How it works: students train in the Pattern Trainer (tools.learningwaypoints.com/trainer/, free, no account), click Download my_model.json, and open that file on the board with Open your model file. The board keeps it in the browser, so the next lessons start with it. The board tests the model on 40 fixed photos it has never seen, in five groups: plain background, messy bench, low light, crumpled or at odd angles, and things that are neither paper nor plastic. Checks tick on the board's scores, not on the training.
Before class: on a student laptop on the school network, open the Pattern Trainer, train a tiny model, download it and open it on the board. The trainer and the board each load about 35 MB from tools.learningwaypoints.com the first time, so check the network allows it. Bring a box of clean paper and plastic (and a few cans, jars or fruit) so every desk has variety.
Privacy: training happens in the browser and photos never leave the computer (the trainer's Privacy page shows how to check). my_model.json holds class names and numbers, no photos, and stays on the student's computer. Train on objects, not faces.
Teachable Machine still works: a student who trains there can export with Upload my model and paste the link into the box under Open your model file. Its webcam is mirrored; the Pattern Trainer's is not.
No webcam? The lesson links two folders of photos to upload instead: plain (30 per class on a white board: trains the biased model) and varied (messy benches, low light, odd angles and a Neither class: trains a good one). The photos come from TrashNet (MIT licence); the messy benches and low light are made from them.
The test photos are similar in style to the downloadable ones, so a model trained only on the varied folder can do well without the webcam. That is fine: the point is what changes the scores.
Accepting that a model trained on one desk fails on a messy bench. Ask what the test photos have that the training photos don't, before adding more data.
Stretch: Add a fourth class (Cardboard or Glass). Which pairs of classes does the model mix up most, and why?
Support: Use the downloaded photos instead of the webcam: plain first (the biased model), then varied.
Next: send the model's labels to a micro:bit that sorts with a servo flap.
Real world: automated recycling sorters, and any camera system tested on people or places it wasn't trained on (who might it fail for?).