Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YOLOv3 - Continue on #1695 #3083

Merged
merged 83 commits into from
Aug 31, 2020
Merged
Show file tree
Hide file tree
Changes from 74 commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
9b5b39e
Implement YOLOv3
Nov 19, 2019
787def0
Remove unused function
Nov 20, 2019
589158c
Merge branch 'master' into yolo
wuhy08 Dec 2, 2019
722fef8
Update yolov3_ms_aug_273e.py
wuhy08 Mar 12, 2020
08ef678
Merge remote-tracking branch 'origin-mm/master' into yolo
wuhy08 Mar 12, 2020
d61c575
Add README.md
wuhy08 Mar 26, 2020
082a63f
Merge branch 'master' of github.com:open-mmlab/mmdetection into yolo-2.0
ElectronicElephant Jun 20, 2020
e09390e
port to mmdet-2.0 api
ElectronicElephant Jun 23, 2020
0edf116
unify registry
ElectronicElephant Jun 23, 2020
035793a
Merge pull request #1 from ElectronicElephant/yolo-dev
ElectronicElephant Jun 23, 2020
e13afb6
Merge pull request #2 from ElectronicElephant/yolo-dev
ElectronicElephant Jun 23, 2020
1b4ecfc
port to ConvModule and remove ConvLayer
ElectronicElephant Jun 29, 2020
1f64c24
Merge pull request #3 from ElectronicElephant/yolo-dev
ElectronicElephant Jun 29, 2020
75c60f5
Refactor Backbone
ElectronicElephant Jun 29, 2020
3e59739
Update README
ElectronicElephant Jun 29, 2020
4f24fa1
Lint and format
ElectronicElephant Jun 29, 2020
4f82cd5
Merge pull request #4 from ElectronicElephant/yolo-dev
ElectronicElephant Jun 29, 2020
0ff50f8
Unify the class name
ElectronicElephant Jun 29, 2020
fd0e591
fix the `label - 1` problem
ElectronicElephant Jun 29, 2020
0b4db8f
Unify the class name and fix the `label-1` problem
ElectronicElephant Jun 29, 2020
4c7a837
Move a lot hard-coded params to the __init__ function
ElectronicElephant Jun 29, 2020
a3219ff
Refactor YOLOV3Neck
ElectronicElephant Jun 29, 2020
8e64bee
Add norm_cfg and act_cfg to backbone
ElectronicElephant Jun 29, 2020
40a6bbb
Update Config
ElectronicElephant Jun 29, 2020
14a13ae
Merge pull request #6 from ElectronicElephant/yolo-dev
ElectronicElephant Jun 30, 2020
59c5e38
Fix doc string
ElectronicElephant Jun 30, 2020
fc7d002
Merge pull request #7 from ElectronicElephant/yolo-dev
ElectronicElephant Jun 30, 2020
12ccde0
Fix nms (thanks to @LMerCy)
ElectronicElephant Jul 3, 2020
f257251
Add doc string
ElectronicElephant Jul 3, 2020
797e3dc
Merge pull request #10 from ElectronicElephant/yolo-dev
ElectronicElephant Jul 3, 2020
556eac0
Update config
ElectronicElephant Jul 5, 2020
77d7a6d
Remove pretrained in head and neck
ElectronicElephant Jul 5, 2020
23fd70e
Add support for conv_cfg in neck
ElectronicElephant Jul 5, 2020
0958b3c
Update mmdet/models/dense_heads/yolo_head.py
ElectronicElephant Jul 5, 2020
80e8cdc
Update mmdet/models/dense_heads/yolo_head.py
ElectronicElephant Jul 5, 2020
55ef429
Fix README.md
ElectronicElephant Jul 5, 2020
067f651
Fix typos
ElectronicElephant Jul 5, 2020
4ebe16b
Resolve comments
ElectronicElephant Jul 5, 2020
7abf5de
update config
ElectronicElephant Jul 5, 2020
deb86e3
Merge pull request #12 from ElectronicElephant/yolo-dev
ElectronicElephant Jul 5, 2020
e7d5081
Merge branch 'master' into yolo-2.0-solve-conflicts
ElectronicElephant Jul 5, 2020
d0aecdb
flake8, yapf, docformatter, etc
ElectronicElephant Jul 5, 2020
a65b733
Update README
ElectronicElephant Jul 13, 2020
1cd4e77
Add conv_cfg to backbone and head
ElectronicElephant Jul 16, 2020
4f28a0f
Move some config to arch_settings in backbone
ElectronicElephant Jul 16, 2020
013d50c
Add doc strings and replace Warning with warnings.warn()
ElectronicElephant Jul 16, 2020
5f435b8
Fix bug.
ElectronicElephant Jul 16, 2020
bbde141
Update doc
ElectronicElephant Jul 16, 2020
f6784d5
Add _frozen_stages for backbone
ElectronicElephant Jul 21, 2020
a74355a
Update mmdet/models/backbones/darknet.py
ElectronicElephant Jul 21, 2020
04965c3
Fix inplace bug
ElectronicElephant Jul 21, 2020
44d6be3
Merge branch 'yolo-2.0-solve-conflicts' of github.com:ElectronicEleph…
ElectronicElephant Jul 21, 2020
7bbe4b4
fix indent
ElectronicElephant Jul 21, 2020
16b39d1
refactor config
xvjiarui Jul 26, 2020
b1a07ce
merge master>2.2.1
xvjiarui Jul 26, 2020
cfb5126
set 8GPU lr
xvjiarui Jul 26, 2020
48f791d
fixed typo
xvjiarui Jul 26, 2020
e3b6d26
update performance table
xvjiarui Aug 2, 2020
411180e
merge master
xvjiarui Aug 2, 2020
cce0b73
Resolve conversation
ElectronicElephant Aug 4, 2020
4b16235
Add anchor generator and coder
xvjiarui Aug 11, 2020
8b06764
fixed test
xvjiarui Aug 11, 2020
832e2d2
Finish refactor
xvjiarui Aug 13, 2020
4524789
Merge branch 'master' into yolo-2.0-solve-conflicts
xvjiarui Aug 13, 2020
a55f5b4
refactor anchor order
xvjiarui Aug 14, 2020
596e96e
fixed batch size
xvjiarui Aug 14, 2020
01722be
Fixed train_cfg
xvjiarui Aug 17, 2020
ec3b71c
fix yolo assigner
sudo-rm-covid19 Aug 18, 2020
00fb03e
clean up
xvjiarui Aug 19, 2020
c8577d3
Merge branch 'yolo-2.0-solve-conflicts' of https://github.com/sudo-rm…
xvjiarui Aug 19, 2020
ff7ff9d
Fixed format
xvjiarui Aug 19, 2020
5b8567d
Update model zoo
xvjiarui Aug 23, 2020
3d72a34
change to mmcv pretrain link
xvjiarui Aug 23, 2020
4c85d6c
add test forward
xvjiarui Aug 23, 2020
5649356
fixed comma and docstring
xvjiarui Aug 26, 2020
6d829eb
Refactor loss
xvjiarui Aug 26, 2020
d938a49
reformat
xvjiarui Aug 26, 2020
7271a5f
fixed avg_factor
xvjiarui Aug 27, 2020
aee61cf
revert to original
xvjiarui Aug 27, 2020
292a051
fixed format
xvjiarui Aug 28, 2020
1516dc8
update table
xvjiarui Aug 28, 2020
f526be0
fixed BCE
xvjiarui Aug 30, 2020
fd74165
merge master
xvjiarui Aug 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ Supported methods:
- [x] [DetectoRS](configs/detectors/README.md)
- [x] [Generalized Focal Loss](configs/gfl/README.md)
- [x] [CornerNet](configs/cornernet/README.md)
- [x] [YOLOv3](configs/yolo/README.md)

Some other methods are also supported in [projects using MMDetection](./docs/projects.md).

Expand Down
25 changes: 25 additions & 0 deletions configs/yolo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# YOLOv3

## Introduction
```
@misc{redmon2018yolov3,
title={YOLOv3: An Incremental Improvement},
author={Joseph Redmon and Ali Farhadi},
year={2018},
eprint={1804.02767},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
```

## Results and Models

| Backbone | Scale | Lr schd | Mem (GB) | Inf time (fps) | box AP | Download |
| :-------------: | :-----: | :-----: | :------: | :------------: | :----: | :-------: |
| DarkNet-53 | 320 | 273e | 2.7 | 50.9 | 28.6 | [model](https://openmmlab.oss-accelerate.aliyuncs.com/mmdetection/v2.0/yolo/yolov3_d53_320_273e_coco/yolov3_d53_320_273e_coco-421362b6.pth) | [log](https://openmmlab.oss-accelerate.aliyuncs.com/mmdetection/v2.0/yolo/yolov3_d53_320_273e_coco/yolov3_d53_320_273e_coco-20200819_172101.log.json) |
| DarkNet-53 | 416 | 273e | 3.8 | 50.9 | 30.7 | [model](https://openmmlab.oss-accelerate.aliyuncs.com/mmdetection/v2.0/yolo/yolov3_d53_mstrain-416_273e_coco/yolov3_d53_mstrain-416_273e_coco-2b60fcd9.pth) | [log](https://openmmlab.oss-accelerate.aliyuncs.com/mmdetection/v2.0/yolo/yolov3_d53_mstrain-416_273e_coco/yolov3_d53_mstrain-416_273e_coco-20200819_173424.log.json) |
| DarkNet-53 | 608 | 273e | 7.1 | 47.1 | 33.6 | [model](https://openmmlab.oss-accelerate.aliyuncs.com/mmdetection/v2.0/yolo/yolov3_d53_mstrain-608_273e_coco/yolov3_d53_mstrain-608_273e_coco-139f5633.pth) | [log](https://openmmlab.oss-accelerate.aliyuncs.com/mmdetection/v2.0/yolo/yolov3_d53_mstrain-608_273e_coco/yolov3_d53_mstrain-608_273e_coco-20200819_170820.log.json) |


## Credit
This implementation originates from the project of Haoyu Wu(@wuhy08) at Western Digital.
42 changes: 42 additions & 0 deletions configs/yolo/yolov3_d53_320_273e_coco.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
_base_ = './yolov3_d53_mstrain-608_273e_coco.py'
# dataset settings
img_norm_cfg = dict(mean=[0, 0, 0], std=[255., 255., 255.], to_rgb=True)
train_pipeline = [
dict(type='LoadImageFromFile', to_float32=True),
dict(type='LoadAnnotations', with_bbox=True),
dict(type='PhotoMetricDistortion'),
dict(
type='Expand',
mean=img_norm_cfg['mean'],
to_rgb=img_norm_cfg['to_rgb'],
ratio_range=(1, 2)),
dict(
type='MinIoURandomCrop',
min_ious=(0.4, 0.5, 0.6, 0.7, 0.8, 0.9),
min_crop_size=0.3),
dict(type='Resize', img_scale=(320, 320), keep_ratio=True),
dict(type='RandomFlip', flip_ratio=0.5),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']),
ElectronicElephant marked this conversation as resolved.
Show resolved Hide resolved
]
test_pipeline = [
dict(type='LoadImageFromFile'),
dict(
type='MultiScaleFlipAug',
img_scale=(320, 320),
flip=False,
transforms=[
dict(type='Resize', keep_ratio=True),
dict(type='RandomFlip'),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='ImageToTensor', keys=['img']),
dict(type='Collect', keys=['img']),
ElectronicElephant marked this conversation as resolved.
Show resolved Hide resolved
])
]
data = dict(
train=dict(pipeline=train_pipeline),
val=dict(pipeline=test_pipeline),
test=dict(pipeline=test_pipeline))
42 changes: 42 additions & 0 deletions configs/yolo/yolov3_d53_mstrain-416_273e_coco.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
_base_ = './yolov3_d53_mstrain-608_273e_coco.py'
# dataset settings
img_norm_cfg = dict(mean=[0, 0, 0], std=[255., 255., 255.], to_rgb=True)
train_pipeline = [
dict(type='LoadImageFromFile', to_float32=True),
dict(type='LoadAnnotations', with_bbox=True),
dict(type='PhotoMetricDistortion'),
dict(
type='Expand',
mean=img_norm_cfg['mean'],
to_rgb=img_norm_cfg['to_rgb'],
ratio_range=(1, 2)),
dict(
type='MinIoURandomCrop',
min_ious=(0.4, 0.5, 0.6, 0.7, 0.8, 0.9),
min_crop_size=0.3),
dict(type='Resize', img_scale=[(320, 320), (416, 416)], keep_ratio=True),
dict(type='RandomFlip', flip_ratio=0.5),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']),
]
test_pipeline = [
dict(type='LoadImageFromFile'),
dict(
type='MultiScaleFlipAug',
img_scale=(416, 416),
flip=False,
transforms=[
dict(type='Resize', keep_ratio=True),
dict(type='RandomFlip'),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='ImageToTensor', keys=['img']),
dict(type='Collect', keys=['img']),
])
]
data = dict(
train=dict(pipeline=train_pipeline),
val=dict(pipeline=test_pipeline),
test=dict(pipeline=test_pipeline))
117 changes: 117 additions & 0 deletions configs/yolo/yolov3_d53_mstrain-608_273e_coco.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
_base_ = [
'../_base_/default_runtime.py',
]
# model settings
model = dict(
type='YOLOV3',
pretrained='open-mmlab://darknet53',
backbone=dict(
type='Darknet',
depth=53,
out_indices=(3, 4, 5),
xvjiarui marked this conversation as resolved.
Show resolved Hide resolved
),
neck=dict(
type='YOLOV3Neck',
num_scales=3,
in_channels=[1024, 512, 256],
out_channels=[512, 256, 128],
xvjiarui marked this conversation as resolved.
Show resolved Hide resolved
),
bbox_head=dict(
type='YOLOV3Head',
num_classes=80,
in_channels=[512, 256, 128],
out_channels=[1024, 512, 256],
anchor_generator=dict(
type='YOLOAnchorGenerator',
base_sizes=[
[(116, 90), (156, 198), (373, 326)],
[(30, 61), (62, 45), (59, 119)],
[(10, 13), (16, 30), (33, 23)],
],
strides=[32, 16, 8]),
bbox_coder=dict(type='YOLOBBoxCoder'),
featmap_strides=[32, 16, 8]))
# training and testing settings
train_cfg = dict(
assigner=dict(
type='GridAssigner', pos_iou_thr=0.5, neg_iou_thr=0.5, min_pos_iou=0))
test_cfg = dict(
nms_pre=1000,
min_bbox_size=0,
score_thr=0.05,
conf_thr=0.005,
nms=dict(type='nms', iou_thr=0.45),
max_per_img=100)
# dataset settings
dataset_type = 'CocoDataset'
data_root = 'data/coco/'
img_norm_cfg = dict(mean=[0, 0, 0], std=[255., 255., 255.], to_rgb=True)
train_pipeline = [
dict(type='LoadImageFromFile', to_float32=True),
dict(type='LoadAnnotations', with_bbox=True),
dict(type='PhotoMetricDistortion'),
dict(
type='Expand',
mean=img_norm_cfg['mean'],
to_rgb=img_norm_cfg['to_rgb'],
ratio_range=(1, 2)),
dict(
type='MinIoURandomCrop',
min_ious=(0.4, 0.5, 0.6, 0.7, 0.8, 0.9),
min_crop_size=0.3),
dict(type='Resize', img_scale=[(320, 320), (608, 608)], keep_ratio=True),
dict(type='RandomFlip', flip_ratio=0.5),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']),
]
test_pipeline = [
dict(type='LoadImageFromFile'),
dict(
type='MultiScaleFlipAug',
img_scale=(608, 608),
flip=False,
transforms=[
dict(type='Resize', keep_ratio=True),
dict(type='RandomFlip'),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='ImageToTensor', keys=['img']),
dict(type='Collect', keys=['img']),
])
]
data = dict(
samples_per_gpu=8,
workers_per_gpu=4,
train=dict(
type=dataset_type,
ann_file=data_root + 'annotations/instances_train2017.json',
img_prefix=data_root + 'train2017/',
pipeline=train_pipeline,
),
val=dict(
type=dataset_type,
ann_file=data_root + 'annotations/instances_val2017.json',
img_prefix=data_root + 'val2017/',
pipeline=test_pipeline,
),
test=dict(
type=dataset_type,
ann_file=data_root + 'annotations/instances_val2017.json',
img_prefix=data_root + 'val2017/',
pipeline=test_pipeline,
xvjiarui marked this conversation as resolved.
Show resolved Hide resolved
))
# optimizer
optimizer = dict(type='SGD', lr=0.001, momentum=0.9, weight_decay=0.0005)
optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2))
# learning policy
lr_config = dict(
policy='step',
warmup='linear',
warmup_iters=2000, # same as burn-in in darknet
warmup_ratio=0.1,
step=[218, 246])
# runtime settings
total_epochs = 273
evaluation = dict(interval=1, metric=['bbox'])
3 changes: 3 additions & 0 deletions docs/model_zoo.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ Please refer to [Generalized Focal Loss](https://github.com/open-mmlab/mmdetecti
### CornerNet
Please refer to [CornerNet](https://github.com/open-mmlab/mmdetection/blob/master/configs/cornernet) for details.

### YOLOv3
Please refer to [YOLOv3](https://github.com/open-mmlab/mmdetection/blob/master/configs/yolo) for details.

### Other datasets

We also benchmark some methods on [PASCAL VOC](https://github.com/open-mmlab/mmdetection/blob/master/configs/pascal_voc), [Cityscapes](https://github.com/open-mmlab/mmdetection/blob/master/configs/cityscapes) and [WIDER FACE](https://github.com/open-mmlab/mmdetection/blob/master/configs/wider_face).
Expand Down
5 changes: 3 additions & 2 deletions mmdet/core/anchor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from .anchor_generator import AnchorGenerator, LegacyAnchorGenerator
from .anchor_generator import (AnchorGenerator, LegacyAnchorGenerator,
YOLOAnchorGenerator)
from .builder import ANCHOR_GENERATORS, build_anchor_generator
from .point_generator import PointGenerator
from .utils import anchor_inside_flags, calc_region, images_to_levels

__all__ = [
'AnchorGenerator', 'LegacyAnchorGenerator', 'anchor_inside_flags',
'PointGenerator', 'images_to_levels', 'calc_region',
'build_anchor_generator', 'ANCHOR_GENERATORS'
'build_anchor_generator', 'ANCHOR_GENERATORS', 'YOLOAnchorGenerator'
]
Loading