Skip to content

Commit 612f82f

Browse files
authored
Merge pull request #54 from fateshelled/dev_cpp
Preprocess speed up and some fix
2 parents 037e03c + 659a7d6 commit 612f82f

25 files changed

+294
-281
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ Check [this URL](./yolox_ros_cpp/README.md).
3737

3838
<!-- - yolox/image_raw : Resized image (`sensor_msgs/Image`) -->
3939

40-
- bounding_boxes: Output BoundingBoxes like darknet_ros_msgs (`bboxes_ex_msgs/BoundingBoxes`)
41-
42-
※ If you want to use `darknet_ros_msgs` , replace `bboxes_ex_msgs` with `darknet_ros_msgs`.
40+
- bounding_boxes (`bboxes_ex_msgs/BoundingBoxes` or `vision_msgs/Detection2DArray`)
41+
- `bboxes_ex_msgs/BoundingBoxes`: Output BoundingBoxes like darknet_ros_msgs
42+
- ※ If you want to use `darknet_ros_msgs` , replace `bboxes_ex_msgs` with `darknet_ros_msgs`.
4343

4444
<!-- ![yolox_topic](images_for_readme/yolox_topic.png) -->
4545

weights/onnx/download.bash

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
#!/bin/bash
22

3-
# if $1 is empty
4-
if [ -z "$1" ]; then
5-
echo "Usage: $0 <target-model>"
6-
echo "Target-Models :"
7-
echo "yolox_tiny, yolox_nano, yolox_s, yolox_m, yolox_l, all"
8-
exit 1
9-
fi
10-
MODEL=$1
11-
MODEL_VERSION=0.1.1rc0
12-
SCRIPT_DIR=$(cd $(dirname $0); pwd)
3+
function download {
4+
# if $1 is empty
5+
if [ -z "$1" ]; then
6+
echo "Usage: $0 <target-model>"
7+
echo "Target-Models :"
8+
echo "yolox_tiny, yolox_nano, yolox_s, yolox_m, yolox_l, all"
9+
return
10+
fi
11+
MODEL=$1
12+
MODEL_VERSION=0.1.1rc0
13+
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE:-$0}); pwd)
1314

14-
echo $MODEL
15-
if [ "$MODEL" = "all" ]; then
16-
wget https://github.com/Megvii-BaseDetection/YOLOX/releases/download/$MODEL_VERSION/yolox_tiny.onnx -P $SCRIPT_DIR
17-
wget https://github.com/Megvii-BaseDetection/YOLOX/releases/download/$MODEL_VERSION/yolox_nano.onnx -P $SCRIPT_DIR
18-
wget https://github.com/Megvii-BaseDetection/YOLOX/releases/download/$MODEL_VERSION/yolox_s.onnx -P $SCRIPT_DIR
19-
wget https://github.com/Megvii-BaseDetection/YOLOX/releases/download/$MODEL_VERSION/yolox_m.onnx -P $SCRIPT_DIR
20-
wget https://github.com/Megvii-BaseDetection/YOLOX/releases/download/$MODEL_VERSION/yolox_l.onnx -P $SCRIPT_DIR
21-
else
22-
wget https://github.com/Megvii-BaseDetection/YOLOX/releases/download/$MODEL_VERSION/$MODEL.onnx -P $SCRIPT_DIR
23-
fi
15+
echo $MODEL
16+
if [ "$MODEL" = "all" ]; then
17+
wget https://github.com/Megvii-BaseDetection/YOLOX/releases/download/$MODEL_VERSION/yolox_tiny.onnx -P $SCRIPT_DIR
18+
wget https://github.com/Megvii-BaseDetection/YOLOX/releases/download/$MODEL_VERSION/yolox_nano.onnx -P $SCRIPT_DIR
19+
wget https://github.com/Megvii-BaseDetection/YOLOX/releases/download/$MODEL_VERSION/yolox_s.onnx -P $SCRIPT_DIR
20+
wget https://github.com/Megvii-BaseDetection/YOLOX/releases/download/$MODEL_VERSION/yolox_m.onnx -P $SCRIPT_DIR
21+
wget https://github.com/Megvii-BaseDetection/YOLOX/releases/download/$MODEL_VERSION/yolox_l.onnx -P $SCRIPT_DIR
22+
else
23+
wget https://github.com/Megvii-BaseDetection/YOLOX/releases/download/$MODEL_VERSION/$MODEL.onnx -P $SCRIPT_DIR
24+
fi
25+
}
26+
27+
download $1

weights/tensorrt/convert.bash

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
11
#!/bin/bash
22

3-
# if $1 is empty
4-
if [ -z "$1" ]; then
5-
echo "Usage: $0 <target-model>"
6-
echo "Target-Models : yolox_tiny, yolox_nano, yolox_s, yolox_m, yolox_l"
7-
exit 1
8-
fi
3+
function convert {
4+
# if $1 is empty
5+
if [ -z "$1" ]; then
6+
echo "Usage: $0 <target-model>"
7+
echo "Target-Models : yolox_tiny, yolox_nano, yolox_s, yolox_m, yolox_l"
8+
return
9+
fi
910

10-
MODEL=$1
11-
SCRIPT_DIR=$(cd $(dirname $0); pwd)
11+
MODEL=$1
12+
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE:-$0}); pwd)
1213

13-
echo "Model Name: ${MODEL}"
14-
echo ""
14+
echo "Model Name: ${MODEL}"
15+
echo ""
1516

16-
ONNX_MODEL_PATH=$SCRIPT_DIR/../onnx/$MODEL.onnx
17-
if [ ! -e $ONNX_MODEL_PATH ]; then
18-
$SCRIPT_DIR/../onnx/download.bash $MODEL
19-
fi
17+
ONNX_MODEL_PATH=$SCRIPT_DIR/../onnx/$MODEL.onnx
18+
if [ ! -e $ONNX_MODEL_PATH ]; then
19+
$SCRIPT_DIR/../onnx/download.bash $MODEL
20+
fi
2021

21-
if [ ! -e $ONNX_MODEL_PATH ]; then
22-
echo "[ERROR] Not Found ${ONNX_MODEL_PATH}"
23-
echo "[ERROR] Please check target model name."
24-
exit 1
25-
fi
22+
if [ ! -e $ONNX_MODEL_PATH ]; then
23+
echo "[ERROR] Not Found ${ONNX_MODEL_PATH}"
24+
echo "[ERROR] Please check target model name."
25+
return
26+
fi
2627

27-
/usr/src/tensorrt/bin/trtexec \
28-
--onnx=$SCRIPT_DIR/../onnx/$MODEL.onnx \
29-
--saveEngine=$SCRIPT_DIR/$MODEL.trt \
30-
--fp16 --verbose
28+
/usr/src/tensorrt/bin/trtexec \
29+
--onnx=$SCRIPT_DIR/../onnx/$MODEL.onnx \
30+
--saveEngine=$SCRIPT_DIR/$MODEL.trt \
31+
--fp16 --verbose
32+
}
33+
34+
convert $1

yolox_ros_cpp/README.md

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
## Requirements
44
- ROS2 Iron
55
- ros-iron-generate-parameter-library
6+
- ros-iron-vision-msgs
7+
- ros-iron-usb-cam
68
- OpenCV 4.x
79
- OpenVINO 2024.*
810
- TensorRT 10.x *
@@ -30,28 +32,26 @@ git clone --recursive https://github.com/Ar-Ray-code/YOLOX-ROS -b iron
3032
cd ~/ros2_ws
3133

3234
./src/YOLOX-ROS/weights/onnx/download.bash yolox_tiny
33-
# Download onnx file and convert to IR format.
34-
# ./src/YOLOX-ROS/weights/openvino/download.bash yolox_tiny
3535
```
3636

3737
### TensorRT
3838
```bash
3939
cd ~/ros2_ws
4040

4141
# Download onnx model and convert to TensorRT engine.
42-
# 1st arg is model name. 2nd is workspace size.
42+
# argument is model name. set yolox_tiny, yolox_nano, yolox_s, yolox_m or yolox_l.
4343
./src/YOLOX-ROS/weights/tensorrt/convert.bash yolox_tiny
4444
```
4545

46-
#### Tensorflow Lite
46+
### Tensorflow Lite
4747
```bash
4848
cd ~/ros2_ws
4949

5050
# Download tflite Person Detection model: https://github.com/Kazuhito00/Person-Detection-using-RaspberryPi-CPU/
5151
./src/YOLOX-ROS/weights/tflite/download_model.bash
5252
```
5353

54-
#### PINTO_model_zoo
54+
### PINTO_model_zoo
5555
- Support PINTO_model_zoo model
5656
- Download model using the following script.
5757
- https://github.com/PINTO0309/PINTO_model_zoo/blob/main/132_YOLOX/download_nano.sh
@@ -77,15 +77,15 @@ cd ~/ros2_ws
7777
# build with openvino
7878
source /opt/ros/humble/setup.bash
7979
source /opt/intel/openvino_2021/bin/setupvars.sh
80-
colcon build --cmake-args -DYOLOX_USE_OPENVINO=ON
80+
colcon build --symlink-install --cmake-args -DYOLOX_USE_OPENVINO=ON
8181
```
8282

8383
### TensorRT
8484

8585
```bash
8686
# build with tensorrt
87-
source /opt/ros/humble/setup.bash
88-
colcon build --cmake-args -DYOLOX_USE_TENSORRT=ON
87+
source /opt/ros/iron/setup.bash
88+
colcon build --symlink-install --cmake-args -DYOLOX_USE_TENSORRT=ON
8989
```
9090

9191
### TFLite
@@ -115,12 +115,13 @@ make -j"$(nproc)"
115115
```
116116

117117
```bash
118-
colcon build --cmake-args \
119-
-DYOLOX_USE_TFLITE=ON \
120-
-DTFLITE_LIB_PATH=${WORKSPACE}/tflite_build \
121-
-DTFLITE_INCLUDE_DIR=${WORKSPACE}/tensorflow_src/ \
122-
-DABSEIL_CPP_ICLUDE_DIR=${WORKSPACE}/tflite_build/abseil-cpp \
123-
-DFLATBUFFERS_INCLUDE_DIR=${WORKSPACE}/tflite_build/flatbuffers/include
118+
colcon build --symlink-install \
119+
--cmake-args \
120+
-DYOLOX_USE_TFLITE=ON \
121+
-DTFLITE_LIB_PATH=${WORKSPACE}/tflite_build \
122+
-DTFLITE_INCLUDE_DIR=${WORKSPACE}/tensorflow_src/ \
123+
-DABSEIL_CPP_ICLUDE_DIR=${WORKSPACE}/tflite_build/abseil-cpp \
124+
-DFLATBUFFERS_INCLUDE_DIR=${WORKSPACE}/tflite_build/flatbuffers/include
124125
```
125126

126127
<br>
@@ -139,10 +140,6 @@ ros2 launch yolox_ros_cpp yolox_openvino.launch.py
139140
# ros2 launch yolox_ros_cpp yolox_openvino.launch.py \
140141
# model_path:=install/yolox_ros_cpp/share/yolox_ros_cpp/weights/onnx/yolox_tiny_480x640.onnx \
141142
# model_version:="0.1.0"
142-
143-
## run YOLOX-tiny with NCS2
144-
# ros2 launch yolox_ros_cpp yolox_openvino_ncs2.launch.py
145-
146143
```
147144

148145
### TensorRT
@@ -156,20 +153,20 @@ ros2 launch yolox_ros_cpp yolox_tensorrt.launch.py
156153

157154
```
158155

159-
### Jetson + TensorRT
156+
<!-- ### Jetson + TensorRT
160157
Jetson docker container cannot display GUI.
161158
If you want to show image with bounding box drawn, subscribe from host jetson or other PC.
162159
163160
```bash
164161
# run yolox_tiny
165162
ros2 launch yolox_ros_cpp yolox_tensorrt_jetson.launch.py
166-
```
163+
``` -->
167164

168-
<!-- ### ONNXRuntime
165+
### ONNXRuntime
169166
```bash
170167
# run yolox_tiny
171168
ros2 launch yolox_ros_cpp yolox_onnxruntime.launch.py
172-
``` -->
169+
```
173170

174171
### Tensorflow Lite
175172
```bash
@@ -188,82 +185,90 @@ ros2 launch yolox_ros_cpp yolox_tflite.launch.py
188185
<details>
189186
<summary>OpenVINO example</summary>
190187

191-
- `model_path`: ./install/yolox_ros_cpp/share/yolox_ros_cpp/weights/openvino/yolox_tiny.xml
188+
- `model_path`: ./src/YOLOX-ROS/weights/onnx/yolox_tiny.onnx
192189
- `p6`: false
193190
- `class_labels_path`: ""
194191
- if not set, use coco_names.
195192
- See [here](https://github.com/fateshelled/YOLOX-ROS/blob/dev_cpp/yolox_ros_cpp/yolox_ros_cpp/labels/coco_names.txt) for label format.
196193
- `num_classes`: 80
197194
- `model_version`: 0.1.1rc0
198-
- `openvino/device`: AUTO
195+
- `openvino_device`: AUTO
199196
- `nms`: 0.45
200197
- `imshow_isshow`: true
201198
- `src_image_topic_name`: /image_raw
202199
- `publish_image_topic_name`: /yolox/image_raw
203200
- `publish_boundingbox_topic_name`: /yolox/bounding_boxes
201+
- `use_bbox_ex_msgs`: false
202+
- `publish_resized_image`: false
204203

205204
</details>
206205

207206

208207
<details>
209208
<summary>TensorRT example</summary>
210209

211-
- `model_path`: ./install/yolox_ros_cpp/share/yolox_ros_cpp/weights/tensorrt/yolox_tiny.trt
210+
- `model_path`: ../src/YOLOX-ROS/weights/tensorrt/yolox_tiny.trt
212211
- `p6`: false
213212
- `class_labels_path`: ""
214213
- `num_classes`: 80
215214
- `model_version`: 0.1.1rc0
216-
- `tensorrt/device`: 0
215+
- `tensorrt_device`: 0
217216
- `conf`: 0.3
218217
- `nms`: 0.45
219218
- `imshow_isshow`: true
220219
- `src_image_topic_name`: /image_raw
221220
- `publish_image_topic_name`: /yolox/image_raw
222221
- `publish_boundingbox_topic_name`: /yolox/bounding_boxes
222+
- `use_bbox_ex_msgs`: false
223+
- `publish_resized_image`: false
223224

224225
</details>
225226

226227
<details>
227228
<summary>ONNXRuntime example</summary>
228229

229230

230-
- `model_path`: ./install/yolox_ros_cpp/share/yolox_ros_cpp/weights/onnx/yolox_tiny.onnx
231+
- `model_path`: ./src/YOLOX-ROS/weights/onnx/yolox_tiny.onnx
231232
- `p6`: false
232233
- `class_labels_path`: ""
233234
- `num_classes`: 80
234235
- `model_version`: 0.1.1rc0
235-
- `onnxruntime/use_cuda`: true
236-
- `onnxruntime/use_parallel`: false
237-
- `onnxruntime/device_id`: 0
238-
- `onnxruntime/inter_op_num_threads`: 1
239-
- if `onnxruntime/use_parallel` is true, the number of threads used to parallelize the execution of the graph (across nodes).
240-
- `onnxruntime/intra_op_num_threads`: 1
236+
- `onnxruntime_use_cuda`: true
237+
- `onnxruntime_use_parallel`: false
238+
- `onnxruntime_device_id`: 0
239+
- `onnxruntime_inter_op_num_threads`: 1
240+
- if `onnxruntime_use_parallel` is true, the number of threads used to parallelize the execution of the graph (across nodes).
241+
- `onnxruntime_intra_op_num_threads`: 1
241242
- the number of threads to use to run the model
242243
- `conf`: 0.3
243244
- `nms`: 0.45
244245
- `imshow_isshow`: true
245246
- `src_image_topic_name`: /image_raw
246247
- `publish_image_topic_name`: /yolox/image_raw
247248
- `publish_boundingbox_topic_name`: /yolox/bounding_boxes
249+
- `use_bbox_ex_msgs`: false
250+
- `publish_resized_image`: false
248251

249252
</details>
250253

251254
<details>
252255
<summary>Tensorflow Lite example</summary>
253256

254-
- `model_path`: ./install/yolox_ros_cpp/share/yolox_ros_cpp/weights/tflite/model.tflite
257+
- `model_path`: ./src/YOLOX-ROS/weights/tflite/model.tflite
255258
- `p6`: false
256259
- `is_nchw`: true
257260
- `class_labels_path`: ""
258261
- `num_classes`: 1
259262
- `model_version`: 0.1.1rc0
260-
- `tflite/num_threads`: 1
263+
- `tflite_num_threads`: 1
261264
- `conf`: 0.3
262265
- `nms`: 0.45
263266
- `imshow_isshow`: true
264267
- `src_image_topic_name`: /image_raw
265268
- `publish_image_topic_name`: /yolox/image_raw
266269
- `publish_boundingbox_topic_name`: /yolox/bounding_boxes
270+
- `use_bbox_ex_msgs`: false
271+
- `publish_resized_image`: false
267272

268273
</details>
269274

0 commit comments

Comments
 (0)