Version: TensorFlow 2.4.1
Encode: UTF-8
GPU/XNNPACK acceleration not supported, yet.
20210401:
-
Refactored the way the project was built. Now every project has its own Makefile, which is placed in the folder of the corresponding project.
The syntax for building a project is still./build_project.sh <project name>
-
Modified the Makefile of the sample project. Now each project can add multiple source file directories in the
SRC_DIRS
variable of Makefile.
-
Give the project build script
./build_project.sh
execute permission:chmod +x ./build_project.sh
-
Create your tf-lite project in the
./project
directory. You can refer to existing sample projects.
The name of the project folder is your project name. -
Write the project code and Makefile.
-
Execute the build script:
./build_project.sh <project name> # Please do not use the source ./build_project.sh or. ./build_project.sh command, the exit command in the script will cause the current ssh window to exit
-
The generated project will be in the
./build
directory.
This is an example of running the MobileNetV3 target recognition network model.
- Build the sample project:
./build_project.sh label_image_tf1.14
- Copy the network model, label, data set and test picture to the project build directory:
cp -r ./project/label_image_tf1.14/data ./build/label_image_tf1.14/
- Switch to the directory where the test picture is located:
cd ./build/label_image_tf1.14/data
- Run the MobileNetV3 network model and perform target recognition on
dogs.bmp
:../bin/label_image_tf1.14 -m ./mobnet_v3_coco_official.tflite -l ./labelmap.txt -i dogs.bmp -o 1 -t 1
Note: The image file input to the model must be in bmp format, and can only be a file name without path. The output picture is in the current directory, such as out_dogs.bmp
.
Cross compile toolchain (use toolchain 6.5.0 in tar.gz):
CC/CXX/AR variables need to be set in Makefile.
/your/path/to/rpi-newer-crosstools/x64-gcc-6.5.0/arm-rpi-linux-gnueabihf/bin/arm-rpi-linux-gnueabihf-gcc
/your/path/to/rpi-newer-crosstools/x64-gcc-6.5.0/arm-rpi-linux-gnueabihf/bin/arm-rpi-linux-gnueabihf-g++
/your/path/to/rpi-newer-crosstools/x64-gcc-6.5.0/arm-rpi-linux-gnueabihf/bin/arm-rpi-linux-gnueabihf-ar
More info about cross-compiling tensorflowlite library on rpi zero (already compiled in our environment):
https://blog.csdn.net/weixin_41973774/article/details/114807080 (in Chinese)