Skip to content

Commit

Permalink
Augmentation, titan script
Browse files Browse the repository at this point in the history
  • Loading branch information
gzuidhof committed Jun 3, 2016
1 parent 07db29e commit 4d12087
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 14 deletions.
12 changes: 10 additions & 2 deletions config/default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,20 @@ batch_size_train: 1
batch_size_validation: 2
n_epochs: 200

[preprocessing]
erode_segmentation: 3

[normalization]
zero_center: True
mean_pixel: 0.66200809792889126

[preprocessing]
erode_segmentation: 3
[augmentation]
augment: True
flip: True
zoom: 0.08 ;Not working yet
rotation: 16
translation: 3


[misc]
multiprocess_load_augmentation: False
Expand Down
2 changes: 1 addition & 1 deletion config/small_subset.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[dataset]
subset: 100
subset: 2
12 changes: 12 additions & 0 deletions config/titan_x_default.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[info]
experiment: U-net large batch size (14), 0.00005 LR

[updates]
learning_rate: 0.00005
momentum: 0.94
batch_size_train: 14
batch_size_validation: 28

[misc]
multiprocess_load_augmentation: True
save_every_n_epoch: 3
11 changes: 3 additions & 8 deletions src/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import cPickle as pickle
import loss_weighting
import skimage.morphology
from augment import augment

from params import params as P

Expand All @@ -19,14 +20,8 @@ def get_image(filename):
with gzip.open(filename.replace('lung','nodule'),'rb') as f:
truth = pickle.load(f)

#Random flips
#if np.random.randint(2)==0:
# lung = lung.transpose(1,0)
# truth = truth.transpose(1,0)
# lung[:,:] = lung[::-1,:]
# truth[:,:] = truth[::-1,:]
# lung = lung.transpose(1,0)
# truth = truth.transpose(1,0)
if P.AUGMENT:
lung, truth = augment([lung,truth])

#We do not care about the outside
outside = np.where(lung==0,True,False)
Expand Down
3 changes: 1 addition & 2 deletions src/learn.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
initialize_logger(os.path.join(model_folder, 'log.txt').format(model_name))

P.write_to_file(os.path.join(model_folder, 'config.ini'))
logging.info("MODEL NAME {}".format(model_name))
logging.info(P.to_string())


Expand Down Expand Up @@ -139,7 +138,7 @@

# Then we print the results for this epoch:
logging.info("Epoch {} of {} took {:.3f}s".format(
epoch + 1, num_epochs, time.time() - start_time))
epoch + 1, P.N_EPOCHS, time.time() - start_time))

for name, train_metric, val_metric in zip(metric_names, train_metrics, val_metrics):
name = name.rjust(10," ") #Pad the name until 10 characters long
Expand Down
12 changes: 11 additions & 1 deletion src/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def __init__(self, config_file_path):
cf = ConfigParser()
read_from = cf.read(config_file_path)

print "Loaded configuration from (in order)", read_from
print "Loaded configurations from (in order)", read_from

self.CONFIG = cf
cf.set('info','config_file', config_file_path)
Expand Down Expand Up @@ -54,6 +54,16 @@ def __init__(self, config_file_path):
self.ZERO_CENTER = cf.getboolean('normalization', 'zero_center')
self.MEAN_PIXEL = cf.getfloat('normalization', 'mean_pixel')


# Augmentation
self.AUGMENT = cf.getboolean('augmentation', 'augment')
self.AUGMENTATION_PARAMS = {
'flip': cf.getboolean('augmentation', 'flip'),
'zoom_range': (1.-cf.getfloat('augmentation', 'zoom'),1.+cf.getfloat('augmentation', 'zoom')),
'rotation_range': (-cf.getfloat('augmentation', 'rotation'),cf.getfloat('augmentation', 'rotation')),
'translation_range': (-cf.getfloat('augmentation', 'translation'),cf.getfloat('augmentation', 'translation'))
}

# Misc
self.MULTIPROCESS_LOAD_AUGMENTATION = cf.getboolean('misc', 'multiprocess_load_augmentation')
self.SAVE_EVERY_N_EPOCH = cf.getint('misc', 'save_every_n_epoch')
Expand Down

0 comments on commit 4d12087

Please sign in to comment.