-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
61 lines (52 loc) · 2.08 KB
/
run.py
File metadata and controls
61 lines (52 loc) · 2.08 KB
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
# -*- coding: utf-8 -*-
'''`
Code for the following paper:
https://www.sciencedirect.com/science/article/abs/pii/S1361841524001993?dgcid
@article{han2026ps_seg,
author = {Meng Han and Xiaochuan Ma and Xiangde Luo and Wenjun Liao and Shichuan Zhang and Shaoting Zhang and Guotai Wang},
title = {{PS-seg: Learning from partial scribbles for 3D multiple abdominal organ segmentation}},
year = {2026},
url = {https://doi.org/10.1016/j.neucom.2026.132837},
journal = {Neurocomputing},
volume = {672},
pages = {132837},
}
'''
from __future__ import print_function, division
import argparse
import logging
import os
import sys
from networks import TDNet_3D
from pymic.util.parse_config import *
from pymic.net_run.weak_sup import WSLPSSEG
def main():
if(len(sys.argv) < 2):
print('Number of arguments should be at least 3. e.g.')
print(' python run.py train config.cfg')
exit()
parser = argparse.ArgumentParser()
parser.add_argument("stage", type = str, help="stage of train or test")
parser.add_argument("cfg", type = str, help="configuration file")
args = parser.parse_args()
if(not os.path.isfile(args.cfg)):
raise ValueError("The config file does not exist: " + args.cfg)
config = parse_config(args)
config = synchronize_config(config)
log_dir = config['training']['ckpt_dir']
if(not os.path.exists(log_dir)):
os.makedirs(log_dir)
if sys.version.startswith("3.9"):
logging.basicConfig(filename=log_dir+"/log_{0:}.txt".format(args.stage), level=logging.INFO,
format='%(message)s', force=True) # for python 3.9
else:
logging.basicConfig(filename=log_dir+"/log_{0:}.txt".format(args.stage), level=logging.INFO,
format='%(message)s') # for python 3.6
logging.getLogger().addHandler(logging.StreamHandler(sys.stdout))
logging_config(config)
agent = WSLPSSEG(config, args.stage)
net_dict = {"TDNet_3D": TDNet_3D}
agent.set_net_dict(net_dict)
agent.run()
if __name__ == "__main__":
main()