Wezley Sherman Pens a Guide to Getting Started with TensorFlow Lite and PlatformIO on the ESP32

Rather than rely on an Adafruit library, Sherman has written a guide to installing TensorFlow Lite and using PlatformIO manually.

Software engineer Wezley Sherman has published a guide to using the TensorFlow Lite machine learning platform on the Espressif ESP32 microcontroller module — without the need to install an Adafruit-specific library.

"When I realized that TensorFlow Lite supports microcontrollers, I flipped my desk — with excitement," Sherman explains. "I have a couple of the ESP32-CAM modules that I’m wanting to use with a home security system. My idea is to deploy a model that recognizes people and starts recording as soon as the camera picks up on a person. I don’t want to use motion-sensing here because I have a dog who would just trip the sensors.

"I see TensorFlow Lite as being a great tool for this use-case. I can train a model to recognize people on my desktop, and then deploy it to my ESP32-CAM modules."

Sherman found a fly in the ointment for his use-case, however: To use TensorFlow Lite on the ESP32 through the PlatformIO integrated development environment is just one command — platformio lib install tfmicro — providing you want to use an Adafruit-provided library. "I don’t," Sherman notes. "With some careful trial and error, I was able to get TensorFlow Lite to play nice with PlatformIO on the ESP32."

The guide resulting from Sherman's experiments walks through the installation of PlatformIO from the pip Python package manager, the creation of a custom project, editing said project's configuration for the ESP32, then cloning the TensorFlow GitHub repository. The secret sauce: "Generate one of the sample ESP32 projects from the TensorFlow Lite folder. We want to generate a sample project," Sherman says, "so we can grab the tfmicro library that is generated and the sample model."

This sample model is then copied over to the new project, the required third-party libraries copied over, and a header file modified. "You are now done," Sherman concludes. "The only thing that’s left to do is import and use TensorFlow Lite in a project."

Sherman's full guide, including a walkthrough in creating a sample "Hello World" project to ease the reader into using TensorFlow Lite, is now available on Towards Data Science.

Gareth Halfacree
Freelance journalist, technical author, hacker, tinkerer, erstwhile sysadmin. For hire: freelance@halfacree.co.uk.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles