-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathconfig.py
95 lines (79 loc) · 2.68 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
AUs = [1, 2, 4, 6, 7, 10, 12, 14, 15, 17, 23, 24]
AUs_name_en = [
'Inner Brow Raiser\n',
'Outer Brow Raiser\n',
'Brow Lowerer\n',
'Cheek Raiser\n',
'Lid Tightener\n',
'Upper Lip Raiser\n',
'Lip Corner Puller\n',
'Dimpler\n',
'Lip Corner Depressor\n',
'Chin Raiser\n',
'Lip Tightener\n',
'Lip Pressor\n',
]
AUs_name_es = [
'Ceja Interior Levantada\n',
'Ceja Exterior Levantada\n',
'Cejas fruncidas\n',
'Mejillas levantadas\n',
'Parpados apretados\n',
'Labio Superior Levantado\n',
'Esquina Labial Estirada\n',
'Hoyuelo Facial\n',
'Esquina Labial hacia abajo\n',
'Barbilla levantada\n',
'Labios mordidos\n',
'Labios apretados\n',
]
TXT_PATH = '/home/afromero/datos2/AUNets/data'
def update_folder(config, folder):
import os
config.log_path = os.path.join(config.log_path, folder)
config.model_save_path = os.path.join(config.model_save_path, folder)
def remove_folder(config):
import os
logs = config.log_path
models = config.model_save_path
print("YOU ARE ABOUT TO REMOVE EVERYTHING IN:\n{}\n{}".format(
logs, models))
print("YOU ARE ABOUT TO REMOVE EVERYTHING IN:\n{}\n{}".format(
logs, models))
input("ARE YOU SURE?")
os.system("rm -r {} {}".format(logs, models))
def update_config(config):
import os
import glob
if config.SHOW_MODEL:
config.batch_size = 1
config.OF_option = config.OF
if config.OF != 'None':
config.OF = True
else:
config.OF = False
folder_parameters = os.path.join(config.dataset, config.mode_data,
'fold_' + config.fold,
'AU' + str(config.AU).zfill(2))
update_folder(config, folder_parameters)
config.metadata_path = os.path.join(config.metadata_path,
folder_parameters)
if config.HYDRA:
update_folder(config, 'HYDRA')
update_folder(config, 'OF_' + config.OF_option)
update_folder(config, config.finetuning)
if config.DELETE:
remove_folder(config)
config.xlsfile = os.path.join(config.results_path, config.mode_data,
config.finetuning + '.xlsx')
if config.pretrained_model == '':
try:
config.pretrained_model = sorted(
glob.glob(os.path.join(config.model_save_path, '*.pth')))[-1]
config.pretrained_model = os.path.basename(
config.pretrained_model).split('.')[0]
except BaseException:
pass
if not os.path.exists(os.path.dirname(config.xlsfile)):
os.makedirs(os.path.dirname(config.xlsfile))
return config