Skip to content

Commit

Permalink
Format code with pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
triple-Mu authored and Chilicyy committed Oct 12, 2022
1 parent 7609bbf commit ca6ba2e
Show file tree
Hide file tree
Showing 58 changed files with 266 additions and 279 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ Implementation of paper - [YOLOv6: A Single-Stage Object Detection Framework for

YOLOv6 has a series of models for various industrial scenarios, including N/T/S/M/L, which the architectures vary considering the model size for better accuracy-speed trade-off. And some Bag-of-freebies methods are introduced to further improve the performance, such as self-distillation and more training epochs. For industrial deployment, we adopt QAT with channel-wise distillation and graph optimization to pursue extreme performance.

YOLOv6-N hits 35.9% AP on COCO dataset with 1234 FPS on T4. YOLOv6-S strikes 43.5% AP with 495 FPS, and the quantized YOLOv6-S model achieves 43.3% AP at a accelerated speed of 869 FPS on T4. YOLOv6-T/M/L also have excellent performance, which show higher accuracy than other detectors with the similar inference speed.
YOLOv6-N hits 35.9% AP on COCO dataset with 1234 FPS on T4. YOLOv6-S strikes 43.5% AP with 495 FPS, and the quantized YOLOv6-S model achieves 43.3% AP at a accelerated speed of 869 FPS on T4. YOLOv6-T/M/L also have excellent performance, which show higher accuracy than other detectors with the similar inference speed.


## What's New

- Release M/L models and update N/T/S models with enhanced performance.⭐️ [Benchmark](#Benchmark)
- 2x faster training time.
- Fix the degration of performance when evaluating on 640x640 inputs.
- Fix the degration of performance when evaluating on 640x640 inputs.
- Customized quantization methods. 🚀 [Quantization Tutorial](./tools/qat/README.md)

## Benchmark
Expand All @@ -34,7 +34,7 @@ YOLOv6-N hits 35.9% AP on COCO dataset with 1234 FPS on T4. YOLOv6-S strikes 43.
| [**YOLOv6-L-ReLU**](https://github.com/meituan/YOLOv6/releases/download/0.2.0/yolov6l_relu.pt) | 640 | 51.7 | 113 | 149 | 58.5 | 144.0 |
| [**YOLOv6-L**](https://github.com/meituan/YOLOv6/releases/download/0.2.0/yolov6l.pt) | 640 | 52.5 | 98 | 121 | 58.5 | 144.0 |

### Quantized model 🚀
### Quantized model 🚀

| Model | Size | Precision | mAP<sup>val<br/>0.5:0.95 | Speed<sup>T4<br/>trt b1 <br/>(fps) | Speed<sup>T4<br/>trt b32 <br/>(fps) |
| :-------------------- | ---- | --------- | :----------------------- | ---------------------------------- | ----------------------------------- |
Expand Down Expand Up @@ -135,19 +135,19 @@ python -m torch.distributed.launch --nproc_per_node 8 tools/train.py \
--epoch 300 \
--device 0,1,2,3,4,5,6,7 \
--name yolov6m_coco # yolov6l_coco


# Step 2: Self-distillation training
python -m torch.distributed.launch --nproc_per_node 8 tools/train.py \
--batch 256 \ # 128 for distillation of yolov6l
--batch 256 \ # 128 for distillation of yolov6l
--conf configs/yolov6m.py \ # configs/yolov6l.py
--data data/coco.yaml \
--epoch 300 \
--device 0,1,2,3,4,5,6,7 \
--distill \
--teacher_model_path runs/train/yolov6m_coco/weights/best_ckpt.pt \ # # yolov6l_coco
--name yolov6m_coco # yolov6l_coco

```
</details>

Expand Down Expand Up @@ -242,5 +242,5 @@ python tools/infer.py --weights yolov6s.pt --source img.jpg / imgdir / video.mp4
* Tutorial: [How to train YOLOv6 on a custom dataset](https://blog.roboflow.com/how-to-train-yolov6-on-a-custom-dataset/) <a href="https://colab.research.google.com/drive/1YnbqOinBZV-c9I7fk_UL6acgnnmkXDMM"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"></a>
* Demo of YOLOv6 inference on Google Colab [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/mahdilamb/YOLOv6/blob/main/inference.ipynb)
</details>

### [FAQ(Continuously updated)](https://github.com/meituan/YOLOv6/wiki/FAQ%EF%BC%88Continuously-updated%EF%BC%89)
2 changes: 1 addition & 1 deletion configs/experiment/eval_640_repro.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@
force_no_pad=True,
not_infer_on_rect=True,
)
)
)
6 changes: 3 additions & 3 deletions configs/experiment/yolov6n_with_eval_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
solver = dict(
optim='SGD',
lr_scheduler='Cosine',
lr0=0.02, #0.01 # 0.02
lr0=0.02, #0.01 # 0.02
lrf=0.01,
momentum=0.937,
weight_decay=0.0005,
Expand All @@ -55,15 +55,15 @@
)

# Eval params when eval model.
# If eval_params item is list, eg conf_thres=[0.03, 0.03],
# If eval_params item is list, eg conf_thres=[0.03, 0.03],
# first will be used in train.py and second will be used in eval.py.
eval_params = dict(
batch_size=None, #None mean will be the same as batch on one device * 2
img_size=None, #None mean will be the same as train image size
conf_thres=0.03,
iou_thres=0.65,

#pading and scale coord
#pading and scale coord
test_load_size=None, #None mean will be the same as test image size
letterbox_return_int=False,
force_no_pad=False,
Expand Down
10 changes: 5 additions & 5 deletions configs/experiment/yolov6s_csp_scaled.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
model = dict(
type='YOLOv6s_csp',
pretrained=None,
depth_multiple=0.70,
depth_multiple=0.70,
width_multiple=0.50,
backbone=dict(
type='CSPBepBackbone',
Expand Down Expand Up @@ -39,12 +39,12 @@
weight_decay=0.0005,
warmup_epochs=3.0,
warmup_momentum=0.8,
warmup_bias_lr=0.1
warmup_bias_lr=0.1
)

data_aug = dict(
hsv_h=0.015,
hsv_s=0.7,
hsv_h=0.015,
hsv_s=0.7,
hsv_v=0.4,
degrees=0.0,
translate=0.1,
Expand Down
10 changes: 5 additions & 5 deletions configs/experiment/yolov6t_csp_scaled.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
model = dict(
type='YOLOv6n_csp',
pretrained=None,
depth_multiple=0.60,
depth_multiple=0.60,
width_multiple=0.50,
backbone=dict(
type='CSPBepBackbone',
Expand Down Expand Up @@ -39,12 +39,12 @@
weight_decay=0.0005,
warmup_epochs=3.0,
warmup_momentum=0.8,
warmup_bias_lr=0.1
warmup_bias_lr=0.1
)

data_aug = dict(
hsv_h=0.015,
hsv_s=0.7,
hsv_h=0.015,
hsv_s=0.7,
hsv_v=0.4,
degrees=0.0,
translate=0.1,
Expand Down
2 changes: 1 addition & 1 deletion configs/repopt/yolov6_tiny_hs.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@
)

# Choose Rep-block by the training Mode, choices=["repvgg", "hyper-search", "repopt"]
training_mode='hyper_search'
training_mode='hyper_search'
2 changes: 1 addition & 1 deletion configs/repopt/yolov6_tiny_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@
mixup=0.0,
)
# Choose Rep-block by the training Mode, choices=["repvgg", "hyper-search", "repopt"]
training_mode='repopt'
training_mode='repopt'
4 changes: 2 additions & 2 deletions configs/repopt/yolov6n_hs.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
solver = dict(
optim='SGD',
lr_scheduler='Cosine',
lr0=0.02, #0.01 # 0.02
lr0=0.02, #0.01 # 0.02
lrf=0.01,
momentum=0.937,
weight_decay=0.0005,
Expand All @@ -55,4 +55,4 @@
)

# Choose Rep-block by the training Mode, choices=["repvgg", "hyper-search", "repopt"]
training_mode='hyper_search'
training_mode='hyper_search'
4 changes: 2 additions & 2 deletions configs/repopt/yolov6n_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
solver = dict(
optim='SGD',
lr_scheduler='Cosine',
lr0=0.02, #0.01 # 0.02
lr0=0.02, #0.01 # 0.02
lrf=0.01,
momentum=0.937,
weight_decay=0.0005,
Expand All @@ -55,4 +55,4 @@
mixup=0.0,
)
# Choose Rep-block by the training Mode, choices=["repvgg", "hyper-search", "repopt"]
training_mode='repopt'
training_mode='repopt'
14 changes: 7 additions & 7 deletions configs/yolov6l.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
model = dict(
type='YOLOv6l',
pretrained=None,
depth_multiple=1.0,
depth_multiple=1.0,
width_multiple=1.0,
backbone=dict(
type='CSPBepBackbone',
Expand Down Expand Up @@ -43,12 +43,12 @@
weight_decay=0.0005,
warmup_epochs=3.0,
warmup_momentum=0.8,
warmup_bias_lr=0.1
warmup_bias_lr=0.1
)

data_aug = dict(
hsv_h=0.015,
hsv_s=0.7,
hsv_h=0.015,
hsv_s=0.7,
hsv_v=0.4,
degrees=0.0,
translate=0.1,
Expand All @@ -59,5 +59,5 @@
mosaic=1.0,
mixup=0.1,
)
training_mode = "conv_silu"
# use normal conv to speed up training and further improve accuracy.
training_mode = "conv_silu"
# use normal conv to speed up training and further improve accuracy.
6 changes: 3 additions & 3 deletions configs/yolov6l_finetune.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
model = dict(
type='YOLOv6l',
pretrained='weights/yolov6l.pt',
depth_multiple=1.0,
depth_multiple=1.0,
width_multiple=1.0,
backbone=dict(
type='CSPBepBackbone',
Expand Down Expand Up @@ -59,5 +59,5 @@
mosaic=1.0,
mixup=0.243,
)
training_mode = "conv_silu"
# use normal conv to speed up training and further improve accuracy.
training_mode = "conv_silu"
# use normal conv to speed up training and further improve accuracy.
12 changes: 6 additions & 6 deletions configs/yolov6l_relu.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
model = dict(
type='YOLOv6l_relu',
pretrained=None,
depth_multiple=1.0,
depth_multiple=1.0,
width_multiple=1.0,
backbone=dict(
type='CSPBepBackbone',
Expand Down Expand Up @@ -43,12 +43,12 @@
weight_decay=0.0005,
warmup_epochs=3.0,
warmup_momentum=0.8,
warmup_bias_lr=0.1
warmup_bias_lr=0.1
)

data_aug = dict(
hsv_h=0.015,
hsv_s=0.7,
hsv_h=0.015,
hsv_s=0.7,
hsv_v=0.4,
degrees=0.0,
translate=0.1,
Expand All @@ -58,4 +58,4 @@
fliplr=0.5,
mosaic=1.0,
mixup=0.1,
)
)
4 changes: 2 additions & 2 deletions configs/yolov6l_relu_finetune.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
model = dict(
type='YOLOv6l_relu',
pretrained='weights/yolov6l_relu.pt',
depth_multiple=1.0,
depth_multiple=1.0,
width_multiple=1.0,
backbone=dict(
type='CSPBepBackbone',
Expand Down Expand Up @@ -58,4 +58,4 @@
fliplr=0.5,
mosaic=1.0,
mixup=0.243,
)
)
12 changes: 6 additions & 6 deletions configs/yolov6m.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
model = dict(
type='YOLOv6m',
pretrained=None,
depth_multiple=0.60,
depth_multiple=0.60,
width_multiple=0.75,
backbone=dict(
type='CSPBepBackbone',
Expand Down Expand Up @@ -43,12 +43,12 @@
weight_decay=0.0005,
warmup_epochs=3.0,
warmup_momentum=0.8,
warmup_bias_lr=0.1
warmup_bias_lr=0.1
)

data_aug = dict(
hsv_h=0.015,
hsv_s=0.7,
hsv_h=0.015,
hsv_s=0.7,
hsv_v=0.4,
degrees=0.0,
translate=0.1,
Expand All @@ -58,4 +58,4 @@
fliplr=0.5,
mosaic=1.0,
mixup=0.1,
)
)
4 changes: 2 additions & 2 deletions configs/yolov6m_finetune.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
model = dict(
type='YOLOv6m',
pretrained='weights/yolov6m.pt',
depth_multiple=0.60,
depth_multiple=0.60,
width_multiple=0.75,
backbone=dict(
type='CSPBepBackbone',
Expand Down Expand Up @@ -58,4 +58,4 @@
fliplr=0.5,
mosaic=1.0,
mixup=0.243,
)
)
2 changes: 1 addition & 1 deletion configs/yolov6n.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
solver = dict(
optim='SGD',
lr_scheduler='Cosine',
lr0=0.02, #0.01 # 0.02
lr0=0.02, #0.01 # 0.02
lrf=0.01,
momentum=0.937,
weight_decay=0.0005,
Expand Down
12 changes: 6 additions & 6 deletions deploy/ONNX/OpenCV/yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@

def draw_label(input_image, label, left, top):
"""Draw text onto image at location."""

# Get text size.
text_size = cv2.getTextSize(label, FONT_FACE, FONT_SCALE, THICKNESS)
dim, baseline = text_size[0], text_size[1]
# Use text size to create a BLACK rectangle.
# Use text size to create a BLACK rectangle.
cv2.rectangle(input_image, (left, top), (left + dim[0], top + dim[1] + baseline), BLACK, cv2.FILLED)
# Display text inside the rectangle.
cv2.putText(input_image, label, (left, top + dim[1]), FONT_FACE, FONT_SCALE, YELLOW, THICKNESS, cv2.LINE_AA)
Expand Down Expand Up @@ -88,7 +88,7 @@ def post_process(input_image, outputs):
top = int((cy - h/2) * y_factor)
width = int(w * x_factor)
height = int(h * y_factor)

box = np.array([left, top, width, height])
boxes.append(box)

Expand Down Expand Up @@ -129,7 +129,7 @@ def post_process(input_image, outputs):
# Give the weight files to the model and load the network using them.
net = cv2.dnn.readNet(model_path)

# Put efficiency information. The function getPerfProfile returns the overall time for inference(t) and the
# Put efficiency information. The function getPerfProfile returns the overall time for inference(t) and the
# timings for each of the layers(in layersTimes)
# Process image.
cycles = 300
Expand All @@ -140,10 +140,10 @@ def post_process(input_image, outputs):
t, _ = net.getPerfProfile()
total_time += t
print(f'Cycle [{i + 1}]:\t{t * 1000.0 / cv2.getTickFrequency():.2f}\tms')

avg_time = total_time / cycles
label = 'Average Inference time: %.2f ms' % (avg_time * 1000.0 / cv2.getTickFrequency())
print(f'Model: {window_name}\n{label}')
cv2.putText(img, label, (20, 40), FONT_FACE, FONT_SCALE, RED, THICKNESS, cv2.LINE_AA)
cv2.imshow(window_name, img)
cv2.waitKey(0)
cv2.waitKey(0)
Loading

0 comments on commit ca6ba2e

Please sign in to comment.