- ROS2 Iron
- ros-jazzy-generate-parameter-library
- ros-jazzy-vision-msgs
- ros-jazzy-usb-cam
- OpenCV 4.x
- OpenVINO 2024.*
- TensorRT 10.x *
- ONNXRuntime *
- Tensorflow Lite *
- CUDA 12
※ Either one of OpenVINO or TensorRT or ONNXRuntime or Tensorflow Lite is required.
※ Tensorflow Lite support XNNPACK Delegate only.
※ Tensorflow Lite support float model and does not support integer model.
cd ~/ros2_ws/src
git clone --recursive https://github.com/Ar-Ray-code/YOLOX-ROS -b jazzy
cd ~/ros2_ws
./src/YOLOX-ROS/weights/onnx/download.bash yolox_tiny
cd ~/ros2_ws
# Download onnx model and convert to TensorRT engine.
# argument is model name. set yolox_tiny, yolox_nano, yolox_s, yolox_m or yolox_l.
./src/YOLOX-ROS/weights/tensorrt/convert.bash yolox_tiny
cd ~/ros2_ws
# Download tflite Person Detection model: https://github.com/Kazuhito00/Person-Detection-using-RaspberryPi-CPU/
./src/YOLOX-ROS/weights/tflite/download_model.bash
-
Support PINTO_model_zoo model
-
Download model using the following script.
- https://github.com/PINTO0309/PINTO_model_zoo/blob/main/132_YOLOX/download_nano.sh
curl -s https://raw.githubusercontent.com/PINTO0309/PINTO_model_zoo/main/132_YOLOX/download_nano.sh | bash
-
ONNX model copy to weight dir
cp resouces_new/saved_model_yolox_tiny_480x640/yolox_tiny_480x640.onnx ./src/YOLOX-ROS/weights/onnx/
-
Convert to TensorRT engine
./src/YOLOX-ROS/weights/tensorrt/convert.bash yolox_tiny_480x640
-
tflite model copy to weight dir
cp resouces_new/saved_model_yolox_tiny_480x640/model_float32.tflite ./src/YOLOX-ROS/weights/tflite/
# build with openvino
source /opt/ros/jazzy/setup.bash
colcon build --symlink-install --cmake-args -DYOLOX_USE_OPENVINO=ON
# build with tensorrt
source /opt/ros/jazzy/setup.bash
colcon build --symlink-install --cmake-args -DYOLOX_USE_TENSORRT=ON
TFLite build
https://www.tensorflow.org/lite/guide/build_cmake
Below is an example build script.
Please change ${WORKSPACE}
as appropriate for your envjazzyment.
export WORKSPACE=${HOME}/ws_tflite
mkdir -p ${WORKSPACE}
cd ${WORKSPACE}
git clone https://github.com/tensorflow/tensorflow.git tensorflow_src
mkdir tflite_build
cd tflite_build
cmake ../tensorflow_src/tensorflow/lite \
-DBUILD_SHARED_LIBS=ON \
-DTFLITE_ENABLE_INSTALL=OFF \
-DTFLITE_ENABLE_XNNPACK=ON \
-DTFLITE_ENABLE_RUY=OFF \
-DCMAKE_BUILD_TYPE=Release
make -j"$(nproc)"
colcon build --symlink-install \
--cmake-args \
-DYOLOX_USE_TFLITE=ON \
-DTFLITE_LIB_PATH=${WORKSPACE}/tflite_build \
-DTFLITE_INCLUDE_DIR=${WORKSPACE}/tensorflow_src/ \
-DABSEIL_CPP_ICLUDE_DIR=${WORKSPACE}/tflite_build/abseil-cpp \
-DFLATBUFFERS_INCLUDE_DIR=${WORKSPACE}/tflite_build/flatbuffers/include
ros2 launch yolox_ros_cpp yolox_openvino.launch.py
## run other model
# ros2 launch yolox_ros_cpp yolox_openvino.launch.py \
# model_path:=install/yolox_ros_cpp/share/yolox_ros_cpp/weights/openvino/yolox_s.xml
## run PINTO_model_zoo model (version 0.1.0)
# ros2 launch yolox_ros_cpp yolox_openvino.launch.py \
# model_path:=install/yolox_ros_cpp/share/yolox_ros_cpp/weights/onnx/yolox_tiny_480x640.onnx \
# model_version:="0.1.0"
ros2 launch yolox_ros_cpp yolox_tensorrt.launch.py
## run PINTO_model_zoo model (version 0.1.0)
# ros2 launch yolox_ros_cpp yolox_tensorrt.launch.py \
# model_path:=install/yolox_ros_cpp/share/yolox_ros_cpp/weights/tensorrt/yolox_tiny_480x640.trt \
# model_version:="0.1.0"
# run yolox_tiny
ros2 launch yolox_ros_cpp yolox_onnxruntime.launch.py
ros2 launch yolox_ros_cpp yolox_tflite.launch.py
# # run PINTO_model_zoo model (version 0.1.0)
# ros2 launch yolox_ros_cpp yolox_tflite.launch.py \
# model_path:=install/yolox_ros_cpp/share/yolox_ros_cpp/weights/tflite/model_float32.tflite \
# model_version:=0.1.0 \
# num_classes:=80 \
# is_nchw:=false
OpenVINO example
model_path
: ./src/YOLOX-ROS/weights/onnx/yolox_tiny.onnxp6
: falseclass_labels_path
: ""- if not set, use coco_names.
- See here for label format.
num_classes
: 80model_version
: 0.1.1rc0openvino_device
: AUTOnms
: 0.45imshow_isshow
: truesrc_image_topic_name
: /image_rawpublish_image_topic_name
: /yolox/image_rawpublish_boundingbox_topic_name
: /yolox/bounding_boxesuse_bbox_ex_msgs
: falsepublish_resized_image
: false
TensorRT example
model_path
: ../src/YOLOX-ROS/weights/tensorrt/yolox_tiny.trtp6
: falseclass_labels_path
: ""num_classes
: 80model_version
: 0.1.1rc0tensorrt_device
: 0conf
: 0.3nms
: 0.45imshow_isshow
: truesrc_image_topic_name
: /image_rawpublish_image_topic_name
: /yolox/image_rawpublish_boundingbox_topic_name
: /yolox/bounding_boxesuse_bbox_ex_msgs
: falsepublish_resized_image
: false
ONNXRuntime example
model_path
: ./src/YOLOX-ROS/weights/onnx/yolox_tiny.onnxp6
: falseclass_labels_path
: ""num_classes
: 80model_version
: 0.1.1rc0onnxruntime_use_cuda
: trueonnxruntime_use_parallel
: falseonnxruntime_device_id
: 0onnxruntime_inter_op_num_threads
: 1- if
onnxruntime_use_parallel
is true, the number of threads used to parallelize the execution of the graph (across nodes).
- if
onnxruntime_intra_op_num_threads
: 1- the number of threads to use to run the model
conf
: 0.3nms
: 0.45imshow_isshow
: truesrc_image_topic_name
: /image_rawpublish_image_topic_name
: /yolox/image_rawpublish_boundingbox_topic_name
: /yolox/bounding_boxesuse_bbox_ex_msgs
: falsepublish_resized_image
: false
Tensorflow Lite example
model_path
: ./src/YOLOX-ROS/weights/tflite/model.tflitep6
: falseis_nchw
: trueclass_labels_path
: ""num_classes
: 1model_version
: 0.1.1rc0tflite_num_threads
: 1conf
: 0.3nms
: 0.45imshow_isshow
: truesrc_image_topic_name
: /image_rawpublish_image_topic_name
: /yolox/image_rawpublish_boundingbox_topic_name
: /yolox/bounding_boxesuse_bbox_ex_msgs
: falsepublish_resized_image
: false
Reference from YOLOX demo code.