def create_train_gen(): """ this generates the training data in order, for postprocessing. Do not use this for actual training. """ data_gen_train = ra.realtime_fixed_augmented_data_gen(train_indices, 'train', ds_transforms=ds_transforms, chunk_size=CHUNK_SIZE, target_sizes=input_sizes) return load_data.buffered_gen_mp(data_gen_train, buffer_size=GEN_BUFFER_SIZE)
def create_train_gen(): """ this generates the training data in order, for postprocessing. Do not use this for actual training. """ data_gen_train = ra.realtime_fixed_augmented_data_gen(train_indices, 'train', ds_transforms=ds_transforms, chunk_size=CHUNK_SIZE, target_sizes=input_sizes) return load_data.buffered_gen_mp(data_gen_train, buffer_size=GEN_BUFFER_SIZE)
def create_valid_gen(): data_gen_valid = ra.realtime_fixed_augmented_data_gen( valid_indices, 'train', ds_transforms=ds_transforms, chunk_size=N_VALID, target_sizes=input_sizes) return data_gen_valid
def create_valid_gen(): data_gen_valid = ra.realtime_fixed_augmented_data_gen( valid_indices, 'train', ds_transforms=ds_transforms, chunk_size=N_TRAIN, target_sizes=input_sizes) return data_gen_valid #load_data.buffered_gen_mp(data_gen_valid, buffer_size=GEN_BUFFER_SIZE)
def create_test_gen(): data_gen_test = ra.realtime_fixed_augmented_data_gen( test_indices, 'test', ds_transforms=ds_transforms, chunk_size=CHUNK_SIZE, target_sizes=input_sizes) return load_data.buffered_gen_mp(data_gen_test, buffer_size=GEN_BUFFER_SIZE)
def create_test_gen(): data_gen_test = ra.realtime_fixed_augmented_data_gen( test_indices, "test", ds_transforms=ds_transforms, chunk_size=CHUNK_SIZE, target_sizes=input_sizes, processor_class=ra.LoadAndProcessFixedPysexGen1CenteringRescaling, ) return load_data.buffered_gen_mp(data_gen_test, buffer_size=GEN_BUFFER_SIZE)
def create_test_gen(): data_gen_test = ra.realtime_fixed_augmented_data_gen( test_indices, 'test', ds_transforms=ds_transforms, chunk_size=CHUNK_SIZE, target_sizes=input_sizes, processor_class=ra.LoadAndProcessFixedPysexGen1CenteringRescaling) return load_data.buffered_gen_mp(data_gen_test, buffer_size=GEN_BUFFER_SIZE)
def create_train_gen(): """ this generates the training data in order, for postprocessing. Do not use this for actual training. """ data_gen_train = ra.realtime_fixed_augmented_data_gen( train_indices, "train", ds_transforms=ds_transforms, chunk_size=CHUNK_SIZE, target_sizes=input_sizes, processor_class=ra.LoadAndProcessFixedPysexGen1CenteringRescaling, ) return load_data.buffered_gen_mp(data_gen_train, buffer_size=GEN_BUFFER_SIZE)
augmentation_transforms = [] for zoom in [1 / 1.2, 1.0, 1.2]: for angle in np.linspace(0, 360, 10, endpoint=False): augmentation_transforms.append( ra.build_augmentation_transform(rotation=angle, zoom=zoom)) augmentation_transforms.append( ra.build_augmentation_transform(rotation=(angle + 180), zoom=zoom, shear=180)) # flipped print(" %d augmentation transforms." % len(augmentation_transforms)) augmented_data_gen_valid = ra.realtime_fixed_augmented_data_gen( valid_indices, 'train', augmentation_transforms=augmentation_transforms, chunk_size=CHUNK_SIZE, target_sizes=input_sizes, ds_transforms=ds_transforms, processor_class=ra.LoadAndProcessFixedPysexGen1CenteringRescaling) valid_gen = load_data.buffered_gen_mp(augmented_data_gen_valid, buffer_size=1) augmented_data_gen_test = ra.realtime_fixed_augmented_data_gen( test_indices, 'test', augmentation_transforms=augmentation_transforms, chunk_size=CHUNK_SIZE, target_sizes=input_sizes, ds_transforms=ds_transforms, processor_class=ra.LoadAndProcessFixedPysexGen1CenteringRescaling) test_gen = load_data.buffered_gen_mp(augmented_data_gen_test, buffer_size=1)
augmentation_transforms = [] for zoom in [1 / 1.2, 1.0, 1.2]: for angle in np.linspace(0, 360, 10, endpoint=False): augmentation_transforms.append( ra.build_augmentation_transform(rotation=angle, zoom=zoom)) augmentation_transforms.append( ra.build_augmentation_transform(rotation=(angle + 180), zoom=zoom, shear=180)) # flipped print " %d augmentation transforms." % len(augmentation_transforms) augmented_data_gen_valid = ra.realtime_fixed_augmented_data_gen( valid_indices, 'train', augmentation_transforms=augmentation_transforms, chunk_size=CHUNK_SIZE, target_sizes=input_sizes, ds_transforms=ds_transforms) valid_gen = load_data.buffered_gen_mp(augmented_data_gen_valid, buffer_size=1) augmented_data_gen_test = ra.realtime_fixed_augmented_data_gen( test_indices, 'test', augmentation_transforms=augmentation_transforms, chunk_size=CHUNK_SIZE, target_sizes=input_sizes, ds_transforms=ds_transforms) test_gen = load_data.buffered_gen_mp(augmented_data_gen_test, buffer_size=1) approx_num_chunks_valid = int(
print "Load model parameters" layers.set_param_values(l6, analysis['param_values']) print "Create generators" # set here which transforms to use to make predictions augmentation_transforms = [] for zoom in [1 / 1.2, 1.0, 1.2]: for angle in np.linspace(0, 360, 10, endpoint=False): augmentation_transforms.append(ra.build_augmentation_transform(rotation=angle, zoom=zoom)) augmentation_transforms.append(ra.build_augmentation_transform(rotation=(angle + 180), zoom=zoom, shear=180)) # flipped print " %d augmentation transforms." % len(augmentation_transforms) augmented_data_gen_valid = ra.realtime_fixed_augmented_data_gen(valid_indices, 'train', augmentation_transforms=augmentation_transforms, chunk_size=CHUNK_SIZE, target_sizes=input_sizes, ds_transforms=ds_transforms) valid_gen = load_data.buffered_gen_mp(augmented_data_gen_valid, buffer_size=1) augmented_data_gen_test = ra.realtime_fixed_augmented_data_gen(test_indices, 'test', augmentation_transforms=augmentation_transforms, chunk_size=CHUNK_SIZE, target_sizes=input_sizes, ds_transforms=ds_transforms) test_gen = load_data.buffered_gen_mp(augmented_data_gen_test, buffer_size=1) approx_num_chunks_valid = int(np.ceil(num_valid * len(augmentation_transforms) / float(CHUNK_SIZE))) approx_num_chunks_test = int(np.ceil(num_test * len(augmentation_transforms) / float(CHUNK_SIZE))) print "Approximately %d chunks for the validation set" % approx_num_chunks_valid print "Approximately %d chunks for the test set" % approx_num_chunks_test if DO_VALID:
def create_test_gen(): data_gen_test = ra.realtime_fixed_augmented_data_gen(test_indices, 'test', ds_transforms=ds_transforms, chunk_size=CHUNK_SIZE, target_sizes=input_sizes) return load_data.buffered_gen_mp(data_gen_test, buffer_size=GEN_BUFFER_SIZE)
def create_valid_gen(): data_gen_valid = ra.realtime_fixed_augmented_data_gen( valid_indices, "train", ds_transforms=ds_transforms, chunk_size=CHUNK_SIZE, target_sizes=input_sizes ) return load_data.buffered_gen_mp(data_gen_valid, buffer_size=GEN_BUFFER_SIZE)
def create_valid_gen(): data_gen_valid = ra.realtime_fixed_augmented_data_gen(valid_indices, 'train', ds_transforms=ds_transforms, chunk_size=CHUNK_SIZE, target_sizes=input_sizes, processor_class=ra.LoadAndProcessFixedPysexCenteringRescaling) return load_data.buffered_gen_mp(data_gen_valid, buffer_size=GEN_BUFFER_SIZE)
print "Load model parameters" layers.set_param_values(l6, analysis['param_values']) print "Create generators" # set here which transforms to use to make predictions augmentation_transforms = [] for zoom in [1 / 1.2, 1.0, 1.2]: for angle in np.linspace(0, 360, 10, endpoint=False): augmentation_transforms.append(ra.build_augmentation_transform(rotation=angle, zoom=zoom)) augmentation_transforms.append(ra.build_augmentation_transform(rotation=(angle + 180), zoom=zoom, shear=180)) # flipped print " %d augmentation transforms." % len(augmentation_transforms) augmented_data_gen_valid = ra.realtime_fixed_augmented_data_gen(valid_indices, 'train', augmentation_transforms=augmentation_transforms, chunk_size=CHUNK_SIZE, target_sizes=input_sizes, ds_transforms=ds_transforms, processor_class=ra.LoadAndProcessFixedPysexGen1CenteringRescaling) valid_gen = load_data.buffered_gen_mp(augmented_data_gen_valid, buffer_size=1) augmented_data_gen_test = ra.realtime_fixed_augmented_data_gen(test_indices, 'test', augmentation_transforms=augmentation_transforms, chunk_size=CHUNK_SIZE, target_sizes=input_sizes, ds_transforms=ds_transforms, processor_class=ra.LoadAndProcessFixedPysexGen1CenteringRescaling) test_gen = load_data.buffered_gen_mp(augmented_data_gen_test, buffer_size=1) approx_num_chunks_valid = int(np.ceil(num_valid * len(augmentation_transforms) / float(CHUNK_SIZE))) approx_num_chunks_test = int(np.ceil(num_test * len(augmentation_transforms) / float(CHUNK_SIZE))) print "Approximately %d chunks for the validation set" % approx_num_chunks_valid print "Approximately %d chunks for the test set" % approx_num_chunks_test if DO_VALID: