Documentation

Una is developed by Una Technologies Limited

All rights reserved

© 2022 Una Technologies Limited

Print

Showing the Total Amount of Classes with Image Model

Image Model get total number of classes

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>poseModel</variable><variable>posePredictionResult</variable><variable>imageModel</variable></variables><block type=\"TeachableMachine_ImageModel_getTotalClasses\" disabled=\"true\" x=\"-22\" y=\"-22\"><value name=\"imageModel\"><block type=\"variables_get\" disabled=\"true\"><field name=\"VAR\">imageModel</field></block></value></block></xml>"}
				
			

This is used to get the full number of classes. 

Parameters: AI Model (Teachable Machine Image Model)
Output: Number
Sample code:

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>imageModel</variable><variable>imagePredictionResult</variable></variables><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">imageModel</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"TeachableMachine_loadImageModel\"><value name=\"baseUrl\"><shadow type=\"text\"><field name=\"TEXT\">https://teachablemachine.withgoogle.com/models/tghdF3FXI/</field></shadow></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">imagePredictionResult</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"TeachableMachine_ImageModel_predict\"><value name=\"imageModel\"><block type=\"variables_get\"><field name=\"VAR\">imageModel</field></block></value><value name=\"photo\"><block type=\"Resources_getPhotoByURL\"><value name=\"url\"><shadow type=\"text\"><field name=\"TEXT\">https://image.shutterstock.com/image-photo/boy-raising-two-fingers-on-260nw-297974771.jpg</field></shadow></value></block></value></block></value><next><block type=\"Camera_showPhoto\"><value name=\"photo\"><block type=\"Resources_getPhotoByURL\"><value name=\"url\"><shadow type=\"text\"><field name=\"TEXT\">https://image.shutterstock.com/image-photo/boy-raising-two-fingers-on-260nw-297974771.jpg</field></shadow></value></block></value><next><block type=\"basic_consoleLogText\"><value name=\"text\"><block type=\"Json_JsonValue_stringify\"><value name=\"jsonValue\"><block type=\"TeachableMachine_ImagePredictionResult_getResults\"><value name=\"imagePredictionResult\"><block type=\"variables_get\"><field name=\"VAR\">imagePredictionResult</field></block></value></block></value></block></value><next><block type=\"basic_consoleLogNum\"><value name=\"num\"><block type=\"TeachableMachine_ImageModel_getTotalClasses\"><value name=\"imageModel\"><block type=\"variables_get\"><field name=\"VAR\">imageModel</field></block></value></block></value></block></next></block></next></block></next></block></next></block></statement></block></xml>"}
				
			

The output:

image Model get total number of classes - Output
Previous Showing the Class Labels in Image Model