/
config_GAICD.py
131 lines (113 loc) · 4.42 KB
/
config_GAICD.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
import os
class Config:
data_root = '/workspace/aesthetic_cropping/human_centric/dataset/'
# the pre-defined candidate crops are downloaded from:
# https://github.com/luwr1022/listwise-view-ranking/blob/master/pdefined_anchors.pkl
predefined_pkl = os.path.join(data_root, 'pdefined_anchors.pkl')
CPC_path = os.path.join(data_root, 'CPCDataset')
CPC_image = os.path.join(CPC_path, 'images')
CPC_anno = os.path.join(CPC_path, 'image_crop.json')
CPC_human = os.path.join(CPC_path, 'human_bboxes.json')
FCDB_path = os.path.join(data_root, 'FCDB')
FCDB_image= os.path.join(FCDB_path, 'data')
FCDB_anno = os.path.join(FCDB_path, 'image_crop.json')
FCDB_human= os.path.join(FCDB_path, 'human_bboxes.json')
FCDB_split= os.path.join(FCDB_path, 'data_split.json')
FLMS_path = os.path.join(data_root, 'FLMS')
FLMS_image= os.path.join(FLMS_path, 'image')
FLMS_anno = os.path.join(FLMS_path, 'image_crop.json')
FLMS_human= os.path.join(FLMS_path, 'human_bboxes.json')
GAIC_path = os.path.join(data_root, 'GAICD')
GAIC_image= os.path.join(GAIC_path, 'images')
GAIC_anno = os.path.join(GAIC_path, 'image_crop.json')
GAIC_human= os.path.join(GAIC_path, 'human_bboxes.json')
GAIC_split= os.path.join(GAIC_path, 'original_data_split.json')
GAIC_human_split = os.path.join(GAIC_path, 'human_data_split.json')
heat_map_dir = '/workspace/aesthetic_cropping/human_centric/code/heat_map/heat_map_gt'
CPC_heat_map = os.path.join(heat_map_dir, 'CPC', 'mask')
GAIC_heat_map= os.path.join(heat_map_dir, 'GAICD', 'mask')
heat_map_size = 1./4
image_size = (256,256)
backbone = 'vgg16'
backbone_weight_path = ('/workspace/pretrained_models/{}.pth'.format(backbone))
# training
training_set = 'GAICD' # ['GAICD', 'CPC']
loss_type = ['L1Loss','RankLoss']
gpu_id = 0
num_workers = 4
only_human = False
data_augmentation = True
keep_aspect_ratio = True
use_partition_aware = True
partition_aware_type = 9 # [0,1,2,9]
concat_with_human = True
visualize_partition_feature = False
use_content_preserve = True
only_content_preserve = False
content_preserve_type = 'gcn'
content_loss_weight = 1.
visualize_heat_map = False
use_rod_feature = True
reduced_dim = 32
batch_size = 1
lr_scheduler= 'cosine'
max_epoch = 80
lr_decay_epoch = [max_epoch + 1]
eval_freq = 1
view_per_image = 64
lr = 1e-4
lr_decay = 0.1
weight_decay = 1e-4
save_freq = max_epoch+1
if only_human:
display_freq = 20
else:
display_freq = 50
visualize_freq = 50
prefix = training_set
if only_human:
prefix += '-Human'
if not data_augmentation:
prefix += '_wodataaug'
if reduced_dim != 32:
prefix += f'_{reduced_dim}redim'
if loss_type != ['L1Loss','RankLoss']:
if isinstance(loss_type, list) and len(loss_type) > 1:
for i in range(len(loss_type)):
if loss_type[i] == 'L1Loss':
continue
prefix += f'_{loss_type[i]}'
if use_partition_aware:
prefix += ('_PA')
if partition_aware_type != 9:
prefix += f'-{partition_aware_type}part'
if use_content_preserve:
prefix += ('_CP')
if content_preserve_type != 'gcn':
prefix += f'-{content_preserve_type}'
if only_content_preserve:
prefix += f'_onlycontent'
exp_root = os.path.join(os.getcwd(), './experiments')
# prefix = f'{content_loss_weight}_content_loss'
# exp_root = os.path.join(os.getcwd(), './experiments/hyper_parameter')
exp_name = prefix
exp_path = os.path.join(exp_root, prefix)
while os.path.exists(exp_path):
index = os.path.basename(exp_path).split(prefix)[-1].split('repeat')[-1]
try:
index = int(index) + 1
except:
index = 1
exp_name = prefix + ('_repeat{}'.format(index))
exp_path = os.path.join(exp_root, exp_name)
# print('Experiment name {} \n'.format(os.path.basename(exp_path)))
checkpoint_dir = os.path.join(exp_path, 'checkpoints')
log_dir = os.path.join(exp_path, 'logs')
def create_path(self):
print('Create experiment directory: ', self.exp_path)
os.makedirs(self.exp_path)
os.makedirs(self.checkpoint_dir)
os.makedirs(self.log_dir)
cfg = Config()
if __name__ == '__main__':
cfg = Config()