Skip to content

This project showcases the deployment of the RT-DETR model using ONNXRUNTIME in C++ and Python.

License

Notifications You must be signed in to change notification settings

foxnight2/rtdetr-onnxruntime-deploy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RT-DETR-onnxruntime-project 💻

This project showcases the deployment of the RT-DETR model using ONNXRUNTIME in C++ and Python.

Environment Dependencies 🛠️

  • OpenCV: 4.x
  • ONNXRuntime: Tested on 1.14
  • OS: Tested on Ubuntu 18.04
  • CUDA: 11+ [Optional]

Installation and Model Conversion 🚀

$ conda create -n rtdetr python=3.8 -y
$ conda activate rtdetr

$ python -m pip install paddlepaddle-gpu==2.4.2.post117 -f https://www.paddlepaddle.org.cn/whl/linux/mkl/avx/stable.html


# Clone PaddleDetection repository
$ git clone https://github.com/PaddlePaddle/PaddleDetection.git
$ cd PaddleDetection
$ git checkout develop

# Compile and install paddledet
$ pip install -r requirements.txt
$ python setup.py install

# Validation
$ python tools/infer.py -c configs/rtdetr/rtdetr_r50vd_6x_coco.yml -o weights=https://bj.bcebos.com/v1/paddledet/models/rtdetr_r50vd_6x_coco.pdparams --infer_img=bus.jpg
  • Modify the configuration file [PaddleDetection/configs/rtdetr/base/rtdetr_r50vd.yml]:

  • Modify the processing code according to the illustration [PaddleDetection/ppdet/modeling/architectures/detr.py]:

# Download the pretrained weight
$ wget https://bj.bcebos.com/v1/paddledet/models/rtdetr_r50vd_6x_coco.pdparams && mkdir weights && mv rtdetr_r50vd_6x_coco.pdparams ./weights


$ python tools/export_model.py -c configs/rtdetr/rtdetr_r50vd_6x_coco.yml \
              -o weights=https://bj.bcebos.com/v1/paddledet/models/rtdetr_r50vd_6x_coco.pdparams trt=True \
              --output_dir=output_inference

$ pip install onnx==1.13.0
$ pip install paddle2onnx==1.0.5

$ paddle2onnx --model_dir=./output_inference/rtdetr_r50vd_6x_coco/ \
              --model_filename model.pdmodel  \
              --params_filename model.pdiparams \
              --opset_version 16 \
              --save_file ./output_inference/rtdetr_r50vd_6x_coco/rtdetr_r50vd_6x_coco.onnx

$ pip3 install -U pip && pip3 install onnxsim
$ onnxsim input_onnx_model output_onnx_model

# Check the converted model [Option]
$ pip install netron

Python 🐍

$ git clone https://github.com/CVHub520/rtdetr-onnxruntime-deploy.git
$ cd rtdetr-onnxruntime-deploy
$ mkdir weights && cd weights
$ wget https://github.com/CVHub520/rtdetr-onnxruntime-deploy/releases/download/v1.0.0/rtdetr_r50vd_6x_coco_cvhub.onnx
$ cd ../python
$ python3 main.py

C++ 🤖

$ cd rtdetr-onnxruntime-deploy
$ mkdir weights && cd weights
$ wget https://github.com/CVHub520/rtdetr-onnxruntime-deploy/releases/download/v1.0.0/rtdetr_r50vd_6x_coco_cvhub.onnx
$ cd ../cplusplus

NOTE: To build the project, ensure that onnxruntime and opencv are correctly installed. Then, run the commands as instructed. Don’t forget to update the ONNXRUNTIME_DIR and OpenCV_DIR cmake options in the CMakeLists.txt file to match your custom environment.

$ mkdir build && cd build
$ cmake ..
$ make
$ ./main
# ./main --use_cuda

Demo 🎬

Python C++

Contact 👋

Please feel free to use this project as a starting point for your own deployment needs, or as a reference for learning purposes. If you have any questions or suggestions, please don't hesitate to raise an issue or submit a pull request.

Platform Account
Wechat 💬 cv_huber
Zhihu 🧠 CVHub
CSDN 📚 CVHub
Github 🐱 CVHub

About

This project showcases the deployment of the RT-DETR model using ONNXRUNTIME in C++ and Python.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 72.7%
  • Python 21.1%
  • CMake 6.2%