forked from meituan/YOLOv6
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request meituan#1 from meituan/main
Pull newest code
- Loading branch information
Showing
12 changed files
with
289 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,98 @@ | ||
## Export ONNX Model | ||
# Export ONNX Model | ||
|
||
### Check requirements | ||
## Check requirements | ||
```shell | ||
pip install onnx>=1.10.0 | ||
``` | ||
|
||
### Export script | ||
## Export script | ||
```shell | ||
python deploy/ONNX/export_onnx.py --weights yolov6s.pt --img 640 --batch 1 | ||
|
||
python ./deploy/ONNX/export_onnx.py \ | ||
--weights yolov6s.pt \ | ||
--img 640 \ | ||
--batch 1 | ||
``` | ||
|
||
### Download | ||
|
||
|
||
#### Description of all arguments | ||
|
||
- `--weights` : The path of yolov6 model weights. | ||
- `--img` : Image size of model inputs. | ||
- `--batch` : Batch size of model inputs. | ||
- `--half` : Whether to export half-precision model. | ||
- `--inplace` : Whether to set Detect() inplace. | ||
- `--simplify` : Whether to simplify onnx. Not support in end to end export. | ||
- `--end2end` : Whether to export end to end onnx model. Only support onnxruntime and TensorRT >= 8.0.0 . | ||
- `--max-wh` : Default is None for TensorRT backend. Set int for onnxruntime backend. | ||
- `--topk-all` : Topk objects for every image. | ||
- `--iou-thres` : IoU threshold for NMS algorithm. | ||
- `--conf-thres` : Confidence threshold for NMS algorithm. | ||
- `--device` : Export device. Cuda device : 0 or 0,1,2,3 ... , CPU : cpu . | ||
|
||
## Download | ||
|
||
* [YOLOv6-nano](https://github.com/meituan/YOLOv6/releases/download/0.1.0/yolov6n.onnx) | ||
* [YOLOv6-tiny](https://github.com/meituan/YOLOv6/releases/download/0.1.0/yolov6t.onnx) | ||
* [YOLOv6-s](https://github.com/meituan/YOLOv6/releases/download/0.1.0/yolov6s.onnx) | ||
|
||
## End2End export | ||
|
||
Now YOLOv6 supports end to end detect for onnxruntime and TensorRT ! | ||
|
||
If you want to deploy in TensorRT, make sure you have installed TensorRT >= 8.0.0 ! | ||
|
||
### onnxruntime backend | ||
#### Usage | ||
|
||
```bash | ||
python ./deploy/ONNX/export_onnx.py \ | ||
--weights yolov6s.pt \ | ||
--img 640 \ | ||
--batch 1 \ | ||
--end2end \ | ||
--max-wh 7680 | ||
``` | ||
|
||
You will get an onnx with **NonMaxSuppression** operater . | ||
|
||
The onnx outputs shape is ```nums x 7```. | ||
|
||
```nums``` means the number of all objects which were detected. | ||
|
||
```7``` means [`batch_index`,`x0`,`y0`,`x1`,` y1`,`classid`,`score`] | ||
|
||
### TensorRT backend (TensorRT version>= 8.0.0) | ||
|
||
#### Usage | ||
|
||
```bash | ||
python ./deploy/ONNX/export_onnx.py \ | ||
--weights yolov6s.pt \ | ||
--img 640 \ | ||
--batch 1 \ | ||
--end2end | ||
``` | ||
|
||
You will get an onnx with **[EfficientNMS_TRT](https://github.com/NVIDIA/TensorRT/tree/main/plugin/efficientNMSPlugin)** plugin . | ||
The onnx outputs are as shown : | ||
|
||
<img src="https://user-images.githubusercontent.com/92794867/176650971-a4fa3d65-10d4-4b65-b8ef-00a2ff13406c.png" height="300px" /> | ||
|
||
```num_dets``` means the number of object in every image in its batch . | ||
|
||
```det_boxes``` means topk(100) object's location about [`x0`,`y0`,`x1`,` y1`] . | ||
|
||
```det_scores``` means the confidence score of every topk(100) objects . | ||
|
||
```det_classes``` means the category of every topk(100) objects . | ||
|
||
|
||
You can export TensorRT engine use [trtexec](https://docs.nvidia.com/deeplearning/tensorrt/developer-guide/index.html#trtexec-ovr) tools. | ||
#### Usage | ||
``` shell | ||
/path/to/trtexec \ | ||
--onnx=yolov6s.onnx \ | ||
--saveEngine=yolov6s.engine \ | ||
--fp16 # if export TensorRT fp16 model | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.