-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfig.py
69 lines (56 loc) · 2.58 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
from io import TextIOWrapper
class Config(object):
def __init__(self):
self.backbone = 'ResNet50-CLIP-VLPD'
# ResNet50-Concat (+self.score_map=False): Pytorch Implmentation of CSP
# ResNet50-CLIP (+self.score_map=False): CLIP-initializaed CSP (CLIP+CSP)
# ResNet50-CLIP (+self.score_map=True): CLIP+CSP+VLS
# ResNet50-CLIP-VLPD (+sef.score_map=True): our proposed VLPD (CLIP+CSP+VLS+PSC)
self.seed = 1337
self.gen_seed = False
# training config
self.onegpu = 4
self.num_epochs = 300
self.add_epoch = 0
self.iter_per_epoch = 2000
self.init_lr = 2e-4
self.lr_policy = 'step' # or cyclic for SWA
self.lr_step = [350] # no step
self.warm_up = 3
self.alpha = 0.999
# dataset
self.root_path = '/root/data/cityperson' # the path to your citypersons dataset
# setting for data augmentation
self.use_horizontal_flips = True
self.brightness = (0.5, 2, 0.5)
self.size_train = (640, 1280)
self.size_test = (1024, 2048)
# image channel-wise mean to subtract, the order is BGR
self.norm_mean = [123.675, 116.28, 103.53]
self.norm_std = [58.395, 57.12, 57.375]
self.log_freq = 20
# whether or not to perform validation during training
self.val = True
self.val_frequency = 2
self.val_begin = 70
self.save_begin = 200
self.save_end = 260
self.score_map = True
# whether ot not to use the strategy of weight moving average following CSP
self.teacher = True
self.templates = ['a picture of {}']
self.classnames = ['ground', 'building', 'tree', 'human', 'car', 'bus', 'bicycle', 'truck', 'traffic sign', 'sky']
self.clip_weight = '/root/RN50.pt'
self.seg_lambda = 1e2
self.contrast_lambda = 1e-3
self.point = 'center' # or 'top', 'bottom
self.scale = 'h' # or 'w', 'hw'
self.num_scale = 1 # 1 for height (or width) prediction, 2 for height+width prediction
self.offset = True # append offset prediction or not
self.down = 4 # downsampling rate of the feature map for detection
self.radius = 2 # surrounding areas of positives for the scale map
def print_conf(self):
print('\n'.join(['%s:%s' % item for item in self.__dict__.items()]))
def write_conf(self, log: TextIOWrapper):
log.write('\n'.join(['%s:%s' % item for item in self.__dict__.items()])+'\n')
log.flush()