项目作者: cloudwiser

项目描述 :
TensorFlow Lite object detection example for Raspberry Pi 2+
高级语言: C++
项目地址: git://github.com/cloudwiser/ObjectDetectionRPi.git
创建时间: 2019-04-22T22:43:04Z
项目社区:https://github.com/cloudwiser/ObjectDetectionRPi

开源协议:Other

下载


TensorFlow Lite : label_image object detection on Raspberry Pi

This is a follow-on to compiling TensorFlow Lite for the Raspberry Pi as detailed at https://www.tensorflow.org/lite/guide/build_rpi

Having got the C++ minimal example code compiled, this extends the label_image example to demonstrate object detection and bounding box extraction using the SSD Mobilenet model trained against the COCO traning set

Copy the content in the ./example, ./make and ./bin sub-directories of this repo to the equivalent paths in your local ./tensorflow/tensorflow/lite/... directory structure (after backing up the original content)

Please note that label_image has not been tested with other quantized or non-quantized models and it expects 1 input tensor and 4 output tensors…so running it with other models may either fail this test and/or cause a runtime error during model load or invocation

If this does occur, it should be a case of adjusting the input and output tensor size checks and ensuring the correct handling of TfLite float or uint8_t output tensors

Once you have installed (and amended) the code, build it via…

  1. $ cd ~/tensorflow/tensorflow/lite/tools/make/
  2. $ ./build_rpi_armv7l_label_image.sh

and then run label_image as follows. Note: the -o 1 option writes the output image (with any above-threshold bounding boxes rendered) to an out file of the format out_<input_filename>

  1. $ cd ~/tensorflow/tensorflow/lite/tools/make/gen/rpi_armv7l/bin
  2. $ ./label_image -i fruit.bmp -m ./models/coco_ssd_mobilenet_v1_1.0_quant_2018_06_29/detect.tflite -l ./models/coco_ssd_mobilenet_v1_1.0_quant_2018_06_29/labelmap.txt -v 1
  3. $ ./label_image -i orange_banana_apple.bmp -m ./models/coco_ssd_mobilenet_v1_1.0_quant_2018_06_29/detect.tflite -l ./models/coco_ssd_mobilenet_v1_1.0_quant_2018_06_29/labelmap.txt -o 1

Run label_image with -h and/or read the source code for the complete set of command line options

This application is based on thelabel_image example code in the Tensorflow Lite repo at https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/examples/label_image



Sample BMP output showing objects detected above the threshold