Skip to content

Commit 208b2fc

Browse files
auskaliceint
andauthored
Feature: add modified yolop tensorrt implementation (wang-xinyu#1129)
* add simplified Logger class * add modified yolop tensorrtx implementation * add gen_wts.py * add CMakeLists.txt * add yolop tensorrtx README.md * fix yolop spelling * simplify yolop code * fix yolop README.md Co-authored-by: aliceint(zhanglj) <[email protected]>
1 parent 0c78095 commit 208b2fc

File tree

11 files changed

+1506
-0
lines changed

11 files changed

+1506
-0
lines changed

yolop/CMakeLists.txt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
cmake_minimum_required(VERSION 2.6)
2+
3+
project(yolop)
4+
5+
add_definitions(-std=c++11)
6+
7+
option(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
8+
set(CMAKE_CXX_STANDARD 11)
9+
set(CMAKE_BUILD_TYPE Release)
10+
11+
find_package(CUDA REQUIRED)
12+
13+
include_directories(${PROJECT_SOURCE_DIR}/include)
14+
15+
find_package(OpenCV REQUIRED)
16+
include_directories(${OpenCV_INCLUDE_DIRS})
17+
18+
# cuda
19+
include_directories(/usr/local/cuda-10.2/include)
20+
link_directories(/usr/local/cuda-10.2/lib64)
21+
# tensorrt
22+
include_directories(/usr/include/aarch64-linux-gnu/)
23+
link_directories(/usr/lib/aarch64-linux-gnu/)
24+
25+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Ofast -Wfatal-errors -D_MWAITXINTRIN_H_INCLUDED")
26+
27+
# to generate plugins
28+
cuda_add_library(myplugins SHARED ${PROJECT_SOURCE_DIR}/yololayer.cu)
29+
target_link_libraries(myplugins nvinfer cudart)
30+
31+
# to generate trt and test image dir
32+
add_executable(yolop ${PROJECT_SOURCE_DIR}/yolop.cpp)
33+
target_link_libraries(yolop nvinfer cudart myplugins ${OpenCV_LIBS})
34+
add_definitions(-O3 -pthread)
35+

yolop/README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
YoloP TensorRT Usage
2+
=====
3+
4+
Fork from [hustvl/YOLOP](https://github.com/hustvl/YOLOP), modify from [ausk/YOLOP](https://github.com/ausk/YOLOP/), push into [wang-xinyu/tensorrtx](https://github.com/wang-xinyu/tensorrtxls)
5+
6+
7+
## 1. Prepare building environments
8+
9+
Make sure you have install `c++`(support c++11)、 `cmake``opencv`(4.x)、`cuda`(10.x)、`nvinfer`(7.x).
10+
11+
12+
## 2. build yolop
13+
14+
Go to `yolop`.
15+
16+
```
17+
mkdir build
18+
cd build
19+
20+
cmake ..
21+
make
22+
```
23+
24+
Now you can get `yolop` and `libmyplugins.so`.
25+
26+
27+
## 3. Generate and test trt
28+
29+
Go to `yolop/build`.
30+
31+
### 3.1 generate yolop.wts
32+
Download/Clone [YOLOP](https://github.com/hustvl/YOLOP)
33+
34+
Edit `gen_wts.py` , change `YOLOP_BASE_DIR` to realpath of `YOLOP`.
35+
36+
```
37+
# [WARN] Please download/clone YOLOP, then set YOLOP_BASE_DIR to the root of YOLOP
38+
python3 ../gen_wts.py
39+
```
40+
41+
### 3.2 generate yolop.trt
42+
```
43+
./yolop -s yolop.wts yolop.trt
44+
```
45+
46+
Now you have such files: `libmyplugins.so yolop yolop.wts yolop.trt`
47+
48+
49+
### 3.3 test yolop.trt
50+
```
51+
mkdir ../results
52+
53+
YOLOP_BASE_DIR=/home/user/jetson/tmp/YOLOP
54+
./yolop -d yolop.trt $YOLOP_BASE_DIR/inference/images/
55+
```
56+
57+
It will output like as follow if successful! ( test on `Jetson Xavier NX - Jetpack 4.4`)
58+
```
59+
1601ms # the fist time is slow
60+
26ms # then it is faster
61+
29ms
62+
27ms
63+
29ms
64+
29ms
65+
```
66+
67+
![](https://user-images.githubusercontent.com/4545060/197756635-38348dc5-d8e7-4ae3-be56-6b231dd2f5db.jpg)
68+
69+
70+
71+
----------------------------------------
72+
73+
74+
```BibTeX
75+
@misc{2108.11250,
76+
Author = {Dong Wu and Manwen Liao and Weitian Zhang and Xinggang Wang},
77+
Title = {YOLOP: You Only Look Once for Panoptic Driving Perception},
78+
Year = {2021},
79+
Eprint = {arXiv:2108.11250},
80+
}
81+
```
82+

0 commit comments

Comments
 (0)