-
Notifications
You must be signed in to change notification settings - Fork 6
/
myops_run.py
36 lines (32 loc) · 1.28 KB
/
myops_run.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
# -*- coding: utf-8 -*-
from __future__ import print_function, division
import os
import sys
from pymic.util.parse_config import parse_config
from pymic.net_run.agent_seg import SegmentationAgent
from path_config import path_dict
def main():
if(len(sys.argv) < 4):
print('Number of arguments should be 4. e.g.')
print(' python myops_run.py train config.cfg 1')
exit()
stage = str(sys.argv[1])
cfg_file = str(sys.argv[2])
fold = str(sys.argv[3])
if(not os.path.isfile(cfg_file)):
print("configure file does not exist: {0:} ".format(cfg_file))
exit()
# reset data dir of each fold for configure
config = parse_config(cfg_file)
data_dir = config['dataset']['root_dir']
data_dir = data_dir.replace('MyoPS_data_dir', path_dict['MyoPS_data_dir'])
config['dataset']['root_dir'] = data_dir
for item in ['train_csv', 'valid_csv', 'test_csv']:
config['dataset'][item] = config['dataset'][item].replace("foldi", "fold" + fold)
ckpt_save_dir = config['training']['ckpt_save_dir']
ckpt_save_dir = ckpt_save_dir.replace("fold_i", "fold_" + fold)
config['training']['ckpt_save_dir'] = ckpt_save_dir
agent = SegmentationAgent(config, stage)
agent.run()
if __name__ == "__main__":
main()