-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.py
32 lines (24 loc) · 820 Bytes
/
utils.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
import yaml
import collections
def get_config(conf):
with open(conf, 'r') as stream:
return yaml.load(stream, Loader=yaml.SafeLoader)
def print_config(conf):
print(yaml.dump(conf, default_flow_style=False, default_style=''))
def _load_weights(weights_dict):
key, value = list(weights_dict.items())[0]
trained_data_parallel = False
if key[:7] == 'module.':
trained_data_parallel = True
if trained_data_parallel is True:
new_weights = collections.OrderedDict()
for old_key in weights_dict:
new_key = old_key[7:]
new_weights[new_key] = weights_dict[old_key]
else:
new_weights = weights_dict
return new_weights
if __name__ == '__main__':
config_path = 'configs/test.yaml'
cong = get_config(config_path)
tmp=0