Skip to content

Commit 8e4de7d

Browse files
committed
optimize yolov5 cmdline args
1 parent fec5e61 commit 8e4de7d

File tree

3 files changed

+120
-477
lines changed

3 files changed

+120
-477
lines changed

yolov5/README.md

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,34 @@
22

33
The Pytorch implementation is [ultralytics/yolov5](https://github.com/ultralytics/yolov5).
44

5+
## Different versions of yolov5
6+
57
Currently, we support yolov5 v1.0(yolov5s only), v2.0, v3.0, v3.1 and v4.0.
68

7-
- For yolov5 v4.0, please visit [yolov5 release v4.0](https://github.com/ultralytics/yolov5/releases/tag/v4.0), and use the latest commit of this repo.
8-
- For yolov5 v3.0 and v3.1, please visit [yolov5 release v3.0](https://github.com/ultralytics/yolov5/releases/tag/v3.0) and [yolov5 release v3.1](https://github.com/ultralytics/yolov5/releases/tag/v3.1), and checkout commit ['6d0f5cb'](https://github.com/wang-xinyu/tensorrtx/commit/6d0f5cbf4745bc00b69aad54a905383fb906f103) of this repo.
9-
- For yolov5 v2.0, please visit [yolov5 release v2.0](https://github.com/ultralytics/yolov5/releases/tag/v2.0), and checkout commit ['5cfa444'](https://github.com/wang-xinyu/tensorrtx/commit/5cfa4445170eabaa54acd5ad7f469ef65a8763f1) of this repo.
10-
- For yolov5 v1.0, please visit [yolov5 release v1.0](https://github.com/ultralytics/yolov5/releases/tag/v1.0), and checkout commit ['f09aa3b'](https://github.com/wang-xinyu/tensorrtx/commit/f09aa3bbebf4d4d37b6d3b32a1d39e1f2678a07b) of this repo.
9+
- For yolov5 v4.0, download .pt from [yolov5 release v4.0](https://github.com/ultralytics/yolov5/releases/tag/v4.0), `git clone -b v4.0 https://github.com/ultralytics/yolov5.git` and `git clone https://github.com/wang-xinyu/tensorrtx.git`.
10+
- For yolov5 v3.1, download .pt from [yolov5 release v3.1](https://github.com/ultralytics/yolov5/releases/tag/v3.1), `git clone -b v3.1 https://github.com/ultralytics/yolov5.git` and `git clone https://github.com/wang-xinyu/tensorrtx.git && git checkout 6d0f5cbf4745bc00b69aad54a905383fb906f103`.
11+
- For yolov5 v3.0, download .pt from [yolov5 release v3.0](https://github.com/ultralytics/yolov5/releases/tag/v3.0), `git clone -b v3.0 https://github.com/ultralytics/yolov5.git` and `git clone https://github.com/wang-xinyu/tensorrtx.git && git checkout 6d0f5cbf4745bc00b69aad54a905383fb906f103`.
12+
- For yolov5 v2.0, download .pt from [yolov5 release v2.0](https://github.com/ultralytics/yolov5/releases/tag/v2.0), `git clone -b v2.0 https://github.com/ultralytics/yolov5.git` and `git clone https://github.com/wang-xinyu/tensorrtx.git && git checkout 5cfa4445170eabaa54acd5ad7f469ef65a8763f1`.
13+
- For yolov5 v1.0, download .pt from [yolov5 release v1.0](https://github.com/ultralytics/yolov5/releases/tag/v1.0), `git clone -b v1.0 https://github.com/ultralytics/yolov5.git` and `git clone https://github.com/wang-xinyu/tensorrtx.git && git checkout f09aa3bbebf4d4d37b6d3b32a1d39e1f2678a07b`.
1114

1215
## Config
1316

1417
- Choose the model s/m/l/x by `NET` macro in yolov5.cpp
1518
- Input shape defined in yololayer.h
1619
- Number of classes defined in yololayer.h, **DO NOT FORGET TO ADAPT THIS, If using your own model**
17-
- FP16/FP32 can be selected by the macro in yolov5.cpp
20+
- INT8/FP16/FP32 can be selected by the macro in yolov5.cpp, **INT8 need more steps, pls follow `How to Run` first and then go the `INT8 Quantization` below**
1821
- GPU id can be selected by the macro in yolov5.cpp
1922
- NMS thresh in yolov5.cpp
2023
- BBox confidence thresh in yolov5.cpp
2124
- Batch size in yolov5.cpp
2225

2326
## How to Run, yolov5s as example
2427

25-
1. generate yolov5s.wts from pytorch with yolov5s.pt, or download .wts from model zoo
28+
1. generate .wts from pytorch with .pt, or download .wts from model zoo
2629

2730
```
28-
git clone https://github.com/wang-xinyu/tensorrtx.git
29-
git clone https://github.com/ultralytics/yolov5.git
30-
// download its weights 'yolov5s.pt'
31+
// git clone src code according to `Different versions of yolov5` above
32+
// download https://github.com/ultralytics/yolov5/releases/download/v4.0/yolov5s.pt
3133
// copy tensorrtx/yolov5/gen_wts.py into ultralytics/yolov5
3234
// ensure the file name is yolov5s.pt and yolov5s.wts in gen_wts.py
3335
// go to ultralytics/yolov5
@@ -40,18 +42,19 @@ python gen_wts.py
4042
```
4143
// put yolov5s.wts into tensorrtx/yolov5
4244
// go to tensorrtx/yolov5
43-
// ensure the macro NET in yolov5.cpp is s
4445
// update CLASS_NUM in yololayer.h if your model is trained on custom dataset
4546
mkdir build
4647
cd build
4748
cmake ..
4849
make
49-
sudo ./yolov5 -s 0.33 0.50 // serialize yolov5s model to plan file i.e. 'yolov5.engine'
50-
sudo ./yolov5 -s 0.67 0.75 // serialize yolov5m model to plan file i.e. 'yolov5.engine'
51-
sudo ./yolov5 -s 1.0 1.0 // serialize yolov5l model to plan file i.e. 'yolov5.engine'
52-
sudo ./yolov5 -s 1.33 1.25 // serialize yolov5x model to plan file i.e. 'yolov5.engine'
53-
sudo ./yolov5 -s 0.17 0.25 // serialize your own yolov5 model with depth_multiple and width_multiple which you set in '.yaml' file when training the model. i.e. depth = 0.17, width = 0.25
54-
sudo ./yolov5 -d ../samples // deserialize plan file and run inference, the images in samples will be processed.
50+
sudo ./yolov5 -s [.wts] [.engine] [s/m/l/x or c gd gw] // serialize model to plan file
51+
sudo ./yolov5 -d [.engine] [image folder] // deserialize and run inference, the images in [image folder] will be processed.
52+
// For example yolov5s
53+
sudo ./yolov5 -s yolov5s.wts yolov5s.engine s
54+
sudo ./yolov5 -d yolov5s.engine ../samples
55+
// For example Custom model with depth_multiple=0.17, width_multiple=0.25 in yolov5.yaml
56+
sudo ./yolov5 -s yolov5_custom.wts yolov5.engine c 0.17 0.25
57+
sudo ./yolov5 -d yolov5.engine ../samples
5558
```
5659

5760
3. check the images generated, as follows. _zidane.jpg and _bus.jpg

yolov5/samples

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../yolov3-spp/samples/

0 commit comments

Comments
 (0)