Image Classification
Materials
AMB82-mini x 1
Example
In this example, we will be using development board to identify images and perform classification.
Open image classification example in File -> Examples -> AmebaNN -> RTSPImageClassification
If the model was trained with metadata, set USE_MODEL_META_DATA_EN to 1.
In the highlighted code snippet, fill in the “ssid” with your WiFi network SSID and “pass” with the network password.
Select Neural Network (NN) task and models using modelSelect() function highlighted in yellow. This function takes 6 arguments: Neural Network task, Object Detection model, Face Detection model, Face Recognition model, Audio Classification model and Image Classification model. Replace with “NA_MODEL” if they are not necessary for your selected Neural Network task. Note that it is mandatory to call modelSelect() function before calling the begin() function.
Valid Neural Network task:
OBJECT_DETECTION,FACE_DETECTION,FACE_RECOGNITIONValid Object Detection model:
YOLOv3-tiny model:
DEFAULT_YOLOV3TINY,CUSTOMIZED_YOLOV3TINYYOLOv4-tiny model:
DEFAULT_YOLOV4TINY,CUSTOMIZED_YOLOV4TINYYOLOv7-tiny model:
DEFAULT_YOLOV7TINY,CUSTOMIZED_YOLOV7TINY
Valid Face Detection model:
DEFAULT_SCRFD,CUSTOMIZED_SCRFDValid Face Recognition model:
DEFAULT_MOBILEFACENET,CUSTOMIZED_MOBILEFACENETValid Image Classification custom CNN model:
DEFAULT_IMGCLASS,CUSTOMIZED_IMGCLASSValid Image Classification MobileNetV2 model:
DEFAULT_IMGCLASS_MOBILENETV2,CUSTOMIZED_IMGCLASS_MOBILENETV2
Choose the customized option (e.g., CUSTOMIZED_YOLOV4TINY/ CUSTOMIZED_SCRFD/ CUSTOMIZED_MOBILEFACENET) if you would like to use your own NN model. To learn about the process of converting an AI model, refer to
AI Model Conversion Toolkit
. Additionally, refer to
AI Model Deployment Guide
to understand how to install and use the converted model.
To note: If you would like to customize your own model, currently only Sequential CNN model is supported. Kindly refer to https://www.amebaiot.com/en/amebapro2-ai-convert-model/ to take note of some points when training models.
Compile the code and upload it to Ameba. After pressing the Reset button, wait for the board to connect to the WiFi network. The board’s IP address and network port number for RTSP will be shown in the Serial Monitor.
The live feed capture from the board’s camera sensor can be viewed on VLC media player. You may download VLC media player from the link here
Upon the completion of the software installation, open VLC media player, and go to Media -> Open Network Stream
Make sure your PC is connected to the same network as the board for streaming. Since RTSP is used as the streaming protocol, key in rtsp://{IPaddress}:{port} as the Network URL in VLC media player, replacing {IPaddress} with the IP address of the board, and {port} with the RTSP port shown in Serial Monitor e.g., rtsp://192.168.1.154:554 The default RTSP port number is 554.
Next, click “Play” to start RTSP streaming to see the result. The video stream from the camera will be shown in VLC media player.
Now, you will be able to see what the camera is capturing. The detected class and its probability will be displayed in the Serial Monitor and at the top-left corner of the video stream.
Custom CNN Model (e.g Sequential): Without metadata and can classify various types of garbage, including cardboard, glass, metal, paper, plastic, and general trash.
MobileNetV2 Model: With metadata which can classify types of flowers such as Daisy, Lavender, Lily, Rose and Sunflower.
The items can be found in ClassificationClassList.h. The index number for each object is fixed and should not be changed. To deactivate the detection of certain objects, set the filter value to 0.