Skip to content

Commit

Permalink
Add: Add yolov5 to sscma and remove mmyolo (#216)
Browse files Browse the repository at this point in the history
* Add: Add Basebackbone and CSPDarknet

* Add: Add BaseDetector and YOLOv5Detector

* Add: Add ConvModule and DepthwiseSeparableConvModule

* Add: Add YOLOv5 head and delete YOLOv8 head

* Add: Add YOLOv5 Neck SPPF and PAFPN

* Add: Add YOLOv5 IOU loss and bboxcoder

* Refractor: Modify get_featmap and get_flops

* Refractor: Change mmyolo config to sscma

* Add: Add copyright

* Fix: Remove module imported but not used

* Style: Change name to YOLOBasebackbone
  • Loading branch information
MILK-BIOS authored Apr 28, 2024
1 parent 7f9c4e0 commit 40fd17a
Show file tree
Hide file tree
Showing 42 changed files with 2,294 additions and 304 deletions.
4 changes: 2 additions & 2 deletions configs/pfld/pfld_dan_fpn_x8_192.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@
model = dict(
type='PFLD',
backbone=dict(
type='mmyolo.YOLOv5CSPDarknet',
type='sscma.YOLOv5CSPDarknet',
deepen_factor=deepen_factor,
widen_factor=widen_factor,
norm_cfg=norm_cfg,
act_cfg=dict(type='SiLU', inplace=True),
),
neck=dict(
type='mmyolo.YOLOv5PAFPN',
type='sscma.YOLOv5PAFPN',
deepen_factor=deepen_factor,
widen_factor=widen_factor,
in_channels=[256, 512, 1024],
Expand Down
4 changes: 2 additions & 2 deletions configs/swift_yolo/base_arch.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (c) Seeed Technology Co.,Ltd. All rights reserved.
_base_ = ['../_base_/default_runtime_det.py']
default_scope = 'mmyolo'
default_scope = 'sscma'

# ========================Suggested optional parameters========================
# DATA
Expand Down Expand Up @@ -114,7 +114,7 @@

# model arch
model = dict(
type='mmyolo.YOLODetector',
type='sscma.YOLODetector',
data_preprocessor=dict(
type='mmdet.DetDataPreprocessor', mean=[0.0, 0.0, 0.0], std=[255.0, 255.0, 255.0], bgr_to_rgb=True
),
Expand Down
3 changes: 1 addition & 2 deletions configs/swift_yolo/swift_yolo_1xb16_300e_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
]

model = dict(
type='mmyolo.YOLODetector',
type='sscma.YOLODetector',
backbone=dict(
type='YOLOv5CSPDarknet',
deepen_factor=deepen_factor,
Expand Down Expand Up @@ -86,7 +86,6 @@
dict(type='LoadAnnotations', with_bbox=True),
]

# from mmyolo.datasets.transforms import YOLOv5RandomAffine

color_space = [
[dict(type='mmdet.ColorTransform')],
Expand Down
4 changes: 2 additions & 2 deletions configs/swift_yolo/swift_yolo_labelmatch_coco.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (c) Seeed Technology Co.,Ltd. All rights reserved.
_base_ = ['../_base_/default_runtime_det.py']
default_scope = 'mmyolo'
default_scope = 'sscma'

# ========================Suggested optional parameters========================
# DATA
Expand Down Expand Up @@ -106,7 +106,7 @@

# model arch
detector = dict(
type='mmyolo.YOLODetector',
type='sscma.YOLODetector',
data_preprocessor=dict(
type='mmdet.DetDataPreprocessor', mean=[0.0, 0.0, 0.0], std=[255.0, 255.0, 255.0], bgr_to_rgb=True
),
Expand Down
2 changes: 1 addition & 1 deletion configs/swift_yolo/swift_yolo_large_1xb16_300e_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
]

model = dict(
type='mmyolo.YOLODetector',
type='sscma.YOLODetector',
backbone=dict(
type='YOLOv5CSPDarknet',
deepen_factor=deepen_factor,
Expand Down
4 changes: 2 additions & 2 deletions configs/swift_yolo/swift_yolo_mb2_1xb16_300e_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'../_base_/default_runtime_det.py',
]

default_scope = 'mmyolo'
default_scope = 'sscma'
# ========================Suggested optional parameters========================
# MODEL
# The scaling factor that controls the depth of the network structure
Expand Down Expand Up @@ -109,7 +109,7 @@

# model arch
model = dict(
type='mmyolo.YOLODetector',
type='sscma.YOLODetector',
data_preprocessor=dict(
type='mmdet.DetDataPreprocessor', mean=[0.0, 0.0, 0.0], std=[255.0, 255.0, 255.0], bgr_to_rgb=True
),
Expand Down
2 changes: 1 addition & 1 deletion configs/swift_yolo/swift_yolo_medium_1xb16_300e_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
]

model = dict(
type='mmyolo.YOLODetector',
type='sscma.YOLODetector',
backbone=dict(
type='YOLOv5CSPDarknet',
deepen_factor=deepen_factor,
Expand Down
2 changes: 1 addition & 1 deletion configs/swift_yolo/swift_yolo_nano_1xb16_300e_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
]

model = dict(
type='mmyolo.YOLODetector',
type='sscma.YOLODetector',
backbone=dict(
type='YOLOv5CSPDarknet',
deepen_factor=deepen_factor,
Expand Down
2 changes: 1 addition & 1 deletion configs/swift_yolo/swift_yolo_shuff_1xb16_300e_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
]

model = dict(
type='mmyolo.YOLODetector',
type='sscma.YOLODetector',
backbone=dict(
type='FastShuffleNetV2',
stage_repeats=[4, 8, 4],
Expand Down
2 changes: 1 addition & 1 deletion configs/swift_yolo/swift_yolo_small_1xb16_300e_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
]

model = dict(
type='mmyolo.YOLODetector',
type='sscma.YOLODetector',
backbone=dict(
type='YOLOv5CSPDarknet',
deepen_factor=deepen_factor,
Expand Down
13 changes: 6 additions & 7 deletions configs/swift_yolo/swift_yolo_tiny_1xb16_300e_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
]

model = dict(
type='mmyolo.YOLODetector',
type='sscma.YOLODetector',
backbone=dict(
type='YOLOv5CSPDarknet',
deepen_factor=deepen_factor,
Expand Down Expand Up @@ -83,7 +83,7 @@

pre_transform = [
dict(type='LoadImageFromFile', file_client_args=dict(backend='disk')),
dict(type='LoadAnnotations', with_bbox=True, _scope_='sscma'),
dict(type='LoadAnnotations', with_bbox=True),
]

train_pipeline = [
Expand All @@ -97,15 +97,14 @@
# imgsz is (width, height)
border=(-imgsz[0] // 2, -imgsz[1] // 2),
border_val=(114, 114, 114),
_scope_='sscma'
),
dict(
type='mmdet.Albu',
transforms=albu_train_transforms,
bbox_params=dict(type='BboxParams', format='pascal_voc', label_fields=['gt_bboxes_labels', 'gt_ignore_flags']),
keymap={'img': 'image', 'gt_bboxes': 'bboxes'},
),
dict(type='YOLOv5HSVRandomAug', _scope_='sscma'),
dict(type='YOLOv5HSVRandomAug'),
dict(type='mmdet.RandomFlip', prob=0.5),
dict(
type='mmdet.PackDetInputs', meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'flip', 'flip_direction')
Expand All @@ -130,9 +129,9 @@

test_pipeline = [
dict(type='LoadImageFromFile', file_client_args=dict(backend='disk')),
dict(type='YOLOv5KeepRatioResize', scale=imgsz, _scope_='sscma'),
dict(type='sscma.LetterResize', scale=imgsz, allow_scale_up=False, pad_val=dict(img=114), _scope_='sscma'),
dict(type='LoadAnnotations', with_bbox=True, _scope_='sscma'),
dict(type='YOLOv5KeepRatioResize', scale=imgsz),
dict(type='sscma.LetterResize', scale=imgsz, allow_scale_up=False, pad_val=dict(img=114)),
dict(type='LoadAnnotations', with_bbox=True),
dict(
type='mmdet.PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'scale_factor', 'pad_param'),
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/training/yolo.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ widen_factor = 0.15
strides = [8, 16, 32]

model = dict(
type='mmyolo.YOLODetector',
type='sscma.YOLODetector',
backbone=dict(
type='YOLOv5CSPDarknet',
deepen_factor=deepen_factor,
Expand Down
2 changes: 1 addition & 1 deletion docs/zh_cn/tutorials/training/yolo.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ widen_factor = 0.15
strides = [8, 16, 32]

model = dict(
type='mmyolo.YOLODetector',
type='sscma.YOLODetector',
backbone=dict(
type='YOLOv5CSPDarknet',
deepen_factor=deepen_factor,
Expand Down
2 changes: 0 additions & 2 deletions requirements/mmlab.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@ mmcls>=1.0.0.rc6
mmcv-full<=2.1.0
mmdet>=3.0.0, <3.1.0 # mmyolo currently does not support mmdet 3.1.0
mmengine>=0.8.2

mmyolo @ https://files.seeedstudio.com/sscma/library/mmyolo-0.5.0-py3-none-any.whl
3 changes: 2 additions & 1 deletion sscma/datasets/cocodataset.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright (c) Seeed Technology Co.,Ltd. All rights reserved.
# Copyright (c) Seeed Technology Co.,Ltd.
# Copyright (c) OpenMMLab.
import json
import os.path as osp
from typing import Optional, Sequence, List
Expand Down
3 changes: 2 additions & 1 deletion sscma/datasets/transforms/transforms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright (c) Seeed Technology Co.,Ltd. All rights reserved.
# Copyright (c) Seeed Technology Co.,Ltd.
# Copyright (c) OpenMMLab.
from typing import Union, Tuple, Sequence
import numpy as np
from numpy import random
Expand Down
5 changes: 2 additions & 3 deletions sscma/datasets/transforms/utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Copyright (c) OpenMMLab. All rights reserved.
# Copyright (c) Seeed Technology Co.,Ltd.
# Copyright (c) OpenMMLab.
from typing import List, Sequence

import numpy as np
import torch
from mmengine.dataset import COLLATE_FUNCTIONS

from sscma.registry import TASK_UTILS


Expand Down
3 changes: 2 additions & 1 deletion sscma/datasets/yolodataset.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright (c) Seeed Technology Co.,Ltd. All rights reserved.
# Copyright (c) Seeed Technology Co.,Ltd.
# Copyright (c) OpenMMLab.
import json
import os.path as osp
from typing import Optional, Sequence, Any
Expand Down
3 changes: 2 additions & 1 deletion sscma/engine/hooks/yolov5_param_scheduler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright (c) Seeed Technology Co.,Ltd. All rights reserved.
# Copyright (c) Seeed Technology Co.,Ltd.
# Copyright (c) OpenMMLab.
import math
from typing import Optional

Expand Down
4 changes: 4 additions & 0 deletions sscma/models/backbones/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from .SoundNet import SoundNetRaw
from .SqueezeNet import SqueezeNet
from .MicroNet import MicroNet
from .csp_darknet import YOLOv5CSPDarknet
from .base_backbone import YOLOBaseBackbone

__all__ = [
'PfldMobileNetV2',
Expand All @@ -21,4 +23,6 @@
'MobileNetv2',
'MicroNet',
"FastShuffleNetV2",
'YOLOv5CSPDarknet',
'YOLOBaseBackbone',
]
Loading

0 comments on commit 40fd17a

Please sign in to comment.