0% found this document useful (0 votes)
4 views15 pages

Worksheet Carpoolcheats

The document outlines a project to create a smart traffic camera that can identify whether cars in the carpool lane have passengers. It involves training a machine learning model using images of cars with and without passengers, which will be used to improve the camera's accuracy in detecting carpool lane violations. The project includes steps for setting up the Scratch programming environment, collecting training data, and testing the model's performance.

Uploaded by

23301493abcdefgh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views15 pages

Worksheet Carpoolcheats

The document outlines a project to create a smart traffic camera that can identify whether cars in the carpool lane have passengers. It involves training a machine learning model using images of cars with and without passengers, which will be used to improve the camera's accuracy in detecting carpool lane violations. The project includes steps for setting up the Scratch programming environment, collecting training data, and testing the model's performance.

Uploaded by

23301493abcdefgh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Carpool Cheats

In this project you will make a smart traffic camera that recognizes if a
car is allowed to be in the carpool lane.

You will teach the computer to recognise whether there are


passengers in the car by giving it examples of pictures of cars with and
without passengers.

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.

Page 1 of 15 Last updated: 31 July 2023


1. Go to https://scratch.machinelearningforkids.co.uk

2. Click on the Project templates menu

3. Click on the “Carpool Cheats (test)” project

4. Click on the full-screen button

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

Cars always start in the middle, slow lane.

You can change lanes using the up and down arrow keys.

Use the up arrow for cars with only a driver.


Use the down arrow for cars with passengers.

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.

Page 2 of 15 Last updated: 31 July 2023


5. When you are ready to try the game, click on the Green flag

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.

It gives a fine to every car that goes past!

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/

7. Click on “Get started”

8. Click on “Try it now”

9. Click the “+ Add a new project” button.

10. Name your project “Carpool Cheats” and set it to learn how to
recognise “images”.
Click the “Create” button

Page 3 of 15 Last updated: 31 July 2023


11. You should now see “Carpool Cheats” in the list of your projects.
Click on it.

12. Click the Train button

13. Click on “+ Add new label”

14. Call your first label “passengers”


This will be where you store examples of pictures of cars with passengers

Page 4 of 15 Last updated: 31 July 2023


15. Do that again, and create a second bucket called “no passengers”.
This is where you will store examples of pictures of cars with only a driver

16. Click on the “< Back to project” link in the top-left

17. Click on the “Make” button.

18. Click on the “Scratch 3” button

19. Click on the “straight into Scratch” button


The page is warning you that you don’t have a machine learning model
yet. That is okay, as you will be using Scratch to collect training pictures
and use them to train your machine learning model.

Page 5 of 15 Last updated: 31 July 2023


20. Click on the Project templates menu

21. Click on the “Carpool Cheats (train)” project


This is a different project to the one you used before!

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:

Page 6 of 15 Last updated: 31 July 2023


24. Click on the capture area sprite and find the “check car” code

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.

Page 7 of 15 Last updated: 31 July 2023


26. Click on the full-screen button

27. Click on the Green flag


It’s time to train!

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.

Collect pictures of about ten cars

28. In the training window, click on the “< Back to project” link

29. Click the Train button

Page 8 of 15 Last updated: 31 July 2023


30. Look at the training pictures that you’ve collected

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.

33. Click on the “< Back to project” link

34. Click on the “Make” button.

35. Click on the “Scratch 3” button

Page 9 of 15 Last updated: 31 July 2023


36. Click on the “straight into Scratch” button
This will open another, different, Scratch window.
Having two Scratch windows means you can use one for training, and one
for testing.

37. Click on the Project templates menu

38. Click on the “Carpool Cheats (test)” project

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:

Page 10 of 15 Last updated: 31 July 2023


41. Find the “when Green flag clicked” code (still on the Stage)

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

Page 11 of 15 Last updated: 31 July 2023


44. Add blocks from your machine learning project to this code
You need to make it look like this:

Move or delete the comment if it’s in your way while you update the code.

45. Click on the full-screen button

46. Click on the Green flag


It’s time to test!

Play the game as you did before.

This time, your machine learning model should mean that the traffic
camera only fines cars without passengers!

Page 12 of 15 Last updated: 31 July 2023


47. If you want to see what your machine learning model is doing, tick
the “camera label” and “camera confidence” variables

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.

Page 13 of 15 Last updated: 31 July 2023


What have you done?

You’ve trained a computer to recognise a picture of a car as having


passengers or no passengers. Instead of trying to write rules to be able to
do this, you did it by collecting examples. These examples were being
used to train a machine learning “model”.

The computer will learn from patterns in the examples you’ve given it.
These were used by the traffic camera to recognise new pictures.

Page 14 of 15 Last updated: 31 July 2023


Ideas and Extensions

Now that you’ve finished, why not give one of these ideas a try?

Or come up with one of your own?

Add more vehicle types

We made it easy for your smart camera by making all vehicles


very similar – they were all cars of the same shape and style.

Try adding more vehicle types (such as different shape cars,


but also busses, motorbikes, and lorries) by adding additional
costumes to your “car” sprite, and see what that does to your
project.

Page 15 of 15 Last updated: 31 July 2023

You might also like