Let us see how to import a model in PictoBlox.
Importing the Model
- Open PictoBlox and start a new project.
- Select evive as your board from the Board Tab on the menu bar.
- Click the Add Extension button and select the Machine Learning extension.
- Click the Load Model button.
- A model will open. Paste the link and click the Upload button.
- The relevant blocks will appear in the palette when the model is loaded successfully.
Understanding the Machine Learning Blocks
1. open recognition window
The Open recognition window block opens the recognition window with the camera feed the same as the AI extension and shows the predicted class based on the camera feed.
2. () block
The () block reports the label of the selected class.
3. identify class from ()
The identify class from () block reports the identified class from the selected feed – web camera, stage, or costume.
4. is identified class from () is ()?
The is identified class from () is () block reports true if the detected class from the selected feed is the selected class, else false.
5. get confidence of class () from ()
The get confidence of class () from () block reports the confidence of the selected class from the selected feed.
Tobi – The Classifier
Tobi will do us the honor of telling the result of the classification. Let us write the script for the same:
- Add the test images to the project by clicking the Upload Backdrop button. Select all 10 test images.
- Once uploaded, click the Backdrop tab and delete the white backdrop.
- Select Tobi. Switch to sound tab and add the following two sounds from the library:
- Switch back to the Code tab.
- Add the when flag clicked block and the forever block into the scripting area and snap them together.
- Drag and drop the switch backdrop to () block inside forever block. From the drop-down, select random backdrop.
- Drag and drop the say () for () seconds block into the scripting area. In the first space, add the identify class from () block from the Machine Learning extension.
- Choose backdrop as the feed from the drop-down.
- Drag and drop the if block below the say block. Then, add the is identified class from () is ()? block in condition space. Select backdrop as the feed.
- From the Sound palette, add a play sound () until done block inside if block. From the drop-down, select Meow.
- Duplicate the if block and snap it below the first if block. Select the class as a dog in the second is identified class from () is () ? block.
- Change the sound in the second play sound () until done block to dog2.
Below is the complete script:
Click the green flag to run the script.
Yay! You have made your first Machine Learning project!
Before you move on to the next lesson, a small assignment awaits you!
You must upload the PictoBlox program you wrote in this activity to the website.
Submitting the assignment is a must to receive the certificate after completing the course.
Follow the steps below to upload your assignment:
- Click Choose File.
- Select the image from the pop-up window that opens up.
- Once the image is selected, click Upload Assignment.