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.
- Loading branch information
Showing
65 changed files
with
3,769 additions
and
169 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# YOLOv6s model | ||
model = dict( | ||
type='YOLOv6s', | ||
pretrained=None, | ||
depth_multiple=0.33, | ||
width_multiple=0.50, | ||
backbone=dict( | ||
type='EfficientRep', | ||
num_repeats=[1, 6, 12, 18, 6], | ||
out_channels=[64, 128, 256, 512, 1024], | ||
), | ||
neck=dict( | ||
type='RepPAN', | ||
num_repeats=[12, 12, 12, 12], | ||
out_channels=[256, 128, 128, 256, 256, 512], | ||
), | ||
head=dict( | ||
type='EffiDeHead', | ||
in_channels=[128, 256, 512], | ||
num_layers=3, | ||
anchors=1, | ||
strides=[8, 16, 32], | ||
iou_type='siou' | ||
) | ||
) | ||
|
||
solver = dict( | ||
optim='SGD', | ||
lr_scheduler='Cosine', | ||
lr0=0.01, | ||
lrf=0.01, | ||
momentum=0.937, | ||
weight_decay=0.0005, | ||
warmup_epochs=3.0, | ||
warmup_momentum=0.8, | ||
warmup_bias_lr=0.1 | ||
) | ||
|
||
data_aug = dict( | ||
hsv_h=0.015, | ||
hsv_s=0.7, | ||
hsv_v=0.4, | ||
degrees=0.0, | ||
translate=0.1, | ||
scale=0.5, | ||
shear=0.0, | ||
flipud=0.0, | ||
fliplr=0.5, | ||
mosaic=1.0, | ||
mixup=0.0, | ||
) | ||
|
||
# Choose Rep-block by the training Mode, choices=["repvgg", "hyper-search", "repopt"] | ||
training_mode='hyper_search' |
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# YOLOv6s model | ||
model = dict( | ||
type='YOLOv6s', | ||
pretrained=None, | ||
scales='./assets/yolov6s_scale.pt', | ||
depth_multiple=0.33, | ||
width_multiple=0.50, | ||
backbone=dict( | ||
type='EfficientRep', | ||
num_repeats=[1, 6, 12, 18, 6], | ||
out_channels=[64, 128, 256, 512, 1024], | ||
), | ||
neck=dict( | ||
type='RepPAN', | ||
num_repeats=[12, 12, 12, 12], | ||
out_channels=[256, 128, 128, 256, 256, 512], | ||
), | ||
head=dict( | ||
type='EffiDeHead', | ||
in_channels=[128, 256, 512], | ||
num_layers=3, | ||
anchors=1, | ||
strides=[8, 16, 32], | ||
iou_type='siou' | ||
) | ||
) | ||
|
||
solver = dict( | ||
optim='SGD', | ||
lr_scheduler='Cosine', | ||
lr0=0.01, | ||
lrf=0.01, | ||
momentum=0.937, | ||
weight_decay=0.0005, | ||
warmup_epochs=3.0, | ||
warmup_momentum=0.8, | ||
warmup_bias_lr=0.1 | ||
) | ||
|
||
data_aug = dict( | ||
hsv_h=0.015, | ||
hsv_s=0.7, | ||
hsv_v=0.4, | ||
degrees=0.0, | ||
translate=0.1, | ||
scale=0.5, | ||
shear=0.0, | ||
flipud=0.0, | ||
fliplr=0.5, | ||
mosaic=1.0, | ||
mixup=0.0, | ||
) | ||
|
||
# Choose Rep-block by the training Mode, choices=["repvgg", "hyper-search", "repopt"] | ||
training_mode='repopt' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Please insure that your custom_dataset are put in same parent dir with YOLOv6_DIR | ||
train: VOCdevkit/voc_07_12/images/train # train images | ||
val: VOCdevkit/voc_07_12/images/val # val images | ||
test: VOCdevkit/voc_07_12/images/val # test images (optional) | ||
|
||
# whether it is coco dataset, only coco dataset should be set to True. | ||
is_coco: False | ||
# Classes | ||
nc: 20 # number of classes | ||
names: ['aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', | ||
'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor'] # class names |
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 |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# Object Detection using YOLOv5/YOLOv6/YOLOX and OpenCV DNN (Python/C++) | ||
|
||
## 0. Install Dependancies | ||
``` | ||
OpenCV >= 4.5.4 | ||
``` | ||
Only **OpenCV >= 4.5.4** can read onnx model file by dnn module. | ||
|
||
## 1. Usage | ||
Change work directory to `/path/to/YOLOv6/deploy/ONNX/OpenCV` | ||
### 1.1 Python | ||
|
||
- YOLOv5&YOLOv6: | ||
```Python | ||
python yolo.py --model /path/to/onnx/yolov5n.onnx --img /path/to/sample.jpg --classesFile /path/to/coco.names | ||
yolov5s.onnx | ||
yolov5m.onnx | ||
yolov6n.onnx | ||
yolov6s.onnx | ||
yolov6t.onnx | ||
``` | ||
- YOLOX: | ||
```Python | ||
python yolox.py --model /path/to/onnx/yolox_nano.onnx --img /path/to/sample.jpg --classesFile /path/to/coco.names | ||
yolox_tiny.onnx | ||
yolox_s.onnx | ||
yolox_m.onnx | ||
``` | ||
|
||
### 1.2 CMake C++ Linux YOLOv5 | ||
```C++ Linux | ||
cd yolov5 // modify CMakeLists.txt | ||
mkdir build | ||
cd build | ||
cmake .. | ||
make | ||
./yolov5 /path/to/onnx/yolov5n.onnx /path/to/sample.jpg /path/to/coco.names | ||
yolov5s.onnx | ||
yolov5m.onnx | ||
``` | ||
|
||
### 1.3 CMake C++ Linux YOLOv6 | ||
```C++ Linux | ||
cd yolov6 // modify CMakeLists.txt | ||
mkdir build | ||
cd build | ||
cmake .. | ||
make | ||
./yolov6 /path/to/onnx/yolov6n.onnx /path/to/sample.jpg /path/to/coco.names | ||
yolov6t.onnx | ||
yolov6s.onnx | ||
``` | ||
|
||
### 1.4 CMake C++ Linux YOLOX | ||
```C++ Linux | ||
cd yolox // modify CMakeLists.txt | ||
mkdir build | ||
cd build | ||
cmake .. | ||
make | ||
./yolox /path/to/onnx/yolox_nano.onnx /path/to/sample.jpg /path/to/coco.names | ||
yolox_tiny.onnx | ||
yolox_s.onnx | ||
yolox_m.onnx | ||
``` | ||
|
||
## 2. Result | ||
| Model | Speed CPU b1(ms) Python | Speed CPU b1(ms) C++ | mAP<sup>val 0.5:0.95</sup> | params(M) | FLOPs(G) | | ||
| :-- | :-: | :-: | :-: | :-: | :-: | | ||
| **YOLOv5n** | 116.47 | 118.89 | 28.0 | 1.9 | 4.5 | | ||
| **YOLOv5s** | 200.53 | 202.22 | 37.4 | 7.2 | 16.5 | | ||
| **YOLOv5m** | 294.98 | 291.86 | 45.4 | 21.2 | 49.0 | | ||
| | | | | | | | ||
| **YOLOv6-n** | 66.88 | 69.96 | 35.0 | 4.3 | 4.7 | | ||
| **YOLOv6-tiny** | 133.15 | 137.59 | 41.3 | 15.0 | 36.7 | | ||
| **YOLOv6-s** | 164.44 | 163.38 | 43.1 | 17.2 | 44.2 | | ||
| | | | | | | | ||
| **YOLOX-Nano** | 81.06 | 86.75 | 25.8@416 | 0.91 | 1.08@416 | | ||
| **YOLOX-tiny** | 129.72 | 144.19 | 32.8@416 | 5.06 | 6.45@416 | | ||
| **YOLOX-s** | 180.86 | 169.96 | 40.5 | 9.0 | 26.8 | | ||
| **YOLOX-m** | 336.34 | 357.91 | 47.2 | 25.3 | 73.8 | | ||
|
||
**Note**: | ||
- All onnx models are converted from official github([Google Drive](https://drive.google.com/drive/folders/1Nw6M_Y6XLASyB0RxhSI2z_QRtt70Picl?usp=sharing)). | ||
- Speed is test by [dnn::Net::getPerfProfile](https://docs.opencv.org/4.5.5/db/d30/classcv_1_1dnn_1_1Net.html), we report the average inference time of 300 runs on the same environment. | ||
- The mAP/params/FLOPs are from official github. | ||
- Test environment: MacOS 11.4 with 2.6 GHz 6-core Intel Core i7, 16GB Memory. | ||
|
||
### Visualization | ||
<div align="left"> <img src="../../../assets/yolov5s.jpg" width="1000"></div> | ||
<div align="left"> <img src="../../../assets/yolov6s.jpg" width="1000"></div> | ||
<div align="left"> <img src="../../../assets/yoloxs.jpg" width="1000"></div> |
Oops, something went wrong.