Intelligent Extra Arm
Edge Impulse and Raspberry Pi
In the last forum discussion, I had completed the initial setup of Raspberry Pi for my project. In this forum discussion, I'll proceed with the setup of Edge Impulse and Raspberry Pi connected to an USB Webcam for Object detection. This will help the Intelligent Extra Arm to detect what objects are resistors, capacitors like that. Let's get started!
Raspberry Pi - Setup
- I have run the below commands in Raspberry Pi's terminal.
sudo apt update curl -sL https://deb.nodesource.com/setup_20.x | sudo bash - sudo apt install -y gcc g++ make build-essential nodejs sox gstreamer1.0-tools gstreamer1.0-plugins-good gstreamer1.0-plugins-base gstreamer1.0-plugins-base-apps sudo npm install edge-impulse-linux -g --unsafe-perm
- Next step was to configure the camera module using sudo raspi-config command. Since, I'm using Raspberry Pi running Ubuntu OS and have an USB camera, I'm skipping this part.
- Ran the below commands for setting up Edge Impulse using Docker. I didn't had Docker libary installed. So I have installed it at first (skip if required). While running second command, got the following error 'docker: unknown server OS: .'. For this adding sudo in front resolved it.
sudo snap install docker sudo docker run -it --rm --privileged --network=host -v /dev/:/dev/ --env UDEV=1 --device /dev:/dev --entrypoint /bin/bash ubuntu:20.04 apt-get update apt-get install wget -y wget https://deb.nodesource.com/setup_20.x bash setup_20.x apt install -y gcc g++ make build-essential nodejs sox gstreamer1.0-tools gstreamer1.0-plugins-good gstreamer1.0-plugins-base gstreamer1.0-plugins-base-apps vim v4l-utils usbutils udev apt-get install npm -y npm install edge-impulse-linux -g --unsafe-perm /lib/systemd/systemd-udevd --daemon
- After running above commands successfully, I ran below command to connect with Edge Impulse project. This asked to enter my Edge Impulse account's email and password. Once successfully logged in, it listed all my projects and I selected a new one created for this project.
edge-impulse-linux
Note: I had created a new project in this link - https://studio.edgeimpulse.com/studio/profile/projects?autoredirect=1 after logging in or signing up for an Edge Impulse account, by providing project name and selecting project type and setting. - It then asked to select a microphone and while it was checking for connected webcam, it failed with the following error. Error - Failed to initialize linux tool Error: Cannot find any webcams. I tried a couple of commands for updating/ installing libraries. But the below set of commands seemed to have solved the issue and I was able to connect to the webcam.
git clone https://gitlab.freedesktop.org/gstreamer/gstreamer.git cd gstreamer sudo apt install gcc g++ make build-essential nodejs sox gstreamer1.0-tools gstreamer1.0-plugins-good gstreamer1.0-plugins-base gstreamer1.0-plugins-base-apps sudo npm install edge-impulse-linux -g --unsafe-perm
- After auto selection of camera module, then gave a name to the device and the steps required for setup is completed.
I was able to see the Raspberry Pi device successfully added to my Edge Impulse project.
Edge Impulse - Testing Data Acquisition
I was able to successfully test Data Acquisition as well. Below is a screenshot of the same. I have also manually created a bounding box and labelled it as a resistor. Since I'll be using object detection to find items in my inventory.
Edge Impulse - Training, Testing, and Deploying the model
- Data Acquisition - I then sampled a few more pieces of data and made one sample as test data.
- Create Impulse - I then created below Impulse with the following steps - resizing the image to 96x96, an image preprocessing block, then added an object detection learning block, output it automatically selected the name of the items (resistor/ capacitor).
- Image - Then I generated features using the training data set.
- Object Detection - I then trained the model (FOMO (Faster Objects, More Objects) MobileNetV2 0.35) using the default settings. Below screenshot shows the training output and model summary.
- Live Classification - Then I did a quick live classification and could see the model was able to find the capacitor but not the resistor. Anyways, I'll be loading more dataset and training the model again. For starters, the flow is working as expected. Below screenshot shows the live classification outcome.
- Deployment - Ran the below command in the terminal of Raspberry Pi and below is the outcome of the same.
edge-impulse-linux-runner
In case of any challenges, you can refer to this official documentation - https://docs.edgeimpulse.com/docs/edge-ai-hardware/cpu/raspberry-pi-4. Stay tuned for more!