Students learn how computers can process and categorize images. They program and train a computer to recognize certain images and teach it to play Rock, Paper, Scissors.
- Explore how computers can be trained to recognize pictures
- Create a Rock, Paper, Scissors game in Scratch
- Facial recognition: A computer’s ability to identify a face or an object
- Detection: A computer’s process of finding a face within an image
- Mapping: A computer’s ability to make a connection between two sets of things or “variables”
- Analysis: A computer’s process of “mapping” a face
- Recognition: A computer’s process of confirming the identity of an individual or object in an image
Ontario (Grades 7-8)
- A2. Coding and Emerging Technologies
- A2.1: write and execute code in investigations and when modelling concepts, with a focus on producing different types of output for a variety of purposes
- A2.2: identify and describe impacts of coding and emerging technologies on everyday life, including skilled trades
- A3. Applications, Connections, and Contributions
- A3.1: describe practical applications of science and technology concepts in various occupations, including skilled trades, and how these applications address real-world problems
- A3.2: investigate how science and technology can be used with other subject areas to address real-world problems
Task 1: Introduction to Facial Recognition
What is facial recognition? Where is it used? Facial recognition is the ability of a computer to identify a face or an object when it is compared to a database. There are many different ways a computer might process facial recognition and it can be sorted into three basic types of technological process: detection, analysis, and recognition.
Detection is the process of finding a face within an image. For example, have you ever used your phone camera and seen a box appear around a face? That’s an example of the computer recognizing a face to know where the expected subject of the photo is so it can focus on it.
Analysis is the computer’s process of “mapping” a face. This entails the computer calculating the placement and distance between different aspects of a face, such as eyes, nose, and mouth. You may have seen this type of technology in use in apps like Snapchat, where you can use different facial filters on your face when using the camera.
Recognition is the computer’s process of confirming the identity of an individual or object in a photo. You have seen this in use if you have ever used facial recognition to unlock your phone or other device. This is similar to the technology we will use to create the game in the next activity.
Task 2 – Creating a Rock, Paper, Scissors game
Now that we have learned about the different types of technology that process facial recognition, we are going to create a program that recognizes hand shapes so we can play Rock, Paper, Scissors with the computer. This task will entail taking multiple pictures with a computer or phone.
Step 1: Go to the Machine Learning For Kids website. Click get started, then click Try it now.
Step 2: Click on the Projects bar at the top of the page, then click Add new project.
Step 3: Under Project Name, write Rock, Paper, Scissors and under Recognising, set it to images, then click Create. It will create a Rock, Paper, Scissors project under the list of projects.
Step 4: Teach the computer hand gestures so it can play the game. Click on the Train button.
Step 5: Click on the Add new label button at the top right corner of the screen. Name this label Rock. Now click on the Webcam button in the rock box. Take at least 10 different pictures of your hand in the gesture of “rock”. Take pictures from different angles so the computer can recognize what “rock” looks like in different formations.
Step 6: Once you are finished, go back to Add new label and repeat step 5 for “paper” and “scissors.”
Step 7: Teach the computer to recognize the hand gestures. At the top left corner, click Back to project, then click Learn & Test.
Step 8: Click on Train new machine learning model. This may take a few seconds.
Step 9: Once the training is complete, click Test with webcam to see how well the computer recognizes “rock”, “paper,” and “scissors”. The confidence score will tell you how well the computer has recognized the hand gestures.
If you want to repeat the process, select Go back to project and Train the computer again by adding more images to your three sections.
Step 10: Once a desired confidence level of 70% is achieved, click Make to open the Scratch interface. Click Scratch and read the instructions carefully.
Step 11: The browser will now open to Scratch 3. In the top menu, click on Project templates and search or scroll for your Rock, Paper, Scissors template.
Step 12: A set of scripts will appear on your screen—do not delete them! Click on the You sprite as highlighted at the bottom right of the image below.
Step 13: Now update the script with project blocks that are under the green flag to look like the script below.
Step 14: Now update the script with the project blocks under New-move to look like the script below.
Step 15: It’s time to play Rock, Paper, Scissors with the computer. Click on the green flag and press the letter P on your keyboard to take a photo. The computer will choose a random move to play; either rock, paper, or scissors.
Now you have your virtual AI buddy to play Rock, Paper, Scissors with. Best of three wins!
Great job! We just learned how to teach a computer to develop intelligence, recognize images, and play the game Rock, Paper, Scissors!
- What are some things you noticed from this activity?
- How long did it take for the computer to understand what you were showing on the screen properly?
- What are some ways facial recognition might have positive or negative effects on daily life?