===== Image Model Guide ===== ** Guide for Image Classification Model with Marty the Robot**
This guide explains how to import an image classification model from Teachable Machine and have Marty the Robot respond to predictions in MartyBlocks.Users new to Teachable Machine should review the following videos to learn about how to create a classification model: * [[https://teachablemachine.withgoogle.com/train?action=onboardOpen&id=DFBbSTvtpy4|Gather samples]] * [[https://teachablemachine.withgoogle.com/train?action=onboardOpen&id=CO67EQ0ZWgA|Train your model]] ===== Step 1: Create an image classification model on Teachable Machine ===== [[https://teachablemachine.withgoogle.com|Go to the Teachable Machine website]], select “Get Started,” and create an image project. Follow the instructions from Teachable Machine to define your classes, collect image samples, and train your model. ===== Step 2: Export your model from Teachable Machine ===== In the preview panel, select “Export Model.” In the dialog box that appears, confirm that “Upload (shareable link)” is chosen and select “Upload my model.” {{:martyv2:userguides:martyblocks:teachablemachine:1.tmexport.png|Image for Step 2.1}} It will take a few seconds to save your model, then copy the shareable link URL that is generated. {{:martyv2:userguides:martyblocks:teachablemachine:2.tm-export2.png|Image for Step 2.2}} ===== Step 3: Add the Teachable Machine extension to MartyBlocks ===== Open MartyBlocks and select the add extension icon in the lower left corner. {{:martyv2:userguides:martyblocks:teachablemachine:3.-tm-new.png|Image for Step 3.1}} Select the “Teachable Machine Image & Sound” extension. {{:martyv2:userguides:martyblocks:teachablemachine:4.tm-extension.png|Image for Step 3.2}} ===== Step 4: Import your Teachable Machine model ===== From the Teachable Machine menu, select the “image classification model URL” block and drag it into the workspace. {{ :martyv2:userguides:martyblocks:teachablemachine:5.image-url.png |Image for Step 4.1}} Paste your classification model URL from Teachable Machine into the block and execute the command to import the model. {{ :martyv2:userguides:martyblocks:teachablemachine:6.url-on-click.png |Image for Step 4.2}} ===== Step 5: Make classifications in MartyBlocks ===== 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. {{ :martyv2:userguides:martyblocks:teachablemachine:7.tm-classification.png |Image for Step 5.1}} 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: {{:martyv2:userguides:martyblocks:teachablemachine:8.tm-blocks1.png|Image for Event handler}} Boolean: {{:martyv2:userguides:martyblocks:teachablemachine:9.tm-blocks-ifs.png|Image for Boolean}} Variable: {{:martyv2:userguides:martyblocks:teachablemachine:10.tm-blocks-ifs2.png|Image for Variable}} To see the value of the “image label” variable, check the box beside the variable in the Teachable Machine menu. {{ :martyv2:userguides:martyblocks:teachablemachine:11.tm-monitor.png |Image for Step 5.2}} ===== Step 6: Show video from camera (optional) ===== To see the video from your device’s camera, open the stage view by selecting the icon to the right of the stop icon. {{ :martyv2:userguides:martyblocks:teachablemachine:12.tm-camera-feed.png |Image for Step 6.1}} The “turn video” block allows you to turn video on and off. {{ :martyv2:userguides:martyblocks:teachablemachine:13.tm-video-off.png |Image for Step 6.2}} ===== Step 7: Changing the classification rate and confidence threshold (optional) ===== 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%). {{:martyv2:userguides:martyblocks:teachablemachine:14.threshold.png|Image for Step 7.1}}