# RT-DETR-OpenVINO
This project mainly demonstrates the deployment of RT-DETR model cases based on OpenVINO C++, Python, and C # API.
# ð Project Environment
| Python Environment | C++ Environment | C# Environment |
| ------------------------------------------------------------ | :---------------------------------- | :----------------------------------------------------------- |
| paddlepaddle=2.5.1<br/>onnx=1.13.0 <br/>paddle2onnx=0.5 <br/>paddledet <br/>opencv-python=4.8.1.78 <br/>openvino=2023.1.0 <br/>pillow=10.0.1 | opencv=4.5.5 <br/>openvino=2023.1.0 | OpenCvSharp4.Windows=4.8.0.20230708 <br/>OpenVINO.CSharp.win=3.1.1 |
# ð¯ Model Download and Cconversion
## â» Environmental Installation
```shell
# Creating a virtual environment using Conda.
conda create -n paddledet python=3.10
conda activate paddledet
# Install paddlepaddle
python -m pip install paddlepaddle==2.5.1 -i https://pypi.tuna.tsinghua.edu.cn/simple
# 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
# Convert ONNX format environment
pip install onnx==1.13.0
pip install paddle2onnx==1.0.5
# Install OpenVINO.
# Convert IR format environment and deploy model in Python environment
pip install openvino==2023.1.0
```
## â¿ Model Export
```shell
cd PaddleDetection
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
```
<div align=center><span><img src="https://s2.loli.net/2023/10/18/bwBfI3JR7goH5Da.png" height=300/></span></div>
The above figure shows our exported RT-DETR model, which actually includes post-processing. Therefore, the input of the model has three nodes. If you find it inconvenient to use, you can also export a model without post-processing. The implementation method is as follows:
Modify the configuration file of the RT-DETR model, with the path to the configuration file:``.\PaddleDetection\configs\rtdetr\_base_\rtdetr_r50vd.yml``, add 'exclude' under the DETR project in the configuration file_ Post_ Process: ``exclude_post_process: True``.
<div align=center><span><img src="https://s2.loli.net/2023/10/18/tA2JFsqaR3L6Vnm.png" height=300/></span></div>
Then rerun the model export command to obtain the model without post-processing, as shown in the following figure:
<div align=center><span><img src="https://s2.loli.net/2023/10/18/OkWv5EcipdwrI7D.png" height=300/></span></div>
## ð® Convert ONNX Format
```shell
paddle2onnx --model_dir=./output_inference/rtdetr_r50vd_6x_coco/ --model_filename model.pdmodel --params_filename model.pdiparams --opset_version 16 --save_file rtdetr_r50vd_6x_coco.onnx
```
## ð¨ Convert IR Format
At present, the model exported by Paddle we are using is a dynamic shape, and OpenVINO supports dynamic model input. However, to prevent convenience in subsequent processing, we fix the shape of the model when exporting the IR model. This can be achieved by using the following instructions:
```shell
ovc rtdetr_r50vd_6x_coco.onnx --input âimage[1,3,640,640], im_shape[1,2], scale_factor[1,2]â
```
If it is a model without post-processing exported from the previous text, the conversion instruction is:
```shell
ovc rtdetr_r50vd_6x_coco.onnx --input image[1,3,640,640]
```
# ðï¸RT-DETR INT8 Quantization
If you want to achieve RT-DETR INT8 quantization, you can refer to the steps in the following article to implement it: [**Convert and Optimize RT-DETR real-time object detection with OpenVINOâ¢**](./optimize/openvino-convert-and-optimize-rt-detr.ipynb)
# ð¨ Case Testing
## ð Python
```
git clone https://github.com/guojin-yan/RT-DETR-OpenVINO.git
cd RT-DETR-OpenVINO/scr/python
python main.py [model path] [image path] [label path] [post flag(1/0)]
```
- \[model path]ï¼Represents the address of the prediction model, which can be exported according to the steps above or downloaded from the model published in this warehouse.
- [image path]ï¼Indicates the address of the image to be predicted, and the file location is in the ``RT-DETR-OpenVINO\image`` path.
- [label path]ï¼Represent the prediction result category file, and the file location is in the ``RT-DETR-OpenVINO\image`` path.
- [post flag(1/0)]ï¼Indicates whether the model includes post-processing, post_ flag=0 indicates no post-processing, post_ flag=1 indicates the inclusion of post-processing
| Console Output | Result Image |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| <span><img src="https://s2.loli.net/2023/10/18/nZGydeSl9NWD54P.png" height=400/></span> | <span><img src="https://s2.loli.net/2023/10/18/ZgFi2tzX3bvHc1y.png" height=400/></span> |
## 𥰠C++
```
git clone https://github.com/guojin-yan/RT-DETR-OpenVINO.git
cd RT-DETR-OpenVINO/scr/cpp
```
C++ æ¡ä¾ä¸ä½¿ç¨äºCmakeç¼è¯ï¼è¥è¦æåç¼è¯è¯¥é¡¹ç®ï¼éè¦æ ¹æ®èªå·±çµèå®è£
对åºçä¾èµåºï¼è¯¥é¡¹ç®éè¦å®è£
OpenVINO以åOpenCVï¼å®è£
ä¹åï¼ä¿®æ¹`æ件ä¸OpenVINO以åOpenCVçç¼è¯è·¯å¾å°åå³å¯ã
In the C++case, Cmake compilation was used. To successfully compile this project, it is necessary to install the corresponding dependency libraries based on one's own computer. This project requires the installation of OpenVINO and OpenCV; After installation, modify the compilation path addresses of OpenVINO and OpenCV in the ``RT-DETR-OpenVINO\src\cpp\CMakeLists.txt`` file.
```
mkdir build && cd build
cmake ..
make
rt-detr_openvino_cpp.exe [model path] [image path] [label path] [post flag(1/0)]
```
| Console Output | Result Image |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| <span><img src="https://s2.loli.net/2023/10/18/XeONfYJdmWSKMZQ.png" height=400/></span> | <span><img src="https://s2.loli.net/2023/10/18/FpMunTeOKXvidjI.png" height=400/></span> |
## ð C#
```
git clone https://github.com/guojin-yan/RT-DETR-OpenVINO.git
cd RT-DETR-OpenVINO/scr/csharp
dotnet run [model path] [image path] [label path] [post flag(1/0)]
```
| Console Output | Result Image |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| <span><img src="https://s2.loli.net/2023/10/18/IK4ZnPFHBTNEi1X.png" height=400/></span> | <span><img src="https://s2.loli.net/2023/10/18/KifdwrtRJ2UIcBQ.png" height=400/></span> |
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
openvino部署_使用openvino部署RT-DETR部署_项目实战_附详细完整流程.zip (36个子文件)
openvino部署_使用openvino部署RT-DETR部署_项目实战_附详细完整流程
RT-DETR-OpenVINO.sln 5KB
image
000000014439.jpg 191KB
000000087038.jpg 179KB
car.jpg 2.18MB
000000570688.jpg 135KB
000000014439_640x640.jpg 267KB
COCO_lable.txt 620B
src
time_test
rt-detr_csharp_time_test
rt-detr_csharp_time_test.csproj 488B
RTDETRProcess.cs 13KB
Program.cs 5KB
RTDETRPredictor.cs 10KB
rt-detr_cpp_time_test
process.h 2KB
rtdert_predictor.h 1KB
rt-detr_cpp_time_test.vcxproj 8KB
main.cpp 1KB
process.cpp 8KB
rtdert_predictor.cpp 9KB
rt-detr_cpp_time_test.vcxproj.filters 1KB
python
main.py 2KB
process.py 11KB
openvino_deploy_rtdetr.py 3KB
cpp
CMakeLists.txt 1KB
rt-detr_openvino_cpp.vcxproj.filters 1KB
rt-detr_openvino_cpp.vcxproj 8KB
process.h 2KB
rtdert_predictor.h 1KB
main.cpp 2KB
process.cpp 8KB
rtdert_predictor.cpp 8KB
csharp
RTDETRProcess.cs 13KB
Properties
launchSettings.json 294B
rt-detr_openvino_csharp.csproj 568B
Program.cs 2KB
RTDETRPredictor.cs 9KB
optimize
openvino-convert-and-optimize-rt-detr.ipynb 117KB
README.md 7KB
共 36 条
- 1
资源评论
极智视界
- 粉丝: 2w+
- 资源: 1412
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功