-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
91 lines (79 loc) · 2.44 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# ------------------ Dataset Config ------------------
def build_dataset_config():
cfg = {
'data_name': 'VOC',
'num_classes': 20,
'class_indexs': None,
'class_names': ('aeroplane', 'bicycle', 'bird', 'boat',
'bottle', 'bus', 'car', 'cat', 'chair',
'cow', 'diningtable', 'dog', 'horse',
'motorbike', 'person', 'pottedplant',
'sheep', 'sofa', 'train', 'tvmonitor'),
}
print('==============================')
print('Dataset Config: {} \n'.format(cfg))
return cfg
# ----------------------- SSD-Style Transform -----------------------
# ------------------ Transform Config ------------------
def build_trans_config():
trans_config='ssd'
print('==============================')
print('Transform: {}-Style ...'.format(trans_config))
ssd_trans_config = {
'aug_type': 'ssd',
'use_ablu': False,
# Mosaic & Mixup are not used for SSD-style augmentation
'mosaic_prob': 0.,
'mixup_prob': 0.,
'mosaic_type': 'yolov5_mosaic',
'mixup_type': 'yolov5_mixup',
'mixup_scale': [0.5, 1.5]
}
cfg = ssd_trans_config
print('Transform Config: {} \n'.format(cfg))
return cfg
# ------------------ Model Config ------------------
## YOLO series
# YOLOv2 Config
yolov2_cfg = {
# input
'trans_type': 'ssd',
'multi_scale': [0.5, 1.5],
# model
'backbone': 'darknet19',
'pretrained': True,
'stride': 32, # P5
'max_stride': 32,
# neck
'neck': 'sppf',
'expand_ratio': 0.5,
'pooling_size': 5,
'neck_act': 'lrelu',
'neck_norm': 'BN',
'neck_depthwise': False,
# head
'head': 'decoupled_head',
'head_act': 'lrelu',
'head_norm': 'BN',
'num_cls_head': 2,
'num_reg_head': 2,
'head_depthwise': False,
'anchor_size': [[17, 25],
[55, 75],
[92, 206],
[202, 21],
[289, 311]], # 416
# matcher
'iou_thresh': 0.5,
# loss weight
'loss_obj_weight': 1.0,
'loss_cls_weight': 1.0,
'loss_box_weight': 5.0,
# training configuration
'trainer_type': 'yolov2',
}
def build_model_config():
print('==============================')
cfg = yolov2_cfg
print('Model: yolov2')
return cfg