Guide for Image Classification Model with Marty the Robot
This guide explains how to create and use an image classification model, and have Marty the Robot respond to predictions in MartyBlocks.
Navigate to the Machine Learning tab, press the “Add” button at the bottom left corner, and select “New Image Model”.
If a new dialog box comes up asking you if you are sure, press continue.
You can start by giving your model a new name!
You can now start collecting data for your classes! As a general rule of thumb, the more data you give to the model the better will perform, although the quality of the data is equally important!
Just type the name of the class you want to collect data for in the “Collect Data for” input and press the “Record” button.
Repeat this process for all the classes you want to collect data for.
You can collect more samples for each class by pressing the “Record” button again.
Once you have collected enough data for your classes, you can train your model by pressing the “Train” button.
Once the training is complete, you will see the Loss graph which plots the training loss over training iterations (epochs).
Once you have trained your model, you can run it by pressing the “Run” button.
You will see the predictions for each class in the “Predictions” table.
Once you are happy with your model, you can save it by pressing the “Save” button.
Note that once your model is saved you will not be able to collect more data for it.
You can now load your model in MartyBlocks and use it to make predictions!
First, navigate to the Code tab and scroll down to the Machine Learning blocks section.
Use the “Load Marty Machine model” block and select the model you want to load.
Executing the “classify image” block will use your device's camera to start making predictions, and you may toggle classifications on and off using the “turn classification” block.
Once you have executed the command to import your classification model, the class labels will be available for selection in some blocks. There are a few ways to make predictions.
Event handler:
Boolean:
Variable:
To see the value of the “image label” variable, check the box beside the variable in the Teachable Machine menu.
To see the video from your device’s camera, open the stage view by selecting the icon to the right of the stop icon.
The “turn video” block allows you to turn video on and off.
To make changes to the rate of classifications, use the “Label once every seconds” block
To make changes to the confidence threshold, use the “set confidence threshold” block. The default confidence threshold is 0.5 (i.e. 50%).