-
Notifications
You must be signed in to change notification settings - Fork 16
/
coplenet_run.py
45 lines (37 loc) · 1.38 KB
/
coplenet_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
37
38
39
40
41
42
43
44
# -*- coding: utf-8 -*-
# Author: Guotai Wang
# Date: 12 June, 2020
# Implementation of of COPLENet for COVID-19 pneumonia lesion segmentation from CT images.
# Reference:
# G. Wang et al. A Noise-robust Framework for Automatic Segmentation of COVID-19 Pneumonia Lesions
# from CT Images. IEEE Transactions on Medical Imaging, 2020. DOI:10.1109/TMI.2020.3000314.
from __future__ import print_function, division
import sys
import torch
from pymic.util.parse_config import parse_config
from pymic.net_run.agent_seg import SegmentationAgent
from pymic.net.net_dict_seg import SegNetDict
from coplenet import COPLENet
net_dict = SegNetDict
net_dict['COPLENet'] = COPLENet
def main():
if(len(sys.argv) < 3):
print('Number of arguments should be 3. e.g.')
print(' python coplenet_run.py test config.cfg')
exit()
cfg_file = str(sys.argv[1])
config = parse_config(cfg_file)
stage = str(sys.argv[1])
cfg_file = str(sys.argv[2])
config = parse_config(cfg_file)
# use custormized CNN and loss function
agent = SegmentationAgent(config, stage)
net_name = config['network']['net_type']
if(net_name in net_dict):
net = net_dict[net_name](config['network'])
agent.set_network(net)
agent.run()
else:
raise ValueError("undefined network {0:}".format(net_name))
if __name__ == "__main__":
main()