Appendix A. Using and Generating an Arduino Library Zip

The Arduino IDE requires source files to be packaged in a certain way. The TensorFlow Lite for Microcontrollers Makefile knows how to do this for you, and can generate a .zip file containing all the source, which you can import into the Arduino IDE as a library. This will allow you to build and deploy your application.

Instructions on generating this file appear later in this section. However, the easiest way to get started is to use a prebuilt .zip file that is generated nightly by the TensorFlow team.

After you’ve downloaded that file, you need to import it. In the Arduino IDE’s Sketch menu, select Include Library→Add .ZIP Library, as shown in Figure A-1.

Screenshot of the Add .ZIP Library menu option
Figure A-1. The “Add .ZIP library…” menu option

In the file browser that appears, locate the .zip file and click Choose to import it.

You might instead want to generate the library yourself—for example, if you made changes to the code in the TensorFlow Git repository that you’d like to test out in the Arduino environment.

If you need to generate the file yourself, open a terminal window, clone the TensorFlow repository, and change into its directory:

git clone https://github.com/tensorflow/tensorflow.git
cd tensorflow

Now run the following script to generate the .zip file:

tensorflow/lite/micro/tools/ci_build/test_arduino.sh

The file will be created at the following location:

tensorflow/lite/micro/tools/make/gen/arduino_x86_64/ 
  prj/micro_speech/tensorflow_lite.zip

You can then import this .zip file into the Arduino IDE using the steps documented earlier. If you’ve previously installed the library, you’ll need to remove the original version first. You can do this by deleting the tensorflow_lite directory from the Arduino IDE’s libraries directory, which you can find under “Sketchbook location” in the IDE’s Preferences window.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.181.146