How to Build DIY AI Projects Using Google TensorFlow and Raspberry Pi

Ian Buckley 11-09-2018

Machine learning is the topic on everyone’s lips. It’s easy to see why. It is the future of data manipulation and is already used in almost every modern business setting. But can it be combined with a Raspberry Pi? Is the Pi up to the task of sustaining a working neural network? With Google TensorFlow, it can!


Here’s how to install TensorFlow on a Raspberry Pi, with some examples of usage.

What Is TensorFlow?

Before diving into examples of how TensorFlow is used, it’s worth knowing what it actually is.

In short, TensorFlow is Google’s trainable neural network, which can perform many different tasks. By actively learning from a user-curated dataset, TensorFlow neural networks makes accurate predictions when given new data.

In short, TensorFlow neural networks think.

Check our list of Tensorflow examples What Is Google TensorFlow? Open-Source Examples and Tutorials TensorFlow, machine learning, and neural networks. Here's a quick overview of what it is, why it's useful, and how to learn it. Read More for more information.


How to Install TensorFlow

While understanding the subject of machine learning takes serious study, basic TensorFlow usage is easy to follow. Our Image Recognition with TensorFlow tutorial Get Started With Image Recognition Using TensorFlow and Raspberry Pi Want to get to grips with image recognition? Thanks to Tensorflow and a Raspberry Pi, you can get started right away. Read More covers installing the library onto your Pi. It also covers testing it, and running the basic Inception image classification program.

In this instance, TensorFlow provides an already trained neural network. All the user must do is input the correct data type, and TensorFlow will guess what the image contains. Even the basic implementation of TensorFlow is capable of classifying images into 1000 classes. It gets a surprising amount correct!

But what else can you do with TensorFlow on the Raspberry Pi?

Portable Image Recognition

We have covered how to make a smart webcam DIY Pan and Tilt Network Security Cam with Raspberry Pi Learn how to make remotely viewable pan and tilt security camera with a Raspberry Pi. This project can be completed in a morning with only the simplest of parts. Read More before, but this talking mobile image classifier takes it to a new level.


This detailed post outlines the hardware setup and custom software integrated with the Inception image classifier. The example code shows just how easy it is to integrate TensorFlow with a project (provided you are comfortable with the basics of the Python Programming language 5 Courses That'll Take You from Python Beginner to Pro These five courses will teach you all about programming in Python, one of the hottest languages out there right now. Read More ). The article goes into great detail about the process of image recognition. It is an excellent resource in general for anyone interested in the field.

One excellent element of this setup may not be initially clear:

“An added bonus many pointed out is that, once installed, no internet access is required.”

Previous image recognition has always relied on a huge amount of processing time, or an internet connection. A Pi cannot always pass off information to the cloud, and has limited processing power. This is the solution, a self-contained offline object recognizer you can make at home. It’ll even tell you what it is looking at. Isn’t the future marvelous?


TensorFlow Magic Mirror

Homemade smart (or “magic”) mirrors are about the coolest thing you can build How to Turn an Old Laptop Screen Into a Magic Mirror Smart mirrors are unique devices that you can use to inject some magic into your home. We show you how to build one with a Raspberry Pi. Read More . Requiring only a Pi and an old laptop screen along with basic DIY supplies, it’s a great beginner project. Alasdair Allan decided not to settle for the average smart mirror and built the TensorFlow magic mirror with voice recognition.

Unsatisfied with the cost of web-based speech recognition, Alasdair decided on TensorFlow as an offline alternative. Integrating TensorFlow’s pretrained voice recognition model into the already utilized AIY kit code adds custom wake words to the project.

Google assembled a dataset with over 65,000 crowdsourced words. This open-source dataset trained the neural net to understand some words.

In this case, it added several possible wake words but still runs into a familiar machine learning problem: it takes a lot of data to train a neural network.


Unless you are willing to create a unique dataset with tens of thousands of entries, you are limited to what is freely available. This project shows the limitations of TensorFlow on the Pi in its current state. It is fully functional but pushes the Pi’s computational capabilities. As with all new technologies, this early implementation is a glimpse into the future of smart home devices.

TensorFlow Autonomous RC Car

Given Google’s history with self-driving cars How Self-Driving Cars Work: The Nuts and Bolts Behind Google's Autonomous Car Program Being able to commute back and forth to work while sleeping, eating, or catching up on your favorite blogs is a concept that is equally appealing and seemingly far-off and too futuristic to actually happen. Read More , it is no surprise that TensorFlow is well suited to autonomous driving.

The DeepPiCar is an excellent example of this kind of neural network in action. Alongside standard remote control this Raspberry Pi robot features something altogether cleverer. Trained on a dataset provided on the GitHub project page, the network learns to stay on a predetermined track.

This project is not for beginners. The hardware required can be found in almost any cheap robot kit. The software implementation takes some more in-depth knowledge. You should have a good grasp of machine learning before taking it on.

Cucumber Auto-Sorter

One of the best-known deployments of TensorFlow on the Pi, Makoto Koike’s cucumber sorter is a sign of things to come.

The sorting of fresh produce for different markets is a massive cost for smaller providers. Sorting cucumbers by size and quality is a task which until recently could only be performed by a human operator. Machine sorting was very difficult to achieve, and costly. TensorFlow solves this problem by categorizing cucumbers in real time via camera.

Using over 7000 images of cucumbers, Makoto trained a neural network to distinguish between different types. In operation, webcams capture images from three angles. The Pi classifies the images, before forwarding them to a Linux server for further classification. The result triggers a conveyor belt and servo system which sorts the cucumbers into boxes.

The Start of Something Smart

We’ve seen Raspberry Pi’s used for everything 26 Awesome Uses for a Raspberry Pi Which Raspberry Pi project should you start with? Here's our roundup of the best Raspberry Pi uses and projects around! Read More , so it’s unsurprising that TensorFlow has arrived on it. The Pi struggles to keep up with the demands of machine learning, but it’s great for learning the basics What Is Machine Learning? Google's Free Course Breaks It Down for You Google has designed a free online course to teach you the fundamentals of machine learning. Read More .

Related topics: Google TensorFlow, Raspberry Pi.

Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.

Whatsapp Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *