8
8
- OpenVINO 2021.*
9
9
- TensorRT 8.x *
10
10
- ONNXRuntime *
11
+ - Tensorflow Lite *
11
12
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.
13
14
14
15
※ ONNXRuntime support CPU or CUDA execute provider.
15
16
17
+ ※ Tensorflow Lite support XNNPACK Delegate only.
18
+
19
+ ※ Tensorflow Lite support float model and does not support integer model.
20
+
16
21
※ Model convert script is not supported OpenVINO 2022.*
17
22
18
23
※ YOLOX is not required.
@@ -144,6 +149,15 @@ source /opt/ros/foxy/setup.bash
144
149
./src/YOLOX-ROS/weights/onnx/download.bash yolox_nano
145
150
```
146
151
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
+
147
161
#### PINTO_model_zoo
148
162
- Support PINTO_model_zoo model
149
163
- Download model using the following script.
@@ -152,9 +166,12 @@ source /opt/ros/foxy/setup.bash
152
166
153
167
- ONNX model copy to weight dir
154
168
- ` cp resouces_new/saved_model_yolox_nano_480x640/yolox_nano_480x640.onnx ./src/YOLOX-ROS/weights/onnx/ `
169
+
155
170
- Convert to TensorRT engine
156
171
- ` ./src/YOLOX-ROS/weights/tensorrt/convert.bash yolox_nano_480x640 `
157
172
173
+ - tflite model copy to weight dir
174
+ - ` cp resouces_new/saved_model_yolox_nano_480x640/model_float32.tflite ./src/YOLOX-ROS/weights/tflite/ `
158
175
159
176
### build packages
160
177
``` bash
@@ -167,6 +184,46 @@ colcon build --symlink-install
167
184
source ./install/setup.bash
168
185
```
169
186
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
+
170
227
### Run
171
228
172
229
#### OpenVINO
@@ -217,9 +274,26 @@ ros2 launch yolox_ros_cpp yolox_tensorrt_jetson.launch.py
217
274
ros2 launch yolox_ros_cpp yolox_onnxruntime.launch.py
218
275
```
219
276
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
+
220
293
### Parameter
221
294
#### OpenVINO example
222
295
- ` model_path ` : ./install/yolox_ros_cpp/share/yolox_ros_cpp/weights/openvino/yolox_nano.xml
296
+ - ` p6 ` : false
223
297
- ` class_labels_path ` : ""
224
298
- if not set, use coco_names.
225
299
- 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
229
303
- ` conf ` : 0.3
230
304
- ` nms ` : 0.45
231
305
- ` 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
235
309
236
310
237
311
#### TensorRT example.
238
312
- ` model_path ` : ./install/yolox_ros_cpp/share/yolox_ros_cpp/weights/tensorrt/yolox_nano.trt
313
+ - ` p6 ` : false
239
314
- ` class_labels_path ` : ""
240
315
- ` num_classes ` : 80
241
316
- ` model_version ` : 0.1.1rc0
242
317
- ` tensorrt/device ` : 0
243
318
- ` conf ` : 0.3
244
319
- ` nms ` : 0.45
245
320
- ` 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
249
324
250
325
251
326
#### ONNXRuntime example.
252
327
- ` model_path ` : ./install/yolox_ros_cpp/share/yolox_ros_cpp/weights/onnx/yolox_nano.onnx
328
+ - ` p6 ` : false
253
329
- ` class_labels_path ` : ""
254
330
- ` num_classes ` : 80
255
331
- ` model_version ` : 0.1.1rc0
@@ -263,9 +339,24 @@ ros2 launch yolox_ros_cpp yolox_onnxruntime.launch.py
263
339
- ` conf ` : 0.3
264
340
- ` nms ` : 0.45
265
341
- ` 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
269
360
270
361
271
362
### Reference
0 commit comments