Teachable Machine extension blocks are developed based on ML5.js open source library.
Add Teachable Machine extension
1) Firstly, open Codecraft, toggle to the Stage mode, click Add Extension to open the Extension Library.
2) Secondly, click Add in the Extension Library to add Teachable Machine extension blocks to the block category on the Stage mode.
The training model requires a computer connected camera. The training and use process can refer to the following examples.
How to Training Model
Preparation before training
Before you start training models, get the models and cameras ready for training. As shown in the figure below, in this example, in addition to the camera, there a kitten, chicken and GameGo as the training model objects.
1. Open the “Training model”
First, click on in Teachable Machine. The training model window opens, as shown in the following figure.
2. Training three models
First put GameGo in front of the camera to start training. Input GameGo in the name field of first sample to tell the computer that it is currently receiving pictures of GameGo . Then click the Learn button of GameGo . As shown in the screenshot below, one picture will appear in the GameGo class.
Then change different angles for GameGo. After each adjustment, click the Learn button, and you can try 9 times, as shown in the figure below. Now the learning progress is close to 100%.
Next, we’ll collect the training images for the kitten. We can try to stake pictures from different angles. As we take pictures, we’ll see them appearing in samples list for kitten object.
Finally, let’s collect the training images for the chicken. The result is as follows.
After training, the Using the model button will become available, as shown in the figure below. Click Using the model.
3. Using the models
Back to the programming interface, you can see that three new building blocks and a Open recognition window button are added, as shown in the figure below. These are the results of our training model above.
4. Test with recognition window
Click the button , you will be prompted to turn on the camera. After confirmation, the screen shown in the following figure will appear. Put kitten in front of the camera, and the recognition result and confidence will be displayed.
Using the results of training model in programming
In the following example, let’s ask the owl to “say” what the camera sees.
The procedure is as follows.