-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
167 lines (155 loc) · 3.42 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
class Map(dict):
"""
A custom dictionary class that allows accessing dictionary keys as attributes.
"""
def __init__(self, *args, **kwargs):
super(Map, self).__init__(*args, **kwargs)
for arg in args:
if isinstance(arg, dict):
for k, v in arg.items():
self[k] = v
if kwargs:
for k, v in kwargs.items():
self[k] = v
def __getattr__(self, attr):
return self.get(attr)
def __setattr__(self, key, value):
self.__setitem__(key, value)
def __setitem__(self, key, value):
super(Map, self).__setitem__(key, value)
self.__dict__.update({key: value})
def __delattr__(self, item):
self.__delitem__(item)
def __delitem__(self, key):
super(Map, self).__delitem__(key)
del self.__dict__[key]
'''
Config for augmentation object detection
'''
# Configuration settings for various data augmentation techniques
config_augmentation = {
'AdjustBrightneess': {
'used': True,
'brightness_factor': 1.5,
},
'AdjustContrast': {
'used': True,
'contrast_factor': 1.5,
},
'AdjustSaturation': {
'used': True,
'saturation_factor': 1.5,
},
'Cutout': {
'used': True,
'amount': .3,
},
'Filters': {
'used': True
},
'GridMask': {
'used': True,
'use_h': True,
'use_w': True,
'rotate': 1,
'offset': False,
'ratio': .5,
'mode': 0,
'prob': .7
},
'RandomHorizontalFlip': {
'used': True,
'p': 1
},
'HorizontalFlip':{
'used': True
},
'RandomHSV': {
'used': True,
'hue':100,
'saturation':100,
'brightness': 100
},
'LightingNoise':{
'used': True,
},
'Mixup':{
'used': True,
'lambd': .3,
},
'Noisy':{
'used': True,
'noise_type': "gauss",
},
'Resize':{
'used': True,
'inp_dim': 512,
},
'RotateOnlyBboxes':{
'used': True,
'angle': 5.,
},
'RandomRotate':{
'used': True,
'angle': 5.,
},
'Rotate':{
'used': True,
'angle': 5,
},
'RandomScale': {
'used': True,
'scale': 0.5,
'diff': True
},
'Scale': {
'used': True,
'scale_x': 0.5,
'scale_y': True
},
'Sequence': {
'used': True
},
'RandomShear': {
'used': True,
'shear_factor': 0.5
},
'Shear': {
'used': True,
'shear_factor': 0.5
},
'SmallObjectAugmentation': {
'used': True,
},
'RandomTranslate': {
'used': True,
'translate': 0.2,
'diff': True
},
'Translate': {
'used': True,
'translate': 0.2,
'diff': True
},
}
# Convert the augmentation configuration to a Map object
config_augmentation = Map(config_augmentation)
'''
Config for generation data
'''
# Configuration settings for generating data
config_data = {
'path_data_raw': './assets/yolo',
'path_save': './dataset',
'label_mapping': {
'dog': 0,
'car': 1,
'bike': 2,
},
'train_scale': 0.7,
'val_scale': 0.2,
'src_type_dataset': 'yolo',
'dest_type_dataset': 'voc',
}
# Convert the data generation configuration to a Map object
config_data = Map(config_data)