Import an AI model trained with Teachable Machine into CodeLab so the robot can recognize objects using its camera. This provides an introduction to machine learning and adds new capabilities to your programs.
What is Teachable Machine?
Teachable Machine is an open-source tool from Google that lets people train object-recognition models with a computer webcam, without programming experience.
How do you train a Teachable Machine model?
Image source :Teachable Machine
Step 1: Gather
Use the webcam to gather and group training images showing different angles and backgrounds.
Step 2: Train
Train your model. Note: because of TensorFlow Lite export limitations, train at least three classes when using the model in CodeLab.
Step 3: Export
Export the model in the format required by your application.
For use in CodeLab, choose TensorFlow Lite and select Quantized.
Add the extension in CodeLab Teachable Machine blocks
Add these blocks in the same way as other extensions:
1. Click Edit Blocks to open the Add Blocks page. 2. Find the Teachable Machine block card. 3. Click Add.
Teachable Machine blocks
When the robot recognizes __ __ with confidence __%
- Description
This block starts a section of the program when the robot recognizes an item from the selected model.
- Example Click Select Image Recognition Model and upload the "Ten Fruits" model exported from Teachable Machine. Select "apple" and set its confidence threshold to 75%. Note: a higher confidence threshold requires the detected image to match the training images more closely.
Wait until the robot recognizes __ __ with confidence __%
Description
This block waits for the robot to recognize an object from the selected model before continuing to the next action.
- Example
Wait until the robot recognizes "apple" from the "Ten Fruits" model with confidence above 75%, then display the "Correct" image.
If the robot recognizes __ __ within __ seconds with confidence __% +
- Description
Place the actions to perform inside the If block. They run when the robot recognizes the specified object within the time limit and above the confidence threshold.
If the robot recognizes __ __ within __ seconds with confidence __%, otherwise __
- Description
If the robot recognizes the specified object within the time limit and above the confidence threshold, it runs the actions inside If. If the condition is not met, it runs the actions inside Else.
__ recognition result
- Description
Upload a recognition model before selecting it for use.
- Example
Connect this variable block to Say and select the "Ten Fruits" model. The robot will use TTS to say which item it recognized.
__ confidence
- Description
Upload a recognition model before selecting it for use.
- Example
Connect this variable block to Say and select the "Ten Fruits" model. The robot will use TTS to say the confidence percentage for the recognized item.