621cef65577a2946040180bc - IoT Gets An ML Boost From Edge To Cloud
621cef65577a2946040180bc - IoT Gets An ML Boost From Edge To Cloud
IoT Gets an ML
Boost, From
Edge to Cloud
Today, It’s Easy to Run Edge Impulse Machine
Learning on Any OS, Like The Linux-Powered
Raspberry Pi, And On Every Cloud, Like
Microsoft’s Azure IoT.
2021
1
IOT GETS AN ML BOOST, FROM EDGE TO CLOUD
Today, It’s Easy To Run Building enterprise-grade IoT hosted solution backend to
Edge Impulse Machine solutions takes a lot of practical connect virtually any device. For
effort and a healthy dose of our hardware, we selected the
Learning on Any
imagination. As a foundation, ubiquitous Raspberry Pi 4, and of
OS, Like The Linux-
you start with a highly secure course Edge Impulse, which will
Powered Raspberry Pi,
and reliable communication connect to both platforms and
And On Every Cloud, between your IoT application extend our showcased solution
Like Microsoft’s Azure and the devices it manages. We from cloud to edge, including
IoT picked our favorite integration, device authentication, out-of-box
the Microsoft Azure IoT Hub, device management, and model
- Evan Rust that provides us with a cloud- provisioning.
FROM EDGE TO have cloud connectivity. The devices directly from the Azure
CLOUD - GETTING second group is often expensive IoT Hub, and run - fast.
2
IOT GETS AN ML BOOST, FROM EDGE TO CLOUD
3
IOT GETS AN ML BOOST, FROM EDGE TO CLOUD
Since this project deals with images, we’ll need some the Edge Impulse Studio and create a new project,
way to capture them. The wizard supports both the then run the wizard with
Pi Camera modules and standard USB webcams, so `$ edge-impulse-linux`
make sure to enable the camera module first with and make sure your device appears within the Edge
`$ sudo raspi-config` Impulse Studio’s device section after logging in and
If you plan on using one. With that completed, go to selecting your project.
CAPTURING
YOUR DATA
Training accurate machine learning
models requires feeding plenty of
varied data, which means a lot of
images are required. For this use
case, I captured around 50 images of
a wheel that had lug nuts on it. After
I was done, I headed to the Labeling
queue in the Data Acquisition page
and added bounding boxes around
each lug nut within every image, along
with every wheel.
4
IOT GETS AN ML BOOST, FROM EDGE TO CLOUD
5
IOT GETS AN ML BOOST, FROM EDGE TO CLOUD
INTEGRATING YOUR MODELS make sure you’ve installed the Azure CLI and have
signed in using `az login`. Then get the name of the
WITH MICROSOFT AZURE IOT resource group you’ll be using for the project. If you
don’t have one, you can follow this guide on how to
With the model working locally on the device, let’s create a new resource group. After that, return to the
add an integration with an Azure IoT Hub that will terminal and run the following commands to create a
allow the Pi to send messages to the cloud. First, new IoT Hub:
6
IOT GETS AN ML BOOST, FROM EDGE TO CLOUD
Retrieve the connection string with --device-id <your device id> --hub-name <your IoT
`$ az iot hub device-identity connection-string show Hub name>`
and set it as an environment variable with program will not work!) The connection string contains
`$ export IOTHUB_DEVICE_CONNECTION_ the information required for the device to establish a
STRING=”<your connection string here>”` connection with the IoT Hub service and communicate
in the Pi’s SSH session, as well as with it. You can then monitor output in the Hub with
`$ pip install azure-iot-device` `$ az iot hub monitor-events --hub-name <your IoT Hub
to add the necessary libraries. (Note: if you do not set name> --output table`
the environment variable or pass it in as an argument the or in the Azure Portal.
7
IOT GETS AN ML BOOST, FROM EDGE TO CLOUD
To make sure it works, download and run this libportaudio2 libportaudiocpp0 portaudio19-dev
example to make sure you can see the test message. $ pip3 install edge_impulse_linux -i https://pypi.
For the second half of deployment, we’ll need a way python.org/simple
to customize how our model is used within the code.
```
Thankfully, Edge Impulse provides a Python SDK for
There’s some simple code that can be found here on
this purpose. Install it with
Github, and it works by setting up a connection to
```
$ sudo apt-get install libatlas-base-dev libportaudio0 the Azure IoT Hub and then running the model.
Once you’ve either downloaded the zip file or `modelfile.eim`. Now, run the Python program with
cloned the repo into a folder, get the model file by `$ python lug_nut_counter.py ./modelfile.eim -c
running <LUG_NUT_COUNT>`
`$ edge-impulse-linux-runner --download modelfile. where `<LUG_NUT_COUNT>` is the correct number
eim` of lug nuts that should be attached to the wheel
inside of the folder you just created from the (you might have to use `python3` if both Python 2
cloning process. This will download a file called and 3 are installed).
8
IOT GETS AN ML BOOST, FROM EDGE TO CLOUD
Now whenever a wheel is detected the number short of the target, a message is sent to the
of lug nuts is calculated. If this number falls Azure IoT Hub.
9
IOT GETS AN ML BOOST, FROM EDGE TO CLOUD
And by only sending messages when there’s amount of bandwidth from being taken due to
something wrong, we can prevent an excess empty payloads.
Imagine utilizing object detection for an industrial and services between the cloud and the edge, and
task such as quality control on an assembly line, benefit from advanced analytics on devices running
or detecting ripe fruit amongst rows of crops, offline or with intermittent connectivity. And if
machinery malfunction and remote, battery- you’re really looking to scale your operation and
powered inferencing devices. Between Edge enjoy a complete dashboard view of the device
Impulse, hardware like Raspberry Pi, and the fleets you manage, it is also possible to receive IoT
Microsoft Azure IoT Hub, you can design endless alerts in Microsoft’s Connected Field Service from
models and deploy them on every device, while Azure IoT Central - directly.
credentials for each of your connected devices here on GitHub and create a fork or add to it.
10
IOT GETS AN ML BOOST, FROM EDGE TO CLOUD
The complete project is available here. Let us know your thoughts at [email protected].
There are no limits, just your imagination at work.
Edge Impulse
3031 Tisch Way
110 Plaza West
San Jose, CA 95128
USA