Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aaa5776

Browse files
committed
udate coplenet_run.py
1 parent 486a546 commit aaa5776

File tree

3 files changed

+32
-19
lines changed

3 files changed

+32
-19
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Based on this project, we have also released a dataset named as `UESTC-COVID-19
1515

1616
# Requirements
1717
* [Pytorch][torch_link] version >=1.0.1.
18-
* [PyMIC][pymic_link], a Pytorch-based toolkit for medical image computing. Install it by `pip install PYMIC`.
18+
* [PyMIC][pymic_link], a Pytorch-based toolkit for medical image computing. Version 0.2 is required. Install it by `pip install PYMIC==0.2`.
1919
* Some basic python packages such as Numpy, Pandas, SimpleITK.
2020

2121
[data_link]:http://faculty.uestc.edu.cn/HiLab/en/article/379152/list/index.htm
@@ -31,7 +31,7 @@ COPLE-Net has also been implemented in [MONAI][monai_link], a PyTorch-based, ope
3131

3232
# How to use
3333
1. Download the pretrained model and example CT images from [Google Drive][google_link] or [Baidu Netdisk][baidu_link] (extract code q0ci). Put them into the folder `coplenet_data`.
34-
2. Run `python net_run.py config/config.cfg`. The results will be saved in `coplenet_data/result`.
34+
2. Run `python coplenet_run.py test config/config.cfg`. The results will be saved in `coplenet_data/result`.
3535
3. To segment COVID-19 pneumonia lesions from your own images, make sure that the images have been cropped into the lung region, and the intensity has been normalized into [0, 1] using window width/level of 1500/-650. Open the configure file `config/config.cfg` and edit `root_dir`, `test_csv` and `output_dir` according to the path of your images. Then return to step 2 to obtain the segmentation results.
3636

3737
[google_link]:https://drive.google.com/drive/folders/1K1jbrxWWhG_L7dh6yMyB4DtklBr-bhxH?usp=sharing

config/config.cfg

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,22 @@ Pad_output_size = [1, 32, 32]
1919
Pad_ceil_mode = True
2020
Pad_inverse = True
2121

22+
[network]
23+
# this section gives parameters for network
24+
25+
# type of network
26+
net_type = COPLENet
27+
28+
# number of class, required for segmentation task
29+
class_num = 2
30+
in_chns = 1
31+
bilinear = True
32+
feature_chns = [32, 64, 128, 256, 512]
33+
dropout = [0.0, 0.0, 0.3, 0.4, 0.5]
34+
2235
[testing]
2336
# device name" cuda:n or cpu
24-
device_name = cuda:1
37+
device_name = cuda:0
2538

2639
checkpoint_name = coplenet_data/coplenet_pretrain.pt
2740
output_dir = coplenet_data/result

net_run.py renamed to coplenet_run.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,29 @@
99
from __future__ import print_function, division
1010
import sys
1111
import torch
12-
from coplenet import COPLENet
13-
from pymic.net_run.net_run import TrainInferAgent
1412
from pymic.util.parse_config import parse_config
13+
from pymic.net_run.net_run_agent import NetRunAgent
14+
from pymic.net.net_dict import NetDict
15+
from coplenet import COPLENet
16+
17+
my_net_dict = NetDict
18+
my_net_dict['COPLENet'] = COPLENet
1519

1620
def main():
17-
if(len(sys.argv) < 2):
18-
print('Number of arguments should be 2. e.g.')
19-
print(' python net_run.py config.cfg')
21+
if(len(sys.argv) < 3):
22+
print('Number of arguments should be 3. e.g.')
23+
print(' python train_infer.py train config.cfg')
2024
exit()
2125
cfg_file = str(sys.argv[1])
2226
config = parse_config(cfg_file)
2327

24-
# parameters of COPLENet
25-
net_param = {"class_num" : 2,
26-
"in_chns" : 1,
27-
"bilinear" : True,
28-
"feature_chns": [32, 64, 128, 256, 512],
29-
"dropout" : [0.0, 0.0, 0.3, 0.4, 0.5]}
30-
config['network'] = net_param
31-
32-
net = COPLENet(net_param)
33-
agent = TrainInferAgent(config, 'test')
34-
agent.set_network(net)
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 = NetRunAgent(config, stage)
34+
agent.set_network_dict(my_net_dict)
3535
agent.run()
3636

3737
if __name__ == "__main__":

0 commit comments

Comments
 (0)