-
Notifications
You must be signed in to change notification settings - Fork 90
/
config.py
68 lines (60 loc) · 1.74 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
# encoding: utf-8
import warnings
import numpy as np
class DefaultConfig(object):
seed = 0
# dataset options
dataset = 'market1501'
datatype = 'person'
mode = 'retrieval'
# optimization options
loss = 'triplet'
optim = 'adam'
max_epoch = 60
train_batch = 32
test_batch = 32
adjust_lr = False
lr = 0.0001
adjust_lr = False
gamma = 0.1
weight_decay = 5e-4
momentum = 0.9
random_crop = False
margin = None
num_instances = 4
num_gpu = 1
evaluate = False
savefig = None
re_ranking = False
# model options
model_name = 'bfe' # triplet, softmax_triplet, bfe, ide
last_stride = 1
pretrained_model = None
# miscs
print_freq = 30
eval_step = 50
save_dir = './pytorch-ckpt/market'
workers = 10
start_epoch = 0
best_rank = -np.inf
def _parse(self, kwargs):
for k, v in kwargs.items():
if not hasattr(self, k):
warnings.warn("Warning: opt has not attribut %s" % k)
setattr(self, k, v)
if 'cls' in self.dataset:
self.mode='class'
if 'market' in self.dataset or 'cuhk' in self.dataset or 'duke' in self.dataset:
self.datatype = 'person'
elif 'cub' in self.dataset:
self.datatype = 'cub'
elif 'car' in self.dataset:
self.datatype = 'car'
elif 'clothes' in self.dataset:
self.datatype = 'clothes'
elif 'product' in self.dataset:
self.datatype = 'product'
def _state_dict(self):
return {k: getattr(self, k) for k, _ in DefaultConfig.__dict__.items()
if not k.startswith('_')}
opt = DefaultConfig()