-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_cortex.py
122 lines (93 loc) · 4.38 KB
/
config_cortex.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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# This scripts houses some usual config and constants used in the network
import os
import shutil
import numpy as np
os.environ["CUDA_VISIBLE_DEVICES"]="2"
class Setup_Directories(object):
def __init__(self):
## Directories and training image generation
# Root directory that house the image
self.root_dir = "/home/sadhana-ravikumar/Documents/Sadhana/exvivo_cortex_unet"
# Directory that contain CNN related files
self.code = "/home/sadhana-ravikumar/Documents/Sadhana/exvivo_cortex_segmentation"
# csv file that store train/test split
self.train_val_csv = self.root_dir + "/data_csv/split.csv"
# self.final_test_csv = self.root_dir + "/data_csv/split_test.csv"
#self.final_test_csv = "/home/sadhana-ravikumar/Documents/Sadhana/n4bias_dots/dots_csv.csv"
#self.final_test_csv = self.root_dir + "/data_csv/test_pulkit.csv"
# Patch directories
self.patch_dir = self.root_dir + "/patch_data"
self.train_patch_csv = self.root_dir + "/data_csv/train_patch.csv"
self.val_patch_csv = self.root_dir + "/data_csv/val_patch.csv"
# Directories that contain the model
self.model_dir = self.root_dir + "/model"
# Directories that contain the tensorboard output
self.tfboard_dir = self.root_dir + "/tfboard"
# Directories that store the validation output
self.valout_dir = self.root_dir + "/validation_output"
# Directories that store the validation output
self.test_dir = self.root_dir + "/mtl_pulkit"
#self.test_dir = "/home/sadhana-ravikumar/Documents/Sadhana/n4bias_dots/initial_test_set/cortex_segmentation"
def force_create(self, folder):
if os.path.exists(folder) and os.path.isdir(folder):
shutil.rmtree(folder)
os.makedirs(folder)
class Config_DistanceMapUnet(Setup_Directories):
def __init__(self):
# Set base init
super().__init__()
# Number image per tfrecord in train and test set
# self.nTrainPerTfrecord = 10
# self.nTestPerTfrecord = 10
# Training patch params
self.num_pos = 250
self.num_neg = 0 #30 # try switching number of pos and neg
self.aug = 50
self.num_thread = 8
# Multi resolution patch size and spacing setting
self.patchsize_multi_res = [(1, (48, 48, 48))]
self.segsize = (96,96,96)
self.test_patch_size = (96,96,96)
self.half_patch = np.ceil((np.array(self.segsize) - 1) / 2).astype(np.int32)
self.test_patch_spacing = (32,32,32) #was 16 and 32 for 96 (for 96 input, must be less than 56 output)
self.patch_crop_size = 4
## Learning parameters
self.batch_size = 3 #15 for training. Make it 10 for testing
self.shuffle_buffer = 100
self.learning_rate = 1e-4#1e-2?
self.step_size = 10
self.weight_decay = 0.0005
## Training parameters
self.num_epochs = 15
# Visualization params
self.num_image_to_show = 2
# num batch for validation
self.batch_validation = 1
class Config_BaselineUnet(Setup_Directories):
def __init__(self):
# Set base init
super().__init__()
# Training patch params
self.num_pos = 250
self.num_neg = 0 #30 # try switching number of pos and neg
self.aug = 50
self.num_thread = 8
# Multi resolution patch size and spacing setting
self.patchsize_multi_res = [(1, (48, 48, 48))]
self.segsize = (96,96,96)
self.test_patch_size = (96,96,96)
self.half_patch = np.ceil((np.array(self.segsize) - 1) / 2).astype(np.int32)
self.test_patch_spacing = (32,32,32) #was 16 and 32 for 96 (for 96 input, must be less than 56 output)
self.patch_crop_size = 4
## Learning parameters
self.batch_size = 4
self.shuffle_buffer = 100
self.learning_rate = 1e-4
self.step_size = 10
self.weight_decay = 0.0005
## Training parameters
self.num_epochs =65
# Visualization params
self.num_image_to_show = 3
# num batch for validation
self.batch_validation = 1