Code Monkey home page Code Monkey logo

rt-detr-deploy's Introduction

RT-DETR Deploy with ONNX and TensorRT

base on project https://github.com/PaddlePaddle/PaddleDetection/tree/develop/configs/rtdetr

not need NMS not need Anchors and soeasy post process

1.Clone project

git clone https://github.com/PaddlePaddle/PaddleDetection.git

2.Export paddlepaddle model

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

note: need paddlepaddle python package >= 2.4.0

3.Convert paddlepaddle model to onnx model

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

4.Simplify onnx model

onnxsim  rtdetr_hgnetv2_l_6x_coco.onnx rtdetr_hgnetv2_l_6x_coco-sim.onnx --overwrite-input-shape im_shape:1,2 image:1,3,640,640 scale_factor:1,2

5.ONNX infer with simplified model

python 1.onnx_run_original_onnx_post_process.py

and will generate a result.jpg

6.Modify onnx model to only one input

simplified model has three inputs (im_shape, image, scale_factor),but we want only one input of model. use script modify onnx model

python modify_onnx.py -i rtdetr_hgnetv2_l_6x_coco-sim.onnx -o rtdetr_hgnetv2_l_6x_coco-modify.onnx

7.ONNX infer with modified model

python 2.onnx_run_modify_onnx_no_post_process.py

8.Generate TensorRT engine

for supporting GatherND and GridSample op need TensorRT version >= 8.5

  • GatherND TensorRT >= 8.4
  • GridSample TensorRT >= 8.5
trtexec --onnx=rtdetr_hgnetv2_l_6x_coco-modify.onnx --saveEngine=rtdetr_hgnetv2_l_6x_coco-modify-fp32.engine

rt-detr-deploy's People

Contributors

nanmi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.