...
 
Commits (5)
#!/usr/bin/env python3
import sys
print('Importing libraries...')
from pathlib import Path
from vesseg import Model, Job
from vesseg.network.model import DSA, T1, T1_GAD
learning_dir = Path('~/mres_project/learning').expanduser()
combinations = (
(DSA,),
(DSA, T1),
(DSA, T1_GAD),
(DSA, T1, T1_GAD),
)
learning_rates = 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5
networks = 222, 223, 233
applications = 'Vessels', 'Vessels_Reuben'
for application in applications:
for net in networks:
for inputs in combinations:
for lr in learning_rates:
models_dir = learning_dir / application / f'highres3dnet_{net}'
network = f'vesseg_networks.highres3dnet_{net}.HighRes3DNet{net}'
application = (
'vesseg_applications'
f'.segmentation_application_{application.lower()}'
f'.SegmentationApplication{application.replace("_", "")}'
)
string = '-'.join(inputs)
model_name = f'highres3dnet_{net}_{string}_lr_{lr}'
print(f'Creating {model_name}...')
model_dir = models_dir / model_name
model = Model(model_dir=model_dir, inputs=inputs)
model.set_images_and_labels_paths()
model.make_csv_files(split_type='subject')
model.config_all()
model.config_training(learning_rate=lr)
model.config_network(network_name=network)
model.write_config_file()
job = Job(model_dir, model.config_path)
job.application = application
job.write()
if len(sys.argv) > 1 and sys.argv[1] == '--submit':
print(f'Submitting {model_name}...')
job.submit()
...@@ -15,6 +15,7 @@ class Job: ...@@ -15,6 +15,7 @@ class Job:
self.config_path = config_path self.config_path = config_path
self.train = True self.train = True
self.infer = True self.infer = True
self.application = 'vesseg_applications.segmentation_application_vessels.SegmentationApplicationVessels'
def write(self, old_cluster=False): def write(self, old_cluster=False):
...@@ -80,7 +81,7 @@ class Job: ...@@ -80,7 +81,7 @@ class Job:
a(' /share/apps/python-3.6.3-shared/bin/python3) \\') a(' /share/apps/python-3.6.3-shared/bin/python3) \\')
a(f' -u net_segment.py {action} \\') a(f' -u net_segment.py {action} \\')
a(f' -c "{self.config_path}" \\') a(f' -c "{self.config_path}" \\')
a(f' -a vesseg_applications.segmentation_application_vessels.SegmentationApplicationVessels') a(f' -a {self.application}')
a('') a('')
if old_cluster: if old_cluster:
a('fi') a('fi')
......
...@@ -453,7 +453,7 @@ class SegmentationApplicationVessels(BaseApplication): ...@@ -453,7 +453,7 @@ class SegmentationApplicationVessels(BaseApplication):
# classification probabilities or argmax classification labels # classification probabilities or argmax classification labels
data_dict = switch_sampler(for_training=False) data_dict = switch_sampler(for_training=False)
image = tf.cast(data_dict['image'], tf.float32) image = tf.cast(data_dict['image'], tf.float32)
net_args = {'is_training': True, # self.is_training, (Reuben modif) net_args = {'is_training': self.is_training, # True # (Reuben modif)
'keep_prob': self.net_param.keep_prob} 'keep_prob': self.net_param.keep_prob}
net_out = self.net(image, **net_args) net_out = self.net(image, **net_args)
......
...@@ -55,7 +55,8 @@ SEGMENTATION_NIFTYNET = '.'.join([ ...@@ -55,7 +55,8 @@ SEGMENTATION_NIFTYNET = '.'.join([
'segmentation_application', 'segmentation_application',
'SegmentationApplication' 'SegmentationApplication'
]) ])
SEGMENTATION_APP = 'segmentation_application_mine.SegmentationApplicationMine'
SEGMENTATION_APP = 'vesseg_applications.segmentation_application_vessels.SegmentationApplicationVessels'
# Random seed # Random seed
...@@ -80,9 +81,9 @@ VOXEL_SPACING = 0.466 # most DSAs ...@@ -80,9 +81,9 @@ VOXEL_SPACING = 0.466 # most DSAs
NEAREST_NEIGHBOR = 0 NEAREST_NEIGHBOR = 0
LINEAR = 1 # true? LINEAR = 1 # true?
X_INTERPOLATION = 3 X_INTERPOLATION = 3
TRAINING_IMAGE_WINDOW_SIZE = 64 TRAINING_IMAGE_WINDOW_SIZE = 96
TRAINING_LABEL_WINDOW_SIZE = TRAINING_IMAGE_WINDOW_SIZE TRAINING_LABEL_WINDOW_SIZE = TRAINING_IMAGE_WINDOW_SIZE
INFERENCE_WINDOW_SIZE = 64 INFERENCE_WINDOW_SIZE = 96
# System # System
NUM_THREADS = 2 NUM_THREADS = 2
...@@ -90,14 +91,14 @@ NUM_THREADS = 2 ...@@ -90,14 +91,14 @@ NUM_THREADS = 2
# Network # Network
# NETWORK_NAME = UNET_SMALL # NETWORK_NAME = UNET_SMALL
NETWORK_NAME = HIGHRES3DNET_SMALLER NETWORK_NAME = HIGHRES3DNET_SMALLER
BATCH_SIZE = 1 BATCH_SIZE = 4
WINDOW_SAMPLING = 'weighted' WINDOW_SAMPLING = 'weighted'
VOLUME_PADDING_SIZE = TRAINING_IMAGE_WINDOW_SIZE // 2 VOLUME_PADDING_SIZE = TRAINING_IMAGE_WINDOW_SIZE // 2
# Training # Training
MAX_NUM_ITERATIONS = 10000 MAX_NUM_ITERATIONS = 10000
SAVE_EVERY_N = MAX_NUM_ITERATIONS // 10 SAVE_EVERY_N = MAX_NUM_ITERATIONS // 10
LEARNING_RATE = 1e-3 LEARNING_RATE = 1e-1
TENSORBOARD_EVERY_N = 1 TENSORBOARD_EVERY_N = 1
VALIDATION_EVERY_N = 5 VALIDATION_EVERY_N = 5
LATEST_CHECKPOINT = -1 LATEST_CHECKPOINT = -1
...@@ -183,6 +184,8 @@ class Model: ...@@ -183,6 +184,8 @@ class Model:
self.config = ConfigParser() self.config = ConfigParser()
self.application = SEGMENTATION_APP
def __repr__(self): def __repr__(self):
return self.name return self.name
......