Ejemplo n.º 1
0
        batch_size=args.batch_size)


def TrainData():
    return images_train, labels_train


pre_transform_images, labels = tf.case({
    tf.equal(data2use, 'stats'): StatsData,
    tf.equal(data2use, 'train'): TrainData,
    tf.equal(data2use, 'val'): ValData
})

# Applying our transformations on the images (and handling their corresponding labels as well):
# Transformations should be applied on the raw images, before applying any standartization, whitening etc'.
transformer = Transformations.Transformer(transformations=TRANSFORMATIONS_LIST)
images, labels = transformer.TransformImages_TF_OP(pre_transform_images,
                                                   labels)

# The example classifer was trained on standartized images, so applying standartization AFTER the transformations were applied:
post_processed_images = tf.map_fn(
    lambda im: tf.image.per_image_standardization(im), images)

train_batches_per_epoch = int(
    np.ceil(num_of_samples * args.train_portion / args.batch_size))
val_batches_per_epoch = int(
    np.ceil(num_of_samples * (1 - args.train_portion) / args.batch_size))

# Example classifier model:
classifier = cifar10.inference(post_processed_images)
logits = classifier.inference_logits()