Out-of-the-box artificial intelligence at the edge
You’ve probably gathered by now that I’m a big fan of edge computing for machine learning. But that doesn’t mean there isn’t a place for the cloud. While some devices like the Coral Dev Board from Google is capable of transfer learning on the device, at the edge, that isn’t that common. At least not yet. For the foreseeable future the cloud is where training will happen, and data will be stored. That is, if you need to store data at all.
The SmartEdge Agile follows this model and is what I normally refer to as a “blended” device. It sits at the edge, and is capable of talking to the cloud through a local gateway. But it’s also able to run machine learning inferencing locally at the edge — no network connection or cloud needed.
Opening the Box
The SmartEdge Agile comes in a ‘retail ready’ blister pack.
Inside the pack is the SmartEdge Agile device,
along with a USB-C to USB-A cable. That’s it.
As the battery in your SmartEdge Agile device probably isn’t charged, you should go ahead and plug it into a charger now using the cable. When you do so, a red LED should come on the far end from the cable connector.
Signing Up to the Cloud
The first thing you need to get started with the SmartEdge Agile is agree to some click wrap licensing and sign up to the Brainium portal. You’ll then be asked to enter your email address and you’ll be sent a code which you’ll use to create your account.
When you sign up, you’ll get up to 180 days of free portal usage, 16GB of cloud storage, or 2GB of ‘meta-sensing’ traffic — whichever comes first. It’s not made entirely clear what happens after this period, as all the FAQ has to say on this is that “…you can keep your data created during the six months free period. If you want to continue using your AGILE or move to an industrialisation phase, you should contact your Avnet local sales representative.”
After you sign in, you’ll be walked through some basic instructions on how to use the portal, and prompt you to install the gateway application.
Installing the Brainium Gateway
The SmartEdge Agile uses Bluetooth to talk to a local gateway which will serve as a proxy for traffic back up into the cloud. You can either use your phone, there is a gateway application for both iPhone and Android, or so long as it has Bluetooth on board, a Raspberry Pi.
Two versions of the Raspberry Pi application are available — one is command line based, the other has a GUI. Since I pretty much always use my Raspberry Pi boards headless, I’m going to go for the command line version.
Go ahead and download the latest release of Raspbian Lite and set up your Raspberry Pi. Unless you’re using wired networking, or have a display and keyboard attached to the Raspberry Pi, at a minimum you’ll need to put the Raspberry Pi on to your wireless network, and enable SSH.
Once you’ve set up your Raspberry Pi, go ahead and power it on, and then open up a Terminal window on your laptop and SSH into the Raspberry Pi.
% ssh firstname.lastname@example.org
Once you’ve logged in you might want to change the hostname to something less generic, to let you tell it apart from all the other Raspberry Pi boards on your network, using the raspi-config application. I chose brain.
You should probably go ahead and rename the gateway to something a bit more memorable by clicking on the pencil icon next to the gateway’s default name. I chose to call mine Raspberry Pi.
Adding Your SmartEdge Agile
Click on the plus icon in the devices column next to your gateway in the Portal. This will take you through to some click-wrap reminding you about the terms of the “discovery period,” click on the ‘Agree’ button and your gateway will start looking for your SmartEdge Agile device.
Turn on your SmartEdge Agile device by pressing the button on the end underneath the red charging LED. Press and hold for around two seconds.
Once the device turns on, the LED next to the button will start blinking blue, and after a few seconds of that it should be discovered by your Gateway and appear in your Portal.
Select the new device and hit the ‘Connect’ button. A few seconds will pass while the Gateway and SmartEdge Agile device are paired. But afterwards you should see something like this:
You can go ahead, and as we did with the gateway, rename our device to something a bit more memorable. I chose to call mine Module.
You can confirm that the device is properly connected by opening the gateway application on your Raspberry Pi and checking with the gw command. This will also show you how charged your SmartEdge Agile is and whether it’s still connected to the charger.
Hit the ‘Close’ button in the Portal to return to the main screen.
Your First Project
The SmartEdge Agile is what I generally call a ‘blended’ device for machine learning. Like Google’s Coral hardware, or other edge devices I’ve talked about in the past, you build your machine learning model in the cloud and deploy it to the edge. The portal is just for training and data storage.
Click on the Projects icon, and then on the ‘Create Project’ button.
Name your project something memorable, I just went with ‘Test Project.’
Then once you’re back in the main Portal screen, click on your newly created project. You’ll see that there aren’t any devices initially connected.
Click on the big purple ‘+’ button in the bottom right of the screen. You’ll be presented with a dialog that let’s you add your device to the project.
Select your device and you’ll be presented an ‘Add to the Project’ button. Click the button and your SmartEdge Agile device will be added to the project.
You’ll see the module and gateway, along with the list of sensors available.
Adding Some Machine Learning
Now we have a project, and a device attache to it, you can add some machine learning. Click on the ‘Motion Recognition’ button in the Portal menu bar.
This will bring you to the AI Studio Workspace. Now go ahead and click on that big purple ‘+’ in the bottom right of your browser again. This will let you create a new Workspace, I called mine ‘Motions.’
After creating the new workspace, click on it in the Portal and you’ll be presented with a screen, allowing you to create a number of motions.
I chose to create a circle motion, but the label you add here isn’t really relevant. It’s just a human readable tag to a corpus of training data.
Now we’ve created that label however, we should add some data. Go ahead and click on the ‘Record new training set’ button in the top right of your browser window.
Select your module from the drop down list of devices, and set the ‘number of motions’ to 10 for this training session.
Now unplug your SmartEdge Agile device from its charger if it’s still plugged in, pick it up in one hand and hit the ‘Start’ button. You’ll be presented with a training screen. Carry out the motion with the SmartEdge Agile in your hand, we picked a circular one earlier.
Once you’re done, hit the ‘Recording’ button in the top left of your browser window. You’ll be presented with a dialog to save your training data. Hit the ‘Save’ button and you’ll be returned to the Workspace screen.
You can click on the ‘Processing’ status line underneath the record name to check on progress. Eventually you should see something like this,
so we should go ahead and generate a second set of training data in the same way as before. Afterwards by selecting both sets of data we can now click on the ‘Generate Your Model’ button to train our machine learning model.
This will take a while depending on how much training data and how many gestures we’re training against. After training is finished you should see something like this:
Now we have a model we can go back to our project screen, and click on the ‘Devices’ tab. Then click on the ‘AI Studio Rules’ section of the Device entry,
and we can select our Workspace and Model. Click the ‘Apply’ button.
Afterwards, click on the “Add New AI Rule” button that is presented. This will let us generate alerts, emails, or link to an action in IFTTT when our ‘circle’ motion is detected. For now let’s just go with an ‘Alert.’
After adding the new rule, you can close the popup by clicking on the cross in the top right of the browser window.
Then click on the ‘Data Tracking/Recording’ tab, and hit the ‘Create Widget’ button to create a new widget so we can see our alerts.
We’re going to create an ‘AI Widget’ called ‘Motions’ that will show the details of the last motion detected by our model running on the SmartEdge Agile.
Go ahead and associate it with our device, hit ‘Finish’ and you’ll be returned to the main Portal page. Hit the ‘Start Tracking’ button, and add your device.
Hit the ‘Start Tracking’ button and you’ll be returned to the main Portal screen again. However this time we’re waiting for events from our model on the SmartEdge Agile device. Go ahead and make some circles, I’ll wait.
When a circle motion is detected you should be presented with a notification in our widget. Congratulations, it all works. You can hit ‘Stop Tracking’ now.
You’ll also be able to see a record of the events in the Alerts drop down.
Stepping Out of the Portal
While the Portal offers a lot of flexibility, and linking out to IFTTT means that there is even more as you can effectively trigger arbitrary events using the Makers Channel, if you want to go further then there is a developer API.
There are two different APIs available for the end users. There is a REST API which provides access to historical data, and a MQTT API over WebSockets which provides access to data in real-time and to events.