Scratch Advanced
Scratch Advanced
Scratch
Advanced
3-1
A.M P.M
Sessions 1~3/6 sessions in total Time
O
Unit
Experience
01 the Teachable Machine
The data collection stage We train machine learning You can use the preview
is t he most basic and model based on the collected window to evaluate whether
important stage of creating ▶ data. On a teachable machine, ▶ the machine learning model
an machine learning model. you can train the model you works properly.
want to create without any
special programming.
Go to https://teachablemachine.withgoogle.com
02
03
04
08
09
What kind of program should we make?
Let’s create a program that helps separate collection by recognizing cans, glass 10
bottles, and paper on the webcam.
11
12
13
14
15
Webcam : You can take pictures of Let’s see how to register an image
things yourself. using a webcam.
Upload : You can upload a file on
your computer, or you can get an [Click] ‘Webcam’
image on the web and upload it.
CHAPTER
01
02
03
04
Let’s add data in the same way for Bottle, Paper,
05
and Nothing classes.
06
07
08
09
10
11
12
13
14
15
❶ When the machine learning model is training, moving to another window will
stop training, which means keep the screen on.
❷ Shows the status of training in progress.
When the training is completed, the above screen appears. It is possible to check
the accuracy of model by using a webcam or uploading an image.
3-1 Programming using the teachable machine 75
Let’s see if the training went well. You can check it through webcam or upload.
CHAPTER
01
02
03
04
05
06
07
08
09
10
If you take something with a webcam, so it distinguishes between cans, bottles and
paper. If the envelope was filmed on a webcam, 78% of the envelopes were recognized 11
as paper! Let’s take a picture of various objects and test what they are recognized as.
12
13
TIP Training data and Test data 14
Training data
In the field of artificial intelligence, the terms training and learning are used in combination. 15
Therefore, the data used for model training is called ‘training data’ and ‘learning data’.
Test data
Test data is used to ‘evaluate’ the model. The evaluation is to judge whether the model’s
performance is good or bad. Usually, accuracy is measured to know the performance. (95%
accuracy is very good). 80% accuracy is low performance - relative figures) Test data and
training data must be independent of each other. Training data should not be used to test.
76 Chapter 03 Scratch Advanced
Unit
Using Teachable Machine
02 in Scratch
CHAPTER
01
02
Adding Teachable Machine Extensions in Scratch
03
Let’s make a scratch program using the learning model made with the teachable
machine. We will use the link created on the teachable machine for scratch coding. 04
However, the teachable machine extension function is not on the official Scratch site.
05
Go to https://stretch3.github.io/
(The teachable machine extension function is not an extension function officially
06
provided by Scratch, so it is impossible to share it.)
07
If the language is not set to your
1
native language, 08
[Click] Icon ❶ - [Choose]
language 09
❷ [Click] ‘Add Extension’ in the
10
lower left corner
11
12
2
13
14
[Click] ‘TM2Scratch’ 15
TM2Scratch is an extension function block that
changes the teachable machine to scratch coding.
Action Reaction
Execution result
You Sprite
Sound -
Don’t recognize anything.
Save the earth.
Speech balloons
Thank you!
In palette, [Choose]
‘TM2 Scratch’
[Drag-and-drop]
‘turn video’ - [Click]
‘off ‘(Default state is
‘off ’) - [Choose] ‘on’
[Drag-and-drop] ‘Image classification model URL’ - [Click] blank - [Enter] the
link to the learning model created by the teacherable machine
[Drag-and-drop] ‘turn classification’ - [Click] ‘off ’(Default state is ‘off ’) - [Choose]
‘on’
3-1 Programming using the teachable machine 79
02
Let’s turn on the computer’s speakers and run Scratch.
03
However, if there is no sound, the classification result cannot be known on the
04
screen. You can move sprites on the screen and display speech balloons.
05
06
07
08
09
10
11
In palette, [Choose] ’Look’ 12
[Drag-and-drop] ‘say’ - [Enter] ‘It’s a
Can’ (Let’s type in the text that fits each 13
label.) When you run the completed
scratch program, it appears 14
that the Sprite recognizes
objects reflected on the screen 15
and separates them as follows.
Since we have created a program that recognizes things, can’t we create a program
that recognizes people? Let’s think about a variety of machine learning programs that
can recognize images.
3-2
A.M P.M
Sessions 4~6/6 sessions in total Time
O
Unit
Creating AI models with
01 Machine Learning for Kids
Machine Learning For Kids was created by IBM software developer Dale Lane. He
created this site to make it easier for children to understand and develop artificial
intelligence. However, Machine Learning for Kids makes it easy for children as well as
those new to AI to create AI programs.
Go to https://machinelearningforkids.co.uk/
‘Train’ in Machine Learn ▶ The learning stage can ▶ When learning is complete,
ing For Kids is the same be said to be the process you can experiment with
as the data collection stage of automatically learning the learning results. You can
in Teachable Machine. In the collected data with a consider adding or modifying
this step, we collect data machine learning algorithm data to a specific label by
for machine learning and and creating a knowledge inserting test data and
classify labels. A label is base. The learning process viewing the analysis results
the same as a ‘Class’ in the may have different learning of machine learning.
Teaching Machine. times depending on the
type and size of data.
3-2 Programming using Machine Learning for Kids 83
Text Project
CHAPTER
01
02
04
05
06
07
08
[Click] ‘Add a new project’
09
10
1
11
12
2
13
3
14
4
15
❶ [Enter] Project name ‘emotions in words’
❷ [Choose] Recognising (You can choose between text, number, sound, and
image.)
❸ [Choose] Language
❹ [Click] ‘CREATE’
84 Chapter 03 Scratch Advanced
[Enter] label name ‘Good’ - [Click] Now, let’s add data to the label.
‘ADD’ To add data to the Good label,
Let’s add the Bad label in the same [Click] ‘Add example’ inside the
way. Good label.
CHAPTER
01
02
03
04
05
06
07
[Click] ‘Learn & Test’ [Click] ‘Train new machine
08
learning model’
09
10
11
After training the machine learning model, you can test it. Completion of training 12
means that it is ready for evaluation.
13
14
15
Using what you didn’t use as training data as test data is enough to get an idea of
the accuracy.
86 Chapter 03 Scratch Advanced
Image Project
Let’s create an artificial intelligence model that can distinguish images.
CHAPTER
01
02
03
04
google image search [Right click] on the [Click] button( ) - [Press]
05
image - [Click] ‘Copy ‘Ctrl’ + ‘V’ in keyboard (paste
image address’ address) - [Click] ‘ADD’ 06
07
08
: take a picture with
: draw it yourself 09
a webcam
10
11
12
13
14
15
[Click] button( ) - Place [Click] button( ) - [Click] ‘Draw’, you
an object in front of the webcam - can draw while holding down the mouse in
[Click] ‘ADD’ the space on the left. - [Click] ‘Erase’, you can
erase what you drew. - When the drawing is
complete, [Click] ‘ADD’
88 Chapter 03 Scratch Advanced
03
04
05
1
06
07
2 08
09
❶ On one side, search for images through the Internet window, and on the other
10
side, keep the test window on. - [Drag-and-drop] the image to move it
❷ The image web address is entered in the input field. - [Click] the Test with www 11
button
12
13
14
15
It can be seen that the input bus image is recognized as a bus image at 99%.
90 Chapter 03 Scratch Advanced
Sound Project
Start a new project.
Background noise labels are basically created because external noises need to be
learned to increase accuracy.
[Click] ‘Add new label’ - [Enter] label name - [Click] ‘ADD’
(In the book, Red, Yellow, and Blue were added as labels.)
3-2 Programming using Machine Learning for Kids 91
CHAPTER
01
02
03
04
[Click] ‘Add example’
05
06
07
08
09
[Click] on the Speaking Finished recording
10
microphone Icon (Recording) -[Click] ‘ADD’
11
12
13
14
15
Add 8-10 pieces of data to each label. Record various speed, voice size, height, etc.
92 Chapter 03 Scratch Advanced
Let’s look at the results and see if the learning went well.
3-2 Programming using Machine Learning for Kids 93
Unit
Scratch Coding Using Machine
02 Learning For Kids
CHAPTER
01
02
Using machine learning models for scratches (Text Project)
03
[Click] ‘Make’ 04
05
06
07
[Click] ‘Scratch 3’
(Machine learning for kids 08
can create programs using
09
machine learning models
trained as Scratch, Python, 10
and App Inventor.)
11
12
[Click] ‘Open
in Scratch 3’ 13
14
15
94 Chapter 03 Scratch Advanced
Sprite 1 Sprite 2
(Abby) (Devin=User)
Case Execution result
[Ask]
(ex. “How was the
Code -
restaurant you
A visited?”)
Costume [Waiting] -
Costume [Waiting] -
[Say]
Code (Reaction according -
Case A is a coded state where Sprite 1 (Abby) has asked and waiting for a response
from Sprite 2. Sprite 2 is the user. Case B shows the case where the user inputs. When
the user types something into the input field and presses enter, it is handled in some
way. In case C, Sprite 1 responds positively or negatively depending on the user input,
and the costume changes.
3-2 Programming using Machine Learning for Kids 95
CHAPTER
01
02
06
07
08
09
Abby’s appearance in Bad costume is a drawing of the shape of her mouth and the
embarrassing figure next to her. Try decorating the costume more interestingly.
Scratch Coding
CHAPTER
01
02
03
04
05
06
07
08
[Drag-and-drop] ‘when (Flag) clicked’
09
[Drag-and-drop] ‘forever’
[Drag-and-drop] two ‘if ’ blocks inside 10
[Drag-and-drop] ‘recognise text (label)’ block into the Operator(‘=’) blocks
[Drag-and-drop] ‘Good’ in the first ‘if ’ block, [Drag-and-drop] ‘Bad’ in the second 11
‘if ’ block
12
13
14
15
[Right click] on my
variable in the Variables block palette -
[Click] ‘Rename variable’ [Enter] ‘review’ - [Click] ‘OK’
98 Chapter 03 Scratch Advanced
[Drag-and-drop] ‘answer’
block into the ‘recognise
text(label)’ block
TIP The types of blocks in Machine Learning For Kids are as follows.
❶ Returns a label for text.
1 ❷ Returns the type of text.
2
❸ Name of the label created in the project.
3 ❹ Add training data.
4 ❺ Train a new machine learning model.
5 ❻ Machine learning models take about a minute to be
ready to use, and must use a wail until block.
6
3-2 Programming using Machine Learning for Kids 99
CHAPTER
01
02
03
The ‘ask ~ and wait’ block creates a speech balloons like the result screen on the
right. ‘answer’ makes the input window under Devin appear, and it receives the 04
value entered by the user and sets it in ‘review’.
05
06
In palette, [Choose] ’Look’
[Drag-and-drop] ‘switch costume to ~’ - [Click] ‘▼’ 07
- [Choose] ‘waiting’ (When Abby does nothing,
costume is waiting. Choose costume from other 08
‘switch costume to ~’ blocks according to the
09
conditions.)
10
11
12
13
In palette, [Choose] ’Look’
[Drag-and-drop] ‘say ~ for ~ seconds’ - [Enter] 14
what Abby has to say when the machine learning
model receives a positive input. - [Enter] ‘5’ (This is 15
to float the speech balloons for five seconds.)