add *.py and converted *.pth
Browse files* *.py config files are copied and renamed from https://github.com/open-mmlab/mmyolo/tree/main/configs/yolov8
* *.pth model files are converted from https://huggingface.co/Bingsu/adetailer
- .gitattributes +2 -0
- default_runtime.py +43 -0
- face_yolov8n.pth +3 -0
- face_yolov8n.py +11 -0
- face_yolov8s.py +2 -0
- hand_yolov8n.pth +3 -0
- hand_yolov8n.py +11 -0
- hand_yolov8s.py +2 -0
- yolov8_s_syncbn_fast_8xb16-500e_coco.py +337 -0
.gitattributes
CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
face_yolov8s.pth filter=lfs diff=lfs merge=lfs -text
|
37 |
+
hand_yolov8s.pth filter=lfs diff=lfs merge=lfs -text
|
default_runtime.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
default_scope = 'mmyolo'
|
2 |
+
|
3 |
+
default_hooks = dict(
|
4 |
+
timer=dict(type='IterTimerHook'),
|
5 |
+
logger=dict(type='LoggerHook', interval=50),
|
6 |
+
param_scheduler=dict(type='ParamSchedulerHook'),
|
7 |
+
checkpoint=dict(type='CheckpointHook', interval=1),
|
8 |
+
sampler_seed=dict(type='DistSamplerSeedHook'),
|
9 |
+
visualization=dict(type='mmdet.DetVisualizationHook'))
|
10 |
+
|
11 |
+
env_cfg = dict(
|
12 |
+
cudnn_benchmark=False,
|
13 |
+
mp_cfg=dict(mp_start_method='fork', opencv_num_threads=0),
|
14 |
+
dist_cfg=dict(backend='nccl'),
|
15 |
+
)
|
16 |
+
|
17 |
+
vis_backends = [dict(type='LocalVisBackend')]
|
18 |
+
visualizer = dict(
|
19 |
+
type='mmdet.DetLocalVisualizer',
|
20 |
+
vis_backends=vis_backends,
|
21 |
+
name='visualizer')
|
22 |
+
log_processor = dict(type='LogProcessor', window_size=50, by_epoch=True)
|
23 |
+
|
24 |
+
log_level = 'INFO'
|
25 |
+
load_from = None
|
26 |
+
resume = False
|
27 |
+
|
28 |
+
# Example to use different file client
|
29 |
+
# Method 1: simply set the data root and let the file I/O module
|
30 |
+
# automatically infer from prefix (not support LMDB and Memcache yet)
|
31 |
+
|
32 |
+
# data_root = 's3://openmmlab/datasets/detection/coco/'
|
33 |
+
|
34 |
+
# Method 2: Use `backend_args`, `file_client_args` in versions
|
35 |
+
# before MMDet 3.0.0rc6
|
36 |
+
# backend_args = dict(
|
37 |
+
# backend='petrel',
|
38 |
+
# path_mapping=dict({
|
39 |
+
# './data/': 's3://openmmlab/datasets/detection/',
|
40 |
+
# 'data/': 's3://openmmlab/datasets/detection/'
|
41 |
+
# }))
|
42 |
+
|
43 |
+
backend_args = None
|
face_yolov8n.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3844d325842ffc3a84e290877cd48fc856464c9aa877158285621840b71b6735
|
3 |
+
size 6156209
|
face_yolov8n.py
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# from https://github.com/open-mmlab/mmyolo/blob/main/configs/yolov8
|
2 |
+
# copy of the original source https://github.com/open-mmlab/mmyolo/blob/main/configs/yolov8/yolov8_n_syncbn_fast_8xb16-500e_coco.py
|
3 |
+
_base_ = './yolov8_s_syncbn_fast_8xb16-500e_coco.py'
|
4 |
+
|
5 |
+
deepen_factor = 0.33
|
6 |
+
widen_factor = 0.25
|
7 |
+
|
8 |
+
model = dict(
|
9 |
+
backbone=dict(deepen_factor=deepen_factor, widen_factor=widen_factor),
|
10 |
+
neck=dict(deepen_factor=deepen_factor, widen_factor=widen_factor),
|
11 |
+
bbox_head=dict(head_module=dict(widen_factor=widen_factor)))
|
face_yolov8s.py
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
# alias file
|
2 |
+
_base_ = './yolov8_s_syncbn_fast_8xb16-500e_coco.py'
|
hand_yolov8n.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:81c1d210811984430922ae3663f5229939b0d81ed6970762df9f95dd822d3f8c
|
3 |
+
size 6156209
|
hand_yolov8n.py
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# from https://github.com/open-mmlab/mmyolo/blob/main/configs/yolov8
|
2 |
+
# copy of the original source https://github.com/open-mmlab/mmyolo/blob/main/configs/yolov8/yolov8_n_syncbn_fast_8xb16-500e_coco.py
|
3 |
+
_base_ = './yolov8_s_syncbn_fast_8xb16-500e_coco.py'
|
4 |
+
|
5 |
+
deepen_factor = 0.33
|
6 |
+
widen_factor = 0.25
|
7 |
+
|
8 |
+
model = dict(
|
9 |
+
backbone=dict(deepen_factor=deepen_factor, widen_factor=widen_factor),
|
10 |
+
neck=dict(deepen_factor=deepen_factor, widen_factor=widen_factor),
|
11 |
+
bbox_head=dict(head_module=dict(widen_factor=widen_factor)))
|
hand_yolov8s.py
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
# alias file
|
2 |
+
_base_ = './yolov8_s_syncbn_fast_8xb16-500e_coco.py'
|
yolov8_s_syncbn_fast_8xb16-500e_coco.py
ADDED
@@ -0,0 +1,337 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# from https://github.com/open-mmlab/mmyolo/blob/main/configs/yolov8
|
2 |
+
# copy of the original source https://github.com/open-mmlab/mmyolo/blob/main/configs/yolov8/yolov8_s_syncbn_fast_8xb16-500e_coco.py
|
3 |
+
#_base_ = ['../_base_/default_runtime.py', '../_base_/det_p5_tta.py']
|
4 |
+
_base_ = ['./default_runtime.py']
|
5 |
+
|
6 |
+
# ========================Frequently modified parameters======================
|
7 |
+
# -----data related-----
|
8 |
+
data_root = 'data/coco/' # Root path of data
|
9 |
+
# Path of train annotation file
|
10 |
+
train_ann_file = 'annotations/instances_train2017.json'
|
11 |
+
train_data_prefix = 'train2017/' # Prefix of train image path
|
12 |
+
# Path of val annotation file
|
13 |
+
val_ann_file = 'annotations/instances_val2017.json'
|
14 |
+
val_data_prefix = 'val2017/' # Prefix of val image path
|
15 |
+
|
16 |
+
num_classes = 1 # Number of classes for classification
|
17 |
+
# Batch size of a single GPU during training
|
18 |
+
train_batch_size_per_gpu = 16
|
19 |
+
# Worker to pre-fetch data for each single GPU during training
|
20 |
+
train_num_workers = 8
|
21 |
+
# persistent_workers must be False if num_workers is 0
|
22 |
+
persistent_workers = True
|
23 |
+
|
24 |
+
# -----train val related-----
|
25 |
+
# Base learning rate for optim_wrapper. Corresponding to 8xb16=64 bs
|
26 |
+
base_lr = 0.01
|
27 |
+
max_epochs = 500 # Maximum training epochs
|
28 |
+
# Disable mosaic augmentation for final 10 epochs (stage 2)
|
29 |
+
close_mosaic_epochs = 10
|
30 |
+
|
31 |
+
model_test_cfg = dict(
|
32 |
+
# The config of multi-label for multi-class prediction.
|
33 |
+
multi_label=True,
|
34 |
+
# The number of boxes before NMS
|
35 |
+
nms_pre=30000,
|
36 |
+
score_thr=0.001, # Threshold to filter out boxes.
|
37 |
+
nms=dict(type='nms', iou_threshold=0.7), # NMS type and threshold
|
38 |
+
max_per_img=300) # Max number of detections of each image
|
39 |
+
|
40 |
+
# ========================Possible modified parameters========================
|
41 |
+
# -----data related-----
|
42 |
+
img_scale = (640, 640) # width, height
|
43 |
+
# Dataset type, this will be used to define the dataset
|
44 |
+
dataset_type = 'YOLOv5CocoDataset'
|
45 |
+
# Batch size of a single GPU during validation
|
46 |
+
val_batch_size_per_gpu = 1
|
47 |
+
# Worker to pre-fetch data for each single GPU during validation
|
48 |
+
val_num_workers = 2
|
49 |
+
|
50 |
+
# Config of batch shapes. Only on val.
|
51 |
+
# We tested YOLOv8-m will get 0.02 higher than not using it.
|
52 |
+
batch_shapes_cfg = None
|
53 |
+
# You can turn on `batch_shapes_cfg` by uncommenting the following lines.
|
54 |
+
# batch_shapes_cfg = dict(
|
55 |
+
# type='BatchShapePolicy',
|
56 |
+
# batch_size=val_batch_size_per_gpu,
|
57 |
+
# img_size=img_scale[0],
|
58 |
+
# # The image scale of padding should be divided by pad_size_divisor
|
59 |
+
# size_divisor=32,
|
60 |
+
# # Additional paddings for pixel scale
|
61 |
+
# extra_pad_ratio=0.5)
|
62 |
+
|
63 |
+
# -----model related-----
|
64 |
+
# The scaling factor that controls the depth of the network structure
|
65 |
+
deepen_factor = 0.33
|
66 |
+
# The scaling factor that controls the width of the network structure
|
67 |
+
widen_factor = 0.5
|
68 |
+
# Strides of multi-scale prior box
|
69 |
+
strides = [8, 16, 32]
|
70 |
+
# The output channel of the last stage
|
71 |
+
last_stage_out_channels = 1024
|
72 |
+
num_det_layers = 3 # The number of model output scales
|
73 |
+
norm_cfg = dict(type='BN', momentum=0.03, eps=0.001) # Normalization config
|
74 |
+
|
75 |
+
# -----train val related-----
|
76 |
+
affine_scale = 0.5 # YOLOv5RandomAffine scaling ratio
|
77 |
+
# YOLOv5RandomAffine aspect ratio of width and height thres to filter bboxes
|
78 |
+
max_aspect_ratio = 100
|
79 |
+
tal_topk = 10 # Number of bbox selected in each level
|
80 |
+
tal_alpha = 0.5 # A Hyper-parameter related to alignment_metrics
|
81 |
+
tal_beta = 6.0 # A Hyper-parameter related to alignment_metrics
|
82 |
+
# TODO: Automatically scale loss_weight based on number of detection layers
|
83 |
+
loss_cls_weight = 0.5
|
84 |
+
loss_bbox_weight = 7.5
|
85 |
+
# Since the dfloss is implemented differently in the official
|
86 |
+
# and mmdet, we're going to divide loss_weight by 4.
|
87 |
+
loss_dfl_weight = 1.5 / 4
|
88 |
+
lr_factor = 0.01 # Learning rate scaling factor
|
89 |
+
weight_decay = 0.0005
|
90 |
+
# Save model checkpoint and validation intervals in stage 1
|
91 |
+
save_epoch_intervals = 10
|
92 |
+
# validation intervals in stage 2
|
93 |
+
val_interval_stage2 = 1
|
94 |
+
# The maximum checkpoints to keep.
|
95 |
+
max_keep_ckpts = 2
|
96 |
+
# Single-scale training is recommended to
|
97 |
+
# be turned on, which can speed up training.
|
98 |
+
env_cfg = dict(cudnn_benchmark=True)
|
99 |
+
|
100 |
+
# ===============================Unmodified in most cases====================
|
101 |
+
model = dict(
|
102 |
+
type='YOLODetector',
|
103 |
+
data_preprocessor=dict(
|
104 |
+
type='YOLOv5DetDataPreprocessor',
|
105 |
+
mean=[0., 0., 0.],
|
106 |
+
std=[255., 255., 255.],
|
107 |
+
bgr_to_rgb=True),
|
108 |
+
backbone=dict(
|
109 |
+
type='YOLOv8CSPDarknet',
|
110 |
+
arch='P5',
|
111 |
+
last_stage_out_channels=last_stage_out_channels,
|
112 |
+
deepen_factor=deepen_factor,
|
113 |
+
widen_factor=widen_factor,
|
114 |
+
norm_cfg=norm_cfg,
|
115 |
+
act_cfg=dict(type='SiLU', inplace=True)),
|
116 |
+
neck=dict(
|
117 |
+
type='YOLOv8PAFPN',
|
118 |
+
deepen_factor=deepen_factor,
|
119 |
+
widen_factor=widen_factor,
|
120 |
+
in_channels=[256, 512, last_stage_out_channels],
|
121 |
+
out_channels=[256, 512, last_stage_out_channels],
|
122 |
+
num_csp_blocks=3,
|
123 |
+
norm_cfg=norm_cfg,
|
124 |
+
act_cfg=dict(type='SiLU', inplace=True)),
|
125 |
+
bbox_head=dict(
|
126 |
+
type='YOLOv8Head',
|
127 |
+
head_module=dict(
|
128 |
+
type='YOLOv8HeadModule',
|
129 |
+
num_classes=num_classes,
|
130 |
+
in_channels=[256, 512, last_stage_out_channels],
|
131 |
+
widen_factor=widen_factor,
|
132 |
+
reg_max=16,
|
133 |
+
norm_cfg=norm_cfg,
|
134 |
+
act_cfg=dict(type='SiLU', inplace=True),
|
135 |
+
featmap_strides=strides),
|
136 |
+
prior_generator=dict(
|
137 |
+
type='mmdet.MlvlPointGenerator', offset=0.5, strides=strides),
|
138 |
+
bbox_coder=dict(type='DistancePointBBoxCoder'),
|
139 |
+
# scaled based on number of detection layers
|
140 |
+
loss_cls=dict(
|
141 |
+
type='mmdet.CrossEntropyLoss',
|
142 |
+
use_sigmoid=True,
|
143 |
+
reduction='none',
|
144 |
+
loss_weight=loss_cls_weight),
|
145 |
+
loss_bbox=dict(
|
146 |
+
type='IoULoss',
|
147 |
+
iou_mode='ciou',
|
148 |
+
bbox_format='xyxy',
|
149 |
+
reduction='sum',
|
150 |
+
loss_weight=loss_bbox_weight,
|
151 |
+
return_iou=False),
|
152 |
+
loss_dfl=dict(
|
153 |
+
type='mmdet.DistributionFocalLoss',
|
154 |
+
reduction='mean',
|
155 |
+
loss_weight=loss_dfl_weight)),
|
156 |
+
train_cfg=dict(
|
157 |
+
assigner=dict(
|
158 |
+
type='BatchTaskAlignedAssigner',
|
159 |
+
num_classes=num_classes,
|
160 |
+
use_ciou=True,
|
161 |
+
topk=tal_topk,
|
162 |
+
alpha=tal_alpha,
|
163 |
+
beta=tal_beta,
|
164 |
+
eps=1e-9)),
|
165 |
+
test_cfg=model_test_cfg)
|
166 |
+
|
167 |
+
albu_train_transforms = [
|
168 |
+
dict(type='Blur', p=0.01),
|
169 |
+
dict(type='MedianBlur', p=0.01),
|
170 |
+
dict(type='ToGray', p=0.01),
|
171 |
+
dict(type='CLAHE', p=0.01)
|
172 |
+
]
|
173 |
+
|
174 |
+
pre_transform = [
|
175 |
+
dict(type='LoadImageFromFile', backend_args=_base_.backend_args),
|
176 |
+
dict(type='LoadAnnotations', with_bbox=True)
|
177 |
+
]
|
178 |
+
|
179 |
+
last_transform = [
|
180 |
+
dict(
|
181 |
+
type='mmdet.Albu',
|
182 |
+
transforms=albu_train_transforms,
|
183 |
+
bbox_params=dict(
|
184 |
+
type='BboxParams',
|
185 |
+
format='pascal_voc',
|
186 |
+
label_fields=['gt_bboxes_labels', 'gt_ignore_flags']),
|
187 |
+
keymap={
|
188 |
+
'img': 'image',
|
189 |
+
'gt_bboxes': 'bboxes'
|
190 |
+
}),
|
191 |
+
dict(type='YOLOv5HSVRandomAug'),
|
192 |
+
dict(type='mmdet.RandomFlip', prob=0.5),
|
193 |
+
dict(
|
194 |
+
type='mmdet.PackDetInputs',
|
195 |
+
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'flip',
|
196 |
+
'flip_direction'))
|
197 |
+
]
|
198 |
+
|
199 |
+
train_pipeline = [
|
200 |
+
*pre_transform,
|
201 |
+
dict(
|
202 |
+
type='Mosaic',
|
203 |
+
img_scale=img_scale,
|
204 |
+
pad_val=114.0,
|
205 |
+
pre_transform=pre_transform),
|
206 |
+
dict(
|
207 |
+
type='YOLOv5RandomAffine',
|
208 |
+
max_rotate_degree=0.0,
|
209 |
+
max_shear_degree=0.0,
|
210 |
+
scaling_ratio_range=(1 - affine_scale, 1 + affine_scale),
|
211 |
+
max_aspect_ratio=max_aspect_ratio,
|
212 |
+
# img_scale is (width, height)
|
213 |
+
border=(-img_scale[0] // 2, -img_scale[1] // 2),
|
214 |
+
border_val=(114, 114, 114)),
|
215 |
+
*last_transform
|
216 |
+
]
|
217 |
+
|
218 |
+
train_pipeline_stage2 = [
|
219 |
+
*pre_transform,
|
220 |
+
dict(type='YOLOv5KeepRatioResize', scale=img_scale),
|
221 |
+
dict(
|
222 |
+
type='LetterResize',
|
223 |
+
scale=img_scale,
|
224 |
+
allow_scale_up=True,
|
225 |
+
pad_val=dict(img=114.0)),
|
226 |
+
dict(
|
227 |
+
type='YOLOv5RandomAffine',
|
228 |
+
max_rotate_degree=0.0,
|
229 |
+
max_shear_degree=0.0,
|
230 |
+
scaling_ratio_range=(1 - affine_scale, 1 + affine_scale),
|
231 |
+
max_aspect_ratio=max_aspect_ratio,
|
232 |
+
border_val=(114, 114, 114)), *last_transform
|
233 |
+
]
|
234 |
+
|
235 |
+
train_dataloader = dict(
|
236 |
+
batch_size=train_batch_size_per_gpu,
|
237 |
+
num_workers=train_num_workers,
|
238 |
+
persistent_workers=persistent_workers,
|
239 |
+
pin_memory=True,
|
240 |
+
sampler=dict(type='DefaultSampler', shuffle=True),
|
241 |
+
collate_fn=dict(type='yolov5_collate'),
|
242 |
+
dataset=dict(
|
243 |
+
type=dataset_type,
|
244 |
+
data_root=data_root,
|
245 |
+
ann_file=train_ann_file,
|
246 |
+
data_prefix=dict(img=train_data_prefix),
|
247 |
+
filter_cfg=dict(filter_empty_gt=False, min_size=32),
|
248 |
+
pipeline=train_pipeline))
|
249 |
+
|
250 |
+
test_pipeline = [
|
251 |
+
dict(type='LoadImageFromFile', backend_args=_base_.backend_args),
|
252 |
+
dict(type='YOLOv5KeepRatioResize', scale=img_scale),
|
253 |
+
dict(
|
254 |
+
type='LetterResize',
|
255 |
+
scale=img_scale,
|
256 |
+
allow_scale_up=False,
|
257 |
+
pad_val=dict(img=114)),
|
258 |
+
dict(type='LoadAnnotations', with_bbox=True, _scope_='mmdet'),
|
259 |
+
dict(
|
260 |
+
type='mmdet.PackDetInputs',
|
261 |
+
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
|
262 |
+
'scale_factor', 'pad_param'))
|
263 |
+
]
|
264 |
+
|
265 |
+
val_dataloader = dict(
|
266 |
+
batch_size=val_batch_size_per_gpu,
|
267 |
+
num_workers=val_num_workers,
|
268 |
+
persistent_workers=persistent_workers,
|
269 |
+
pin_memory=True,
|
270 |
+
drop_last=False,
|
271 |
+
sampler=dict(type='DefaultSampler', shuffle=False),
|
272 |
+
dataset=dict(
|
273 |
+
type=dataset_type,
|
274 |
+
data_root=data_root,
|
275 |
+
test_mode=True,
|
276 |
+
data_prefix=dict(img=val_data_prefix),
|
277 |
+
ann_file=val_ann_file,
|
278 |
+
pipeline=test_pipeline,
|
279 |
+
batch_shapes_cfg=batch_shapes_cfg))
|
280 |
+
|
281 |
+
test_dataloader = val_dataloader
|
282 |
+
|
283 |
+
param_scheduler = None
|
284 |
+
optim_wrapper = dict(
|
285 |
+
type='OptimWrapper',
|
286 |
+
clip_grad=dict(max_norm=10.0),
|
287 |
+
optimizer=dict(
|
288 |
+
type='SGD',
|
289 |
+
lr=base_lr,
|
290 |
+
momentum=0.937,
|
291 |
+
weight_decay=weight_decay,
|
292 |
+
nesterov=True,
|
293 |
+
batch_size_per_gpu=train_batch_size_per_gpu),
|
294 |
+
constructor='YOLOv5OptimizerConstructor')
|
295 |
+
|
296 |
+
default_hooks = dict(
|
297 |
+
param_scheduler=dict(
|
298 |
+
type='YOLOv5ParamSchedulerHook',
|
299 |
+
scheduler_type='linear',
|
300 |
+
lr_factor=lr_factor,
|
301 |
+
max_epochs=max_epochs),
|
302 |
+
checkpoint=dict(
|
303 |
+
type='CheckpointHook',
|
304 |
+
interval=save_epoch_intervals,
|
305 |
+
save_best='auto',
|
306 |
+
max_keep_ckpts=max_keep_ckpts))
|
307 |
+
|
308 |
+
custom_hooks = [
|
309 |
+
dict(
|
310 |
+
type='EMAHook',
|
311 |
+
ema_type='ExpMomentumEMA',
|
312 |
+
momentum=0.0001,
|
313 |
+
update_buffers=True,
|
314 |
+
strict_load=False,
|
315 |
+
priority=49),
|
316 |
+
dict(
|
317 |
+
type='mmdet.PipelineSwitchHook',
|
318 |
+
switch_epoch=max_epochs - close_mosaic_epochs,
|
319 |
+
switch_pipeline=train_pipeline_stage2)
|
320 |
+
]
|
321 |
+
|
322 |
+
val_evaluator = dict(
|
323 |
+
type='mmdet.CocoMetric',
|
324 |
+
proposal_nums=(100, 1, 10),
|
325 |
+
ann_file=data_root + val_ann_file,
|
326 |
+
metric='bbox')
|
327 |
+
test_evaluator = val_evaluator
|
328 |
+
|
329 |
+
train_cfg = dict(
|
330 |
+
type='EpochBasedTrainLoop',
|
331 |
+
max_epochs=max_epochs,
|
332 |
+
val_interval=save_epoch_intervals,
|
333 |
+
dynamic_intervals=[((max_epochs - close_mosaic_epochs),
|
334 |
+
val_interval_stage2)])
|
335 |
+
|
336 |
+
val_cfg = dict(type='ValLoop')
|
337 |
+
test_cfg = dict(type='TestLoop')
|