How To Run ML Applications On Particle Hardware

With the release of TensorFlow Lite at Google I/O 2019, the accessible machine learning library is no longer limited to applications with access to GPUs. You can now run machine learning algorithms on microcontrollers much more easily, improving on-board inference and computation.

[Brandon Satrom] published a demo on how to run TFLite on Particle devices (tested on Photon, Argon, Boron,  and Xenon) making it possible to make predictions on live data with pre-trained models. While some of the easier computation that occurs on MCUs requires manipulating data with existing equations (mapping analog inputs to a percentage range, for instance), many applications require understanding large, complex sets of sensor data gathered in real time. It’s often more difficult to get accurate results from a simple equation.

The current method is to train ML models on specialty hardware, deploy the models on cloud infrastructure, and backhaul sensor data to the cloud for inference. By running the inference and decision-making on-board, MCUs can simply take action without backhauling any data.

He starts off by constructing a simple TGLite model for MCU execution, using mean squared error for loss and stochastic gradient descent for the optimization. After training the model on sample data, you can save the model and convert it to a C array for the MCU. On the MCU, you can load the model, TFLite libraries, and operations resolver, as well as instantiate an interpreter and tensors. From there you invoke the model on the MCU and see your results!

[Thanks dcschelt for the tip!]

AI Phone App Learns Baseball Signals

Watching a sport can be a bit odd if you aren’t familiar with it. Most Americans, for example, would think a cricket match looked funny because they don’t know the rules. If you were not familiar with baseball, you might wonder why one of the coaches was waving his hands around, touching his nose, his ears, and his hat seemingly at random. Those in the know however understand that this is a secret signal to the player. The coach might be telling the player to steal a base or bunt. The other team tries to decode the signals, but if you don’t know the code that is notoriously difficult. Unless you have the machine learning phone app you can see in the video below.

If you are not a baseball fan, it works like this. The coach will do a number of things. Perhaps touch his cap, then his nose, brush his left forearm, and touch his lips. However, the code is often as simple as knowing one attention signal and one action signal. For example, the coach might tell you that if they touch their nose and then their lips, you should steal. Touching their nose and then their ear is a bunt. Touching their nose and then the bill of their cap is something else. Anything they do that doesn’t start with touching their nose means nothing at all. If the signal is this easy, you really don’t even need machine learning to decode it. But if it were more complicated — say, the gesture that occurs third after they touch their nose unless they also kick dirt at which point it means nothing — it would be much harder for a human to figure out.

Continue reading “AI Phone App Learns Baseball Signals”

Training Bats In The Random Forest With The Confusion Matrix

When exploring the realm of Machine Learning, it’s always nice to have some real and interesting data to work with. That’s where the bats come in – they’re fascinating animals that emit very particular ultrasonic calls that can be recorded and analysed with computer software to get a fairly good idea of what species they are. When analysed with an FFT spectogram, we can see the individual call shapes very clearly.

Creating an open source classifier for bats is also potentially useful for the world outside of Machine Learning as it could not only enable us to more easily monitor bats themselves, but also the knock on effects of modern farming methods on the natural environment. Bats feed on moths and other night flying insects which themselves have been decimated in numbers. Even in the depths of the countryside here in the UK these insects are a fraction of the population that they used to be 30 years ago, but nobody seems to have monitored this decline.

So getting back to our spectograms, it would be perfectly reasonable to throw these images at a convolutional neural network (CNN) and use an image feature-recognition strategy. But I wanted to explore the depths of the mysterious Random Forest. Continue reading “Training Bats In The Random Forest With The Confusion Matrix”

Colorizing Images With The Help Of AI

The world was never black and white – we simply lacked the technology to capture it in full color. Many have experimented with techniques to take black and white images, and colorize them. [Adrian Rosebrock] decided to put an AI on the job, with impressive results.

The method involves training a Convolutional Neural Network (CNN) on a large batch of photos, which have been converted to the Lab colorspace. In this colorspace, images are made up of 3 channels – lightness, a (red-green), and b (blue-yellow). This colorspace is used as it better corresponds to the nature of the human visual system than RGB. The model is then trained such that when given a lightness channel as an input, it can predict the likely a & b channels. These can then be recombined into a colorized image, and converted back to RGB for human consumption.

It’s a technique capable of doing a decent job on a wide variety of material. Things such as grass, countryside, and ocean are particularly well dealt with, however more complicated scenes can suffer from some aberration. Regardless, it’s a useful technique, and far less tedious than manual methods.

CNNs are doing other great things too, from naming tomatoes to helping out with home automation. Video after the break.

Continue reading “Colorizing Images With The Help Of AI”

Finding Pre-Trained AI In A Modelzoo Using Python

Training a machine learning model is not a task for mere mortals, as it takes a lot of time or computing power to do so. Fortunately there are pre-trained models out there that one can use, and [Max Bridgland] decided it would be a good idea to write a python module to find and view such models using the command line.

For the uninitiated, Modelzoo is a place where you can find open source deep learning code and pre-trained models. [Max] taps into the (undocumented) API and allows a user to find and view models directly. When you run a utility, it goes online and retrieves the categories and then details of the available models. From then on, the user can select a model and the application will simply open the corresponding GitHub repository. Sounds simple but it has a lot of value since the code is designed to be extendable so that users working on such projects may automate the downloading part as well.

We have seen projects with machine learning used to detect humans, and with AI trending community tools such as this one help beginners get started even faster.

Tracking Ants And Zapping Them With Lasers

Thanks to the wonders of neural networks and machine learning algorithms, it’s now possible to do things that were once thought to be inordinately difficult to achieve with computers. It’s a combination of the right techniques and piles of computing power that make such feats doable, and [Robert Bond’s] ant zapping project is a great example.

The project is based around an NVIDIA Jetson TK1, a system that brings the processing power of a modern GPU to an embedded platform. It’s fitted with a USB camera, that is used to scan its field of view for ants. Once detected, thanks to a little OpenCV magic, the coordinates of the insect are passed to the laser system. Twin stepper motors are used to spin mirrors that direct the light from a 5 mW red laser, which is shined on the target. If you’re thinking of working on something like this we highly recommend using galvos to direct the laser.

Such a system could readily vaporize ants if fitted with a more powerful laser, but [Robert] decided to avoid this for safety reasons. Plus, the smell wouldn’t be great, and nobody wants charred insect residue all over the kitchen floor anyway. We’ve seen AIs do similar work, too – like detecting naughty cats for security reasons.

Continue reading “Tracking Ants And Zapping Them With Lasers”

BeagleBone Deep Learning Video Demo

BeagleBoard often gets eclipsed by Raspberry Pi. Where the Pi focuses on ease-of-use, the BeagleBone generally has more power for hardcore applications. With machine learning AI all the rage now, BeagleBoard now has the BeagleBone AI, a board with specific features aimed at machine learning. A recent video (see below) shows a demo of using TIDL (Texas Instruments Deep Learning Library). The video includes an example of streaming video to a browser and using predefined learning models to identify things picked up by a web camera.

The CPU onboard is the TI Sitara AM5729. That’s a dual Arm Cortex A15 running at 1.5 GHz. There are also two C66x floating-point DSP processors and two dual ARM Cortex M4 coprocessors. Still need more? You get four embedded vision engines, two dual-core real-time units, a 2D graphics accelerator, a 3D graphics accelerator, and a subsystem for encoding and decoding video and cryptography.

Continue reading “BeagleBone Deep Learning Video Demo”