Worksheet Carpoolcheats
Worksheet Carpoolcheats
In this project you will make a smart traffic camera that recognizes if a
car is allowed to be in the carpool lane.
This project worksheet is licensed under a Creative Commons Attribution Non-Commercial Share-Alike License
http://creativecommons.org/licenses/by-nc-sa/4.0/
This worksheet was initially contributed by Jack Wright, from Henry Beaufort School.
You will have 30 seconds to get as many cars along the road as you can.
Cars drive at different speeds depending on which lane they are in.
medium speed
slow speed
Only cars with passengers
fast speed are allowed to use this lane
You can change lanes using the up and down arrow keys.
The yellow traffic camera is there to catch the Carpool Cheats – cars with only
a driver that try to use the bottom carpool lane!
If it catches you, you will lose points.
You probably noticed that the traffic camera isn’t very smart.
It can’t tell the difference between a car with only a driver and a car with
passengers.
In this project, you will train a machine learning model to recognise if a car has
passengers, and use this to make a smarter traffic camera.
6. Go to https://machinelearningforkids.co.uk/
10. Name your project “Carpool Cheats” and set it to learn how to
recognise “images”.
Click the “Create” button
You will use this Scratch project to collect training examples: examples of
pictures of cars with and without passengers.
You can use these examples to train the computer to recognise what a car
without passengers looks like.
22. Click on the Stage and find the prepare training labels code
23. Add blocks from your machine learning project to this code
You need to make it look like this:
25. Add blocks from your machine learning project to this code
You need to make it look like this:
This will add a picture of whatever is in front of the traffic camera to one
of the training buckets you created for your project.
You will see a series of randomly selected cars – some with passengers,
and some with only a driver.
Click on the “Driver only” or “Driver with passengers” button to add the
picture of the car to your training bucket.
28. In the training window, click on the “< Back to project” link
31. If you accidentally clicked the wrong button for any of the images,
you can remove it by clicking on the red cross
32. Once you have at least five example pictures in both training
buckets, it is time to give your model a try.
You will update it to get the traffic camera to use your machine learning model.
39. Click on the Stage and find the prepare training labels code
40. Add blocks from your machine learning project to this code
You need to make it look like this:
42. Add a block from your machine learning project to this code
You need to make it look like this:
43. Click on the capture area sprite and find the “check car” code
Move or delete the comment if it’s in your way while you update the code.
This time, your machine learning model should mean that the traffic
camera only fines cars without passengers!
This will display the results from your machine learning model when a car
goes past the traffic camera
48. If your machine learning model makes too many mistakes, more
training examples may improve it
Go back to the Scratch window with the “Carpool Cheats (train)” project
and collect another ten examples of pictures of cars.
The computer will learn from patterns in the examples you’ve given it.
These were used by the traffic camera to recognise new pictures.
Now that you’ve finished, why not give one of these ideas a try?