TinyML — How To Build Intelligent IoT Devices with Tensorflow Lite

machine learning Aug 31, 2020

When you combine large data sets with high computing power, these neural networks can understand patterns between data.

Deep learning has given rise to self-driving cars, personal assistants like Siri, and many others. Engineers are adopting deep learning models into their applications to solve complex problems for their customers.

Tensorflow is a leading Deep learning library developed by Google. It supports a variety of neural network models like Convolutional and Recurrent Neural Networks.

I recently wrote an article on Machine learning called “Machine Learning For Managers — What You Need To Know”. It should give you all the basics you need.

Embedded Systems

If hardware scares you, don't worry. I'll make this simple.

A microprocessor is a small computer similar to your CPU. The difference is that it is really tiny and can only perform low-level operations.

These tiny microprocessors are present in devices like your air-conditioner and your refrigerator. But microprocessors alone cannot do much. They need input through sensors and send outputs to perform an action.

When you press a button on your remote and change a channel on your TV, the device takes in an input, understands the command, and performs an operation. The combination of these sensors and the microprocessor is called Embedded Systems. (coz they are embedded together on a circuit board)

Embedded systems are present in devices like your smartphone, electric guitar, and many others we use on a daily basis.

Internet of Things (IoT)

IoT is any device connected to the internet. If your air conditioner is connected to the internet, you can turn it on/off from your office through a mobile app. That makes it an IoT device.

IoT devices are usually grouped together to perform various actions. A few examples would be:

  • Devices on a farm to check weeds and pests using cameras.
  • Traffic cameras for real-time monitoring
  • A network of drones to monitor a construction site.

There are pre-built embedded systems like Raspberry Pi and Arduino that come packaged with a microcontroller, sensors, support for wifi, and even a USB port. You can connect to them using a keyword and a monitor, just like you would do with a CPU.

What is TinyML

Most IoT devices perform a specific task. They take input through a sensor, perform computation, and send the data out or perform an action.

The usual approach to IoT is to collect data and send it to a centralized logging server. From here, you can use machine learning to draw conclusions.

But why don't we make these devices intelligent at the embedded system level? We can build solutions like smart traffic signals based on traffic density, send you an alert when your refrigerator goes out of stock, or even predict rainfall based on weather data.

The challenge with embedded systems in that they are tiny. And most of them run on battery power. Since machine learning models consume a lot of processing power, machine learning tools like Tensorflow are not well suited to build models on IoT devices.

This is where TinyML comes in.

TinyML can perform on-device analysis of sensor inputs with extremely low power. With hardware improvements and the advancements in TinyML tools like Tensorflow Lite, it is now possible to install intelligence in these tiny devices.

Tensorflow Lite

So how do you achieve TinyML? There are a few tools that help us run machine learning models on IoT devices.

The most famous one is Tensorflow Lite. With Tensorflow Lite, you can wrap your Tensorflow models to run on embedded systems. Tensorflow Lite will give you small sized binaries capable of running on low powered embedded systems.

Tensorflow Lite also supports major platforms including Android, iOS, Arduino, and so on.

Python is usually the preferred language to build machine learning models. But with TensorFlow Lite, you can use C, C++ or Java to build machine learning models.

Connecting to the network is a power-consuming operation. With Tensorflow Lite, you can deploy machine learning models without the need to connect to the internet. This also solves security concerns since embedded systems are relatively easier to exploit.

Tensorflow Lite offers pre-trained machine learning models for common use cases. These include:

  • Object Detection — Recognizes multiple objects within an image. Supports up to 80 different classes of objects.
  • Smart RepliesGenerates smart replies, similar to interacting with a chatbot.
  • RecommendationsPersonalized recommendation systems based on user behavior.

Alternatives

There are a few alternatives to Tensorflow Lite. Two strong contenders are:

  • CoreML — Apple’s library for building machine learning models on iOS devices.
  • PyTorch Mobile — Mobile version of Facebook’s deep learning library PyTorch.

Summary

TinyML is still in its early stages. There are improvements being made in Tensorflow Lite and other TinyML frameworks to support complex machine learning models.

It might take a couple of years before we begin to see the mainstream adoption of TinyML. But no mistake, intelligent devices are coming.

References


Loved this article? Join my Newsletter and get a summary of my articles and videos every Monday.

Tags

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.