# PIDNet_TensorRT
This repository provides a step-by-step guide and code for optimizing a state-of-the-art semantic segmentation model using TorchScript, ONNX, and TensorRT.
## Prerequisites
### Device: RTX 3050
* CUDA: 12.0 (driver: 525)
* cuDNN: 8.9
* TensorRT: 8.6
* PyCUDA
### Device: NVIDIA Jetson Nano
* Jetpack: 4.6.2
* PyCUDA
## Usage
### 0. Setup
* Clone this repository and download the pretrained model from the official [PIDNet](https://github.com/XuJiacong/PIDNet/tree/main) repository.
### 1. Export the model
For TorchScript:
````bash
python tools/export.py --a pidnet-s --p ./pretrained_models/cityscapes/PIDNet_S_Cityscapes_test.pt --f torchscript
````
For ONNX:
````bash
python tools/export.py --a pidnet-s --p ./pretrained_models/cityscapes/PIDNet_S_Cityscapes_test.pt --f onnx
````
For TensorRT (using the above ONNX model):
```bash
trtexec --onnx=path/to/onnx/model --saveEngine=path/to/engine
```
### 2. Inference
```bash
python tools/inference.py --f pytorch
```
### 3. Speed Measurement
* Measure the inference speed of PIDNet-S for Cityscapes:
````bash
python models/speed/pidnet_speed.py --f all
````
| | FPS | % increase |
| :---------- | :---------: |:---------: |
| PyTorch | 24.72 | - |
| TorchScript | 27.09 | 9.59 |
| ONNX (with TensorRT EP) | 33.52 | 35.60 |
| TensorRT | 32.93 | 33.21 |
speed test is performed on a single Nvidia GeForce RTX 3050 GPU
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
算法部署_使用TensorRT部署PIDNet算法_优质算法部署项目实战.zip (70个子文件)
算法部署_使用TensorRT部署PIDNet算法_优质算法部署项目实战
results.txt 31B
tools
custom_trt.py 5KB
_init_paths.py 586B
eval.py 4KB
export.py 2KB
custom.py 4KB
inference.py 10KB
train.py 8KB
demo.py 3KB
pretrained_models
imagenet
readme.txt 42B
camvid
readme.txt 40B
cityscapes
readme.txt 44B
data
list
camvid
test.lst 12KB
train.lst 18KB
val.lst 5KB
trainval.lst 23KB
cityscapes
test.lst 92KB
train.lst 375KB
val.lst 62KB
trainval.lst 437KB
camvid
labels
readme.txt 40B
images
readme.txt 35B
readme.txt 87B
cityscapes
readme.txt 51B
samples
outputs_ort
frankfurt_000000_002196_leftImg8bit.png 24KB
frankfurt_000000_003025_leftImg8bit.png 33KB
frankfurt_000000_002196_leftImg8bit.png 2.2MB
frankfurt_000000_003025_leftImg8bit.png 2.41MB
outputs_ts
frankfurt_000000_002196_leftImg8bit.png 24KB
frankfurt_000000_003025_leftImg8bit.png 33KB
outputs_trt
frankfurt_000000_002196_leftImg8bit.png 24KB
frankfurt_000000_003025_leftImg8bit.png 33KB
outputs
frankfurt_000000_002196_leftImg8bit.png 24KB
frankfurt_000000_003025_leftImg8bit.png 33KB
configs
__init__.py 445B
default.py 2KB
camvid
pidnet_small_camvid.yaml 937B
pidnet_medium_camvid.yaml 937B
cityscapes
pidnet_medium_cityscapes_trainval.yaml 955B
pidnet_large_cityscapes.yaml 951B
pidnet_small_cityscapes.yaml 951B
pidnet_medium_cityscapes.yaml 952B
pidnet_small_cityscapes_trainval.yaml 954B
pidnet_large_cityscapes_trainval.yaml 954B
utils
utils.py 5KB
__init__.py 0B
function.py 7KB
criterion.py 4KB
datasets
__init__.py 432B
base_dataset.py 5KB
camvid.py 4KB
cityscapes.py 5KB
readme.txt 60B
figs
cityscapes_score.jpg 96KB
video2_all.gif 44MB
pidnet_table.jpg 198KB
pidnet.jpg 301KB
prediction.jpg 562KB
video1_all.gif 43.44MB
models
__init__.py 339B
model_utils.py 17KB
others
bisenet_adb_bag.py 16KB
ddrnet_23_adb_bag.py 19KB
resnet.py 3KB
pidnet.py 12KB
speed
pidnet_speed_onnx.py 12KB
pidnet_speed_tensorrt.py 11KB
pidnet_speed.py 18KB
model_utils_speed.py 16KB
README.md 1KB
共 70 条
- 1
资源评论
__AtYou__
- 粉丝: 3508
- 资源: 2175
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功