88- OpenVINO 2021.*
99- TensorRT 8.x *
1010- ONNXRuntime *
11+ - Tensorflow Lite *
1112
12- ※ Either one of OpenVINO or TensorRT or ONNXRuntime is required.
13+ ※ Either one of OpenVINO or TensorRT or ONNXRuntime or Tensorflow Lite is required.
1314
1415※ ONNXRuntime support CPU or CUDA execute provider.
1516
17+ ※ Tensorflow Lite support XNNPACK Delegate only.
18+
19+ ※ Tensorflow Lite support float model and does not support integer model.
20+
1621※ Model convert script is not supported OpenVINO 2022.*
1722
1823※ YOLOX is not required.
@@ -144,6 +149,15 @@ source /opt/ros/foxy/setup.bash
144149./src/YOLOX-ROS/weights/onnx/download.bash yolox_nano
145150```
146151
152+ #### Tensorflow Lite
153+ ``` bash
154+ cd ~ /ros2_ws
155+
156+ # Download tflite Person Detection model
157+ # https://github.com/Kazuhito00/Person-Detection-using-RaspberryPi-CPU/
158+ ./src/YOLOX-ROS/weights/tflite/download_model.bash
159+ ```
160+
147161#### PINTO_model_zoo
148162- Support PINTO_model_zoo model
149163- Download model using the following script.
@@ -152,9 +166,12 @@ source /opt/ros/foxy/setup.bash
152166
153167- ONNX model copy to weight dir
154168 - ` cp resouces_new/saved_model_yolox_nano_480x640/yolox_nano_480x640.onnx ./src/YOLOX-ROS/weights/onnx/ `
169+
155170- Convert to TensorRT engine
156171 - ` ./src/YOLOX-ROS/weights/tensorrt/convert.bash yolox_nano_480x640 `
157172
173+ - tflite model copy to weight dir
174+ - ` cp resouces_new/saved_model_yolox_nano_480x640/model_float32.tflite ./src/YOLOX-ROS/weights/tflite/ `
158175
159176### build packages
160177``` bash
@@ -167,6 +184,46 @@ colcon build --symlink-install
167184source ./install/setup.bash
168185```
169186
187+
188+ #### build yolox_ros_cpp with tflite
189+
190+ ##### build tflite
191+ https://www.tensorflow.org/lite/guide/build_cmake
192+
193+ Below is an example build script.
194+ Please change ` ${workspace} ` as appropriate for your environment.
195+ ``` bash
196+ cd ${workspace}
197+ git clone https://github.com/tensorflow/tensorflow.git tensorflow_src
198+ mkdir tflite_build
199+ cd tflite_build
200+
201+ cmake ../tensorflow_src/tensorflow/lite \
202+ -DBUILD_SHARED_LIBS=ON \
203+ -DTFLITE_ENABLE_INSTALL=OFF \
204+ -DTFLITE_ENABLE_XNNPACK=ON \
205+ -DTFLITE_ENABLE_RUY=OFF \
206+ -DCMAKE_BUILD_TYPE=Release
207+
208+ make -j" $( nproc) "
209+ ```
210+
211+ ##### build ros package with tflite
212+
213+ This is build script when tflite built as above.
214+
215+ ``` bash
216+ # build with tflite
217+ colcon build --symlink-install \
218+ --packages-up-to yolox_ros_cpp \
219+ --cmake-args \
220+ -DYOLOX_USE_TFLITE=ON \
221+ -DTFLITE_LIB_PATH=${workspace} /tflite_build/libtensorflow-lite.so \
222+ -DTFLITE_INCLUDE_DIR=${workspace} /tensorflow_src \
223+ -DABSEIL_CPP_ICLUDE_DIR=${workspace} /tflite_build/abseil-cpp \
224+ -DFLATBUFFERS_INCLUDE_DIR=${workspace} /tflite_build/flatbuffers/include
225+ ```
226+
170227### Run
171228
172229#### OpenVINO
@@ -217,9 +274,26 @@ ros2 launch yolox_ros_cpp yolox_tensorrt_jetson.launch.py
217274ros2 launch yolox_ros_cpp yolox_onnxruntime.launch.py
218275```
219276
277+ #### Tensorflow Lite
278+ ``` bash
279+ # add libtensorflow-lite.so directory path to `LD_LIBRARY_PATH`
280+ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH :${workspace} /tflite_build
281+
282+ # run Person Detection Model
283+ ros2 launch yolox_ros_cpp yolox_tflite.launch.py
284+
285+ # run PINTO_model_zoo model
286+ ros2 launch yolox_ros_cpp yolox_tflite.launch.py \
287+ model_path:=install/yolox_ros_cpp/share/yolox_ros_cpp/weights/tflite/model_float32.tflite \
288+ model_version:=0.1.0 \
289+ num_classes:=80 \
290+ is_nchw:=false
291+ ```
292+
220293### Parameter
221294#### OpenVINO example
222295- ` model_path ` : ./install/yolox_ros_cpp/share/yolox_ros_cpp/weights/openvino/yolox_nano.xml
296+ - ` p6 ` : false
223297- ` class_labels_path ` : ""
224298 - if not set, use coco_names.
225299 - See [ here] ( https://github.com/fateshelled/YOLOX-ROS/blob/dev_cpp/yolox_ros_cpp/yolox_ros_cpp/labels/coco_names.txt ) for label format.
@@ -229,27 +303,29 @@ ros2 launch yolox_ros_cpp yolox_onnxruntime.launch.py
229303- ` conf ` : 0.3
230304- ` nms ` : 0.45
231305- ` imshow_isshow ` : true
232- - ` src_image_topic_name ` : image_raw
233- - ` publish_image_topic_name ` : yolox/image_raw
234- - ` publish_boundingbox_topic_name ` : yolox/bounding_boxes
306+ - ` src_image_topic_name ` : / image_raw
307+ - ` publish_image_topic_name ` : / yolox/image_raw
308+ - ` publish_boundingbox_topic_name ` : / yolox/bounding_boxes
235309
236310
237311#### TensorRT example.
238312- ` model_path ` : ./install/yolox_ros_cpp/share/yolox_ros_cpp/weights/tensorrt/yolox_nano.trt
313+ - ` p6 ` : false
239314- ` class_labels_path ` : ""
240315- ` num_classes ` : 80
241316- ` model_version ` : 0.1.1rc0
242317- ` tensorrt/device ` : 0
243318- ` conf ` : 0.3
244319- ` nms ` : 0.45
245320- ` imshow_isshow ` : true
246- - ` src_image_topic_name ` : image_raw
247- - ` publish_image_topic_name ` : yolox/image_raw
248- - ` publish_boundingbox_topic_name ` : yolox/bounding_boxes
321+ - ` src_image_topic_name ` : / image_raw
322+ - ` publish_image_topic_name ` : / yolox/image_raw
323+ - ` publish_boundingbox_topic_name ` : / yolox/bounding_boxes
249324
250325
251326#### ONNXRuntime example.
252327- ` model_path ` : ./install/yolox_ros_cpp/share/yolox_ros_cpp/weights/onnx/yolox_nano.onnx
328+ - ` p6 ` : false
253329- ` class_labels_path ` : ""
254330- ` num_classes ` : 80
255331- ` model_version ` : 0.1.1rc0
@@ -263,9 +339,24 @@ ros2 launch yolox_ros_cpp yolox_onnxruntime.launch.py
263339- ` conf ` : 0.3
264340- ` nms ` : 0.45
265341- ` imshow_isshow ` : true
266- - ` src_image_topic_name ` : image_raw
267- - ` publish_image_topic_name ` : yolox/image_raw
268- - ` publish_boundingbox_topic_name ` : yolox/bounding_boxes
342+ - ` src_image_topic_name ` : /image_raw
343+ - ` publish_image_topic_name ` : /yolox/image_raw
344+ - ` publish_boundingbox_topic_name ` : /yolox/bounding_boxes
345+
346+ #### Tensorflow Lite example.
347+ - ` model_path ` : ./install/yolox_ros_cpp/share/yolox_ros_cpp/weights/tflite/model.tflite
348+ - ` p6 ` : false
349+ - ` is_nchw ` : true
350+ - ` class_labels_path ` : ""
351+ - ` num_classes ` : 1
352+ - ` model_version ` : 0.1.1rc0
353+ - ` tflite/num_threads ` : 1
354+ - ` conf ` : 0.3
355+ - ` nms ` : 0.45
356+ - ` imshow_isshow ` : true
357+ - ` src_image_topic_name ` : /image_raw
358+ - ` publish_image_topic_name ` : /yolox/image_raw
359+ - ` publish_boundingbox_topic_name ` : /yolox/bounding_boxes
269360
270361
271362### Reference
0 commit comments