# Path: data/helper/record.py
# class Record(object):
#     """Record object holding an example of a dataset."""
# 
#     def __init__(self, data, shape, label):
#         """Creates a record representing an example of a dataset.
# 
#         Args:
#             data: A [height, width, depth] float32 tensor with the data of the
#               record.
#             shape: A TensorShape representing the shape of the data.
#             label: An int64 tensor with the label of the record.
#         """
# 
#         self._data = data
#         self._data.set_shape(shape)
# 
#         self._shape = shape
# 
#         self._label = label
#         self._label.set_shape([1])
# 
#     @property
#     def data(self):
#         """A [height, width, depth] float32 tensor with the data of the record.
#         """
#         return self._data
# 
#     @property
#     def shape(self):
#         """The shape of the data."""
#         return self._shape
# 
#     @property
#     def label(self):
#         """An int64 tensor with the label of the record."""
#         return self._label


import tensorflow as tf
from .record import Record
CROP_RATIO = 0.75


def distort_image_for_train(record):
    """Applies random distortions for training to the image of a record.

    Args:
        record: The record.

    Returns:
        A new record object after applying distortions.
    """

    image = record.data
    crop_shape = _crop_shape(record.shape)

    with tf.name_scope('distort_image_for_train', values=[image, crop_shape]):

        # Randomly crop a [height, width] section of the image.
        image = tf.random_crop(image, crop_shape)

        # Randomly flip the image horizontally.
        image = tf.image.random_flip_left_right(image)

        # Randomly adjust the saturation and the contrast of the image.
        image = tf.cast(image, tf.uint8)
        image = tf.image.random_saturation(image, lower=0.8, upper=1.0)
        image = tf.image.random_contrast(image, lower=0.8, upper=1.0)
        image = tf.cast(image, tf.float32)


# Path: data/helper/record.py
# class Record(object):
#     """Record object holding an example of a dataset."""
# 
#     def __init__(self, data, shape, label):
#         """Creates a record representing an example of a dataset.
# 
#         Args:
#             data: A [height, width, depth] float32 tensor with the data of the
#               record.
#             shape: A TensorShape representing the shape of the data.
#             label: An int64 tensor with the label of the record.
#         """
# 
#         self._data = data
#         self._data.set_shape(shape)
# 
#         self._shape = shape
# 
#         self._label = label
#         self._label.set_shape([1])
# 
#     @property
#     def data(self):
#         """A [height, width, depth] float32 tensor with the data of the record.
#         """
#         return self._data
# 
#     @property
#     def shape(self):
#         """The shape of the data."""
#         return self._shape
# 
#     @property
#     def label(self):
#         """An int64 tensor with the label of the record."""
#         return self._label


# Path: data/helper/distort_image.py
import tensorflow as tf
from .record import Record

CROP_RATIO = 0.75


def distort_image_for_train(record):
    """Applies random distortions for training to the image of a record.

    Args:
        record: The record.

    Returns:
        A new record object after applying distortions.
    """

    image = record.data
    crop_shape = _crop_shape(record.shape)

    with tf.name_scope('distort_image_for_train', values=[image, crop_shape]):

        # Randomly crop a [height, width] section of the image.
        image = tf.random_crop(image, crop_shape)

        # Randomly flip the image horizontally.
        image = tf.image.random_flip_left_right(image)

        # Randomly adjust the saturation and the contrast of the image.
        image = tf.cast(image, tf.uint8)
        image = tf.image.random_saturation(image, lower=0.8, upper=1.0)
        image = tf.image.random_contrast(image, lower=0.8, upper=1.0)
        image = tf.cast(image, tf.float32)


    return Record(image, crop_shape, record.label)