Project 31:TinyML-Based Intelligent Bird Recording Device

Strolling through forests, you may see flying birds but can't identify them. Traditional birdwatching with field guides is inefficient and makes you miss great moments. Now, a new intelligent bird recording device based on UNIHIKER K10 is launched. It uses a self-trained object detection model on Edge Impulse and TinyML technology to identify birds in real time, mark their positions, and quickly count bird quantity and species, providing a smarter and more convenient experience for bird lovers.

Project Objectives

Knowledge Objectives

1.Understand AI models and roles;

2.Train and deploy image recognition models.

Practical Objective

Create an intelligent bird recording device based on UNIHIKER K10. It uses the device's camera to automatically identify and outline birds in the frame and show popular-science information. Press Button A to record the currently identified bird species, and press Button B to display statistical records of the quantity and categories of observed birds.

Materials List

HARDWARE LIST
1 UNIHIKER K10
1 USB Cable

Preparations

Hardware

Connect the UNIHIKER K10 to the computer using a USB Cable.

Software

1.Download and Setup of Arduino IDE 1.8.19

Download and install Arduino IDE software for subsequent model deployment and uploading. The specific download link is as follows: https://www.unihiker.com/wiki/K10/GettingStarted/gettingstarted_arduinoide/

Note: UNIHIKER K10 currently only supports Arduino IDE 1.8.19 or below. We will add support for Arduino IDE V2.x in subsequent releases.

After installation, we need to install UNIHIKER SDK in the Arduino IDE. The specific steps are as follows:

STEP1:open Arduino IDE, go to "File→Preference" in Arduino IDE, and set "Compiler warnings" to none.

STEP 2: add SDK URL.Copy and paste the URL in the box, then click OK to save.

SDK URL Link: https://downloadcd.dfrobot.com.cn/UNIHIKER/package_unihiker_index.json

STEP3:open "Tools→Board→Boards Manager",complete the installation of the UNIHIKER K10.

STEP4:In“Tools”, set the board to UNIHIKER K10.

Note: For more instructions on using the Unihiker K10 via the Arduino IDE, please refer to the official wiki: https://www.unihiker.com/wiki/K10/GettingStarted/gettingstarted_arduinoide/.

2.Mind+ Software (Minimum Version Requirement: V1.8.1RC1.0)

Open Mind+, switch to“Upload Mode”, connect the UNIHIKER K10 as shown in the figure below, and load the UNIHIKER K10 library.

Hands-on Practice

Next, we'll use UNIHIKER K10 and Edge Impulse platform to train a model for bird species identification. Then, by combining with the screen display and other functions, we'll build an intelligent bird recording device.

Task 1: Bird Image Data Collection

First, we'll configure the network on UNIHIKER K10 and collect bird image data with a network camera.

Task 2: Model Training

Then, we'll upload image data to the Edge Impulse platform, then complete model training and calibration.

Task 3: Building the Intelligent Bird Recording Device

Last, we'll deploy the trained model to UNIHIKER K10 to finish the device.

Task 1: Bird Image Data Collection

Code

Network Configuration

First, retrieve and add the Wi-Fi module from the Module in the "Extensions". The specific steps are as follows:

Next, we can complete the core code follow the main logic:connect to the network→wait for successful connection→output IP address, as shown below:

Note: Connect UNIHIKER K10 and computer to the same Wi-Fi network.

Network Camera Startup

After connecting the UNIHIKER K10 to the network, search for and add the “K10webcam”from "Module" in extensions. The specific steps are as follows:

After loading, follow the main logic to display the UNIHIKER K10 camera and enable the network camera to transmit the feed to the LAN. Then, any LAN computer can access it at any time and use existing computer vision libraries for image recognition.

To enable the network camera, use“Webcam (open)”block from UNIHIKER K10 Webcam, as shown below.

The complete reading code is shown below:

Run the Code

Click the“Upload”button, wait for upload completion, then open the Serial Monitor. You'll see the IP address of the UNIHIKER K10, as shown below.

Open a browser and enter the IP address shown on the serial port. A “Capture” button will appear on the web interface. When the desired image appears in the frame, click the button and the system will save the current frame to your computer. For example, enter 192.168.0.116 (the IP shown in the above figure) in the browser. The corresponding interface is as follows:

Collect and save bird images.

Open the corresponding web page. Pick up UNIHIKER K10, point its camera at the bird to make it visible in the frame. Then click“Take a photo and download it” on the web interface, and the system will capture and save the image to your computer. To improve model-training accuracy, take 30-50 photos for each bird species. The specific steps are as follows:

Next, cut all images to a folder named "bird_datasrt" for later model training.

Code Review

Category

Blocks

Function

It toggles the network camera's on/off status and works with other blocks to display the UNIHIKER K10 onboard camera's footage on a computer in real time.

Task 2: Model Training

Data Upload

Uploading bird photo materials requires Edge Impulse platform (official website: https://edgeimpulse.com/). After accessing the website, please complete user registration by yourself.

After entering the website, click "Create new project" and enter a project name (e.g., "birds_detection").

Next, click "Add existing data", then select "Upload data".

Then click "select a folder", find and click "choose files" button, locate the previously collected and organized "bird_dataset" folder, and click "Upload".

Finally, select "Automatically split between training and testing", then click "Upload data" to start uploading the dataset.

Data Labeling

After data upload, click "Data acquisition→Labeling queue" to enter the data annotation page. On the page, use the mouse to draw a rectangular box around the bird in the image to enclose it. After that, enter the bird's name (e.g., "sparrow", "white pigeon") in the pop-up label input box and click "Add" to add the label. If there are multiple birds or different species in one image, draw multiple boxes and label them separately.

After completing the annotation, click the "Next" button to switch to the next image and continue annotating until all images are annotated.

Model Training

After completing the dataset annotation, click "Impulse design→Create impulse",click "save impulse" button.

Note:Reference for the meaning of each processing block https://docs.edgeimpulse.com/docs/edge-impulse-studio/processing-blocks.

After saving, click the "Image" processing block to enter the "data parameters" page,select"save paramenters".

Next, enter the "Generate features" page and click the "Generate features" button to generate image features.

Finally, click "Object detection" to enter the model training page. On this page, set model training hyperparameters like the number of training epochs and learning rate. Set the number of training epochs to 100 and the learning rate to 0.001. Then, select the model framework (here, choose the FOMO MobileNetV2 framework) and click "Save&train" to start model training. After training is complete, view the training results and related data on the right side.

After training, we can view the model performance. If the performance is unsatisfactory, go to the "Retrain model" page, select "Train model", adjust the parameters, and retrain the model.

Task 3: Building the Intelligent Bird Recording Device

Model Deployment

Once the model training is complete, click“Deployment”to enter the model download page.Then click“DEFAULT DEPLOYMENT”and select“Arduino library”.Meanwhile, select“TensorFlow Lite”in“MODEL OPTIMIZATIONS” section,and click “Build”. The specific steps are as follows:

After the model is built, the packaged model archive will be downloaded automatically.

Unzip the downloaded model file into the "arduino→libraries" path of Arduino IDE (1.8.19), as shown below.

Open the birds_detection_inferencing folder and replace the depthwise_conv.cpp and conv.cpp files in src\edge-impulse-sdk\tensorflow\lite\micro\kernels of the model file(Provided in the “Project 31” archive).

Replace these two files with the same name in the attachment which can be find in the corresponding compressed file packageReplace these two files with the same name in the attachment which can be find in the corresponding compressed file package

Next, download the edgeImpulse_vision library for the UNIHIKER K10 from the following link: https://github.com/cdjq/edgeImpulse_vision.Once downloaded, extract the folder to the arduino-1.8.19\libraries directory.

Model Import

Next, we'll import the model. First, locate“user_include” file under the path \arduino-1.8.19\libraries\edgeImpulse_vision-main\src and double-click to open it.

After opening it, modify the #include section in the file as shown below:

Code

First, double-click to open Arduino IDE.Click “File” in the top-left corner, select “Open”, and open the “edgeimpulse.ino” file under the path arduino-1.8.19\libraries\edgeImpulse_vision-main\example\edgeimpulse.

After opening the file, copy the contents of “code.txt” from the "Project 31" folder into the newly opened file, as detailed below:

Copy and paste the codeCopy and paste the code

Note: For more instructions on using the Unihiker K10 via the Arduino IDE, please refer to the official wiki: https://www.unihiker.com/wiki/K10/GettingStarted/gettingstarted_arduinoide/

Run the Code

In the Arduino IDE software, click "Tool", set "Board" to "unihiker k10", "Upload Speed" to "921600", and enable "USB CDC on Boot".

Then click "Upload" button to compile and upload the code to UNIHIKER K10.

Note: The first compilation of Edge Impulse-related programs on the UNIHIKER K10 may take longer. Please wait patiently.

When the upload is successful, the page will display as follows.

Then, point the camera of UNIHIKER K10 at the bird images.Observe the recognition results on UNIHIKER K10 screen: the name of the bird will be displayed, and a bounding box will mark the bird's position in the image.

Press and hold the A button on the UNIHIKER K10 for 1 second to record the observed bird name into the device. When you release the button, the screen will display "recorded" to indicate successful recording.

Press the B button to view all identified bird species and their corresponding counts.

Knowledge Base

Next, let's learn and summarize the knowledge used in this lesson.

AI models and roles

An AI model is an intelligent judgment and processing system trained with specific algorithms and massive data. As the core for AI's independent analysis and decision - making, it's the "brain" of AI. It doesn't rely on fixed instructions but learns from data to form autonomous reasoning logic, providing a basis for AI's thinking and acting.

The core of AI is to make computers go beyond simple instruction execution. With recognition, understanding, prediction and decision-making abilities, AI can efficiently process information like images, speech and text, and perform intelligent tasks such as face recognition, voice interaction, content recommendation and data prediction. Therefore, it replaces or assists humans in complex analysis and judgment, improving work efficiency and reducing labor costs.

Challenge Task

Based on the completed intelligent bird recognition and recording device, expand image collection for 3 common bird species and retrain the model. This enables the device to accurately identify different bird species in the frame and complete a functional upgrade more suitable for real bird-watching scenarios.

icon project 31.zip 4.66MB Download(0)

Click to get the birds database.

License
All Rights
Reserved
licensBg
0