File size: 2,999 Bytes
8970c37
1cc0005
8970c37
 
 
 
 
1cc0005
 
 
 
 
f11f6a9
1cc0005
 
 
 
f11f6a9
1cc0005
f11f6a9
1cc0005
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8970c37
1cc0005
 
 
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Training code for Lung Tumor 3D Segmentation - Mixed Supervision

End to end code base for lung tumor segmentation from CT-scan using mixed supervision for deep convolutional neural network.

Takes 3D CT scans as input and outputs 3D segmentation of primary tumor.

Project aims to utilize multiple different datasets with different label types (classification labels, bounding boxes, rough segmentations, and fine segmentations).

## Installation

Requires python >= 3.6

Install python dependencies with pip. The requirements file is located in `/Resources/`:
```
pip install -r requirements.txt
```

Build repository files as packages using setuptools. If you alter the code, remember to run the setup again:
```
python setup.py install
```

## Usage

**Initiate Training:**  `python .\Runable\Test\test_sevlus.py`

The training is initiated from the .\Resources\Test\test_train.yaml file that looks like this:
```
device: 'cuda'

data:
  train_dataset: "D:\\Repos\\LungTumorSegmentation\\Resources\\Test\\data_test_train.yaml"
  aug_prob: 0.1
  scale_dim:
    d_0: 32
    d_1: 32
    d_2: 32

model:
  architecture: UNet_con_double
  loss: DiceLoss
  filter_base: 64
  filter_expansion: 2
  optimizer:
    name: 'Adam'
    lr: 0.001

train:
  max_epochs: 3
  val_frequency: 1
  output_threshold: 0.5
  metric_path: "D:\\Repos\\LungTumorSegmentation\\metrics.csv"
  save_frequency: 5
  model_directory: "D:\\Repos\\LungTumorSegmentation\\models\\"
  steps_per_plot: 10
```

The paths would need to be updated.

**Plot Training Metric File**: `python interface.py plot <path_to_metric_file>`

Store the plot by specifying the store location: `python interface.py plot <path_to_metric_file> -store_file <path_to_store> -steps_per_epoch <steps_per_epoch (int)>` Example: `python interface.py plot ./metrics.csv -store_file plot.png -steps_per_epoch 120`

**Evaluate Network**: `python .\Runable\Evaluate\eval.py`

Evaluates the network on specified test images with labels. The configuration file (which here is the file at .\Resources\Windows_Files\win_eval.yaml) should contain network information as well as a reference to the data to evaluate the network on.

The evaluation config should look similar to this

```
device: 'cuda'

data:
  train_dataset: "D:\\Repos\\LungTumorSegmentation\\Resources\\Windows_Files\\evaluate_data_msd.yaml"
  scale_dim:
    d_0: 128
    d_1: 128
    d_2: 128

model:
  architecture: UNet_filter
  weights: "D:\\idun_models\\1\\model_last_128.pth"
  loss: DiceLoss
  filter_base: 128
  filter_expansion: 2
  optimizer:
    name: 'Adam'
    lr: 0.01

evaluate:
  save_segmentations: True
  save_directory: 'D:\\Repos\\LungTumorSegmentation\\m_128\\'
  output_threshold: 0.5
```

In this case, the paths would also need to be updated.

## Authors
[Vemund Fredrksen](https://github.com/VemundFredriksen), [Svein Ole M. Sevle](https://github.com/sosevle), & [André Pedersen](https://github.com/andreped).

## License
[MIT](https://choosealicense.com/licenses/mit/)