|Author||TensorFlow Authors, Pete Warden firstname.lastname@example.org|
|Maintainer||Brandon Satrom email@example.com|
|All Versions||0.1.1, 0.1.0, 0.0.2, 0.0.1|
Allows you to run machine learning models locally on your device. This library runs TensorFlow machine learning models on microcontrollers, allowing you to build AI/ML applications powered by deep learning and neural networks. With the included examples, you can recognize speech, detect people using a camera, and recognise "magic wand" gestures using an accelerometer. The examples work best with Particle Gen3 devices (Argon, Boron, Xenon), but some also work on the Photon and Electron.
This content is provided by the library maintainer and has not been validated or approved.
A library for using TensorFlow Lite for Microcontrollers with Particle devices. This library has been tested with the following Particle devices:
- Photon / P1
NOTE: While the TensorFlow Library itself has been tested with all of the devices above, not every example below runs on all of these devices. Model size if the main constraint here, so check the model size if you're having issues running an project.
To use TensorFlow Lite for Microcontrollers with your own models, you'll need to take the following steps, as detailed in the TensorFlow docs:
- Create or download a model.
- Convert the model to a a TensorFlow Lite FlatBuffer.
- Convert the FlatBuffer to a C byte array for inclusion in your project.
- Integrate this library into your project using the instructions below.
- Deploy your project to a Particle device.
For a complete walkthrough of the steps above, you can view one of the exercises in the TensorFlow docs, or check out the README for the linear_regression example for a step-by-step example of the model creation to MCU execution process.
This library is available for use on all Particle devices and can be installed using one of the following approaches.
To install this libraries from the Web IDE, open the libraries tab by clicking on the bookmark icon on the lower left of the screen.
Then, in the Community Libraries search box, type "TensorFlow" and click on the
Finally, click the "Include in Project" button and follow the prompts to pick the project in which to install this library.
If you're using Particle Workbench, first open the project you want to use with TensorFlow Lite. Then, open the Command Palette by typing CMD+SHIFT+P (macOX/Linux) or CTRL+SHIFT+P (Windows).
Search for the "Particle: Install Library" option and click it.
Type "TensorFlowLite" and hit enter. Workbench will install the library into a
lib directory at the root of your project and notify you when complete.
To install this library using the Particle CLI, run the following command from a Particle project directory.
$ particle library install TensorFlowLite Checking library TensorFlowLite... Installing library TensorFlowLite 0.1.0 to /Users/bsatrom/Particle/community/libraries/TensorFlowLite@0.1.0 ... Library TensorFlowLite 0.1.0 installed.
See the TensorFlow Lite for Microcontrollers docs for detailed instructions on running inference on embedded devices.
The source contains the following examples, some of which require additional hardware and may not run across all Particle devices (especially the Photon) due to model size constraints.
linear_regression- Runs a simple linear regression model (~1kb in size) to solve for the canonical "straight line equation"
y = mx + cgiven random
xvalues between 0 and 1. Outputs the result to an Adafruit 3.5" TFT FeatherWing. This example project also contains complete instructions that illustrate the process of building a model from scratch in TensorFlow and Keras, converting that model to TFLite and then a FlatBuffer format, and finally, building a project to execute that model on Particle MCUs. Tested on the Particle Photon and Xenon.
hello_world- Runs a simple sine wave model (2kb in size) to predict the next wave position. Uses the output to
analogWritethe waveform value to the onboard D7 LED. Tested on the Particle Photon and Xenon.
sine_with_screen- Runs the same sine wave model from the
hello_worldproject, and outputs the result to an Adafruit 3.5" TFT FeatherWing. Can easily be adapted to other displays.
micro_speech- Runs a speech detection model (18k in size) that can recognize the words "yes" and "no." Uses the output to flash the onboard D7 LED when "yes" is detected. Requires an electret microphone amplifier. This example is only supported on Particle 3rd gen devices (Argon, Boron, Xenon).
magic_wand- Runs a gesture detection model (18k in size) that can recognize 3 gestures: "wing" (draw a W from left to right), "ring" (draw a circle clockwise from top), and "slope" (draw two-sides of a triangle from top right). This example is only supported on Particle 3rd Gen devices (Argon, Boron, Xenon).
person_detection- Runs a person detection model (250k in size) that can detect a person in an image from a connected camera. Requires the ArduCam and dependent libraries. NOTE: This demo has been ported, but cannot currently be run on Particle devices as the model overflows available flash space significantly.