3 cool machine learning projects using TensorFlow and the Raspberry Pi

TensorFlow and the Raspberry Pi are working together in the city and on the farm. Learn about three recent, innovative projects.
775 readers like this.
3 cool machine learning projects using TensorFlow and the Raspberry Pi


In early 2017, the Raspberry Pi Foundation announced a Google developer survey, which requested feedback from the maker community on what tools they wanted on the Raspberry Pi. The blog post says that Google has developed tools for machine learning, IoT, wearables, robotics, and home automation, and that the survey mentions face- and emotion-recognition, speech-to-text translation, natural language processing, and sentiment analysis. "The survey will help them get a feel for the Raspberry Pi community, but it'll also help us get the kinds of services we need," the post explains. Meanwhile, data scientists aren't waiting around to put Google's TensorFlow, an open source software library for machine learning, to work on the Raspberry Pi.

    Let's take a look at a few cool examples of machine learning with TensorFlow on the Raspberry Pi.

    Caltrain project

    The Caltrain project is a Silicon Valley Data Science trainspotting project. In an introduction to the project article series, data scientists Chloe Mawer, Matthew Rubashkin, and Colin Higgins write, "Our interest stems from the fact that half of our employees rely on the Caltrain to get to work each day. We also want to give back to the community, and we love when we can do that with data."

    Because delay estimates provided by Caltrain "can be a bit ... off" (their words), the team wanted to integrate new data sources for delay predictions beyond what was available from Caltrain's API. They outline three questions they wanted an IoT Raspberry Pi train detector to answer:

    1. Is there a train passing?
    2. Which direction is it going?
    3. How fast is the train moving?

    Then they broke their process into a series of posts, which includes Image Processing in Python and Streaming Video Analysis with Python.

    Then, in TensorFlow Image Recognition on a Raspberry Pi, Rubashkin writes, "When we set up a new Raspberry Pi in our Mountain View office, we ran into a big problem: the Pi was not only detecting Caltrains (true positive), but also detecting Union Pacific freight trains and the VTA light rail (false positive). In order to reliably detect Caltrain delays, we would have to reliably classify the different trains." He says 2016 was a good year to run into this classification problem because several deep learning image recognition technologies had been released as open source projects, including Google's TensorFlow.

    To get experience creating an image classifier using TensorFlow, Rubashkin used the flowers tutorial on the tutorials page in TensorFlow for Poets, by Pete Warden. Then to get the train training data set, Rubashkin used 1,000 images from Google Images to create a vehicle classifier for Caltrains, freight trains, light rail, trucks, and cars. See the TensorFlow training action in this video:

    Read TensorFlow Image Recognition on a Raspberry Pi to learn more about how the Rubashkin tested and deployed the model, and his experience troubleshooting TensorFlow on the Raspberry Pi.

    Meter Maid Monitor

    At the TechCrunch Disrupt Hackathon in September 2016, John Naulty introduced Meter Maid Monitor. On the project website, Naulty says Meter Maid Monitor, which combines TensorFlow image classification with a Raspberry Pi motion detection and speed-measuring program, is an effort to avoid parking tickets. "With this set of tools, one can park their car, knowing that a notification will arrive via text message notifying them of a passing metermaid," he explains. The idea is that this marks the official start of their two-hour parking time limit.

    When an image of a moving car in the field of view is captured, it gets analyzed by TensorFlow with trained data (to recognize the meter maid vehicles). If the image is a meter maid match, a message gets sent via Twilio with a link to the image. Naulty includes the disclaimer, "This is a free, open source project and the developers are in no way accountable for parking tickets because of rebellious, citation-breaking citizens."

    Check out the project on GitHub, or watch the TechCrunch Disrupt Hackathon video for Naulty's brief presentation:

    TensorFlow on the farm

    TensorFlow isn't only for city slickers—it comes in handy on the farm, too. Makoto Koike, a former embedded systems designer from the Japanese automobile industry, started helping out at his parents' cucumber farm. An article on the Google Cloud Platform blog, How a Japanese cucumber farmer is using deep learning and TensorFlow, explains that Koike's mother spent up to eight hours a day sorting cucumbers by characteristics such as size, thickness, color, texture, small scratches, and whether they have prickles, which command higher prices on the market.

    "The system uses Raspberry Pi 3 as the main controller to take images of the cucumbers with a camera, and in a first phase, runs a small-scale neural network on TensorFlow to detect whether or not the image is a cucumber," the article explains. "It then forwards the image to a larger TensorFlow neural network running on a Linux server to perform a more detailed classification."

    Read the article to learn more about how the project works, or watch the video to see the sorter in action:

    Do you know about other cool projects using TensorFlow and the Raspberry Pi? Let us know about them in the comments, or send your story idea to us at open@opensource.com.

    User profile image.
    Rikki Endsley is the Developer Program managing editor at Red Hat, and a former community architect and editor for Opensource.com.

    Comments are closed.

    Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.