Diff of /coplenet_run.py [000000] .. [5b2be7]

Switch to unified view

a b/coplenet_run.py
1
# -*- coding: utf-8 -*-
2
# Author: Guotai Wang
3
# Date:   12 June, 2020
4
# Implementation of of COPLENet for COVID-19 pneumonia lesion segmentation from CT images.
5
# Reference: 
6
#     G. Wang et al. A Noise-robust Framework for Automatic Segmentation of COVID-19 Pneumonia Lesions 
7
#     from CT Images. IEEE Transactions on Medical Imaging, 2020. DOI:10.1109/TMI.2020.3000314.
8
9
from __future__ import print_function, division
10
import sys
11
import torch
12
from pymic.util.parse_config import parse_config
13
from pymic.net_run.agent_seg import  SegmentationAgent
14
from pymic.net.net_dict_seg import SegNetDict
15
from coplenet import COPLENet
16
17
net_dict = SegNetDict
18
net_dict['COPLENet'] = COPLENet
19
20
def main():
21
    if(len(sys.argv) < 3):
22
        print('Number of arguments should be 3. e.g.')
23
        print('    python coplenet_run.py test config.cfg')
24
        exit()
25
    cfg_file = str(sys.argv[1])
26
    config   = parse_config(cfg_file)
27
28
    stage    = str(sys.argv[1])
29
    cfg_file = str(sys.argv[2])
30
    config   = parse_config(cfg_file)
31
32
    # use custormized CNN and loss function
33
    agent  = SegmentationAgent(config, stage)
34
    net_name = config['network']['net_type']
35
    if(net_name in net_dict):
36
        net = net_dict[net_name](config['network'])
37
        agent.set_network(net)
38
        agent.run()
39
    else:
40
        raise ValueError("undefined network {0:}".format(net_name))
41
42
if __name__ == "__main__":
43
    main()
44
    
45