# Path: external/inception_preprocessing.py
# def apply_with_random_selector(x, func, num_cases):
# def distort_color(image, color_ordering=0, fast_mode=True, scope=None):
# def distorted_bounding_box_crop(image,
#                                 bbox,
#                                 min_object_covered=0.1,
#                                 aspect_ratio_range=(0.75, 1.33),
#                                 area_range=(0.05, 1.0),
#                                 max_attempts=100,
#                                 scope=None):
# def preprocess_for_train(image, height, width, bbox,
#                          fast_mode=True,
#                          scope=None):
# def preprocess_for_eval(image, height, width,
#                         central_fraction=0.875, scope=None):
# def preprocess_image(image, height, width,
#                      is_training=False,
#                      bbox=None,
#                      fast_mode=True):
# 
# Path: external/datasets_imagenet.py
# _FILE_PATTERN = '%s-*'
# _SPLITS_TO_SIZES = {
#     'train': 1281167,
#     'validation': 50000,
# }
# _ITEMS_TO_DESCRIPTIONS = {
#     'image': 'A color image of varying height and width.',
#     'label': 'The label id of the image, integer between 0 and 999',
#     'label_text': 'The text of the label.',
#     'object/bbox': 'A list of bounding boxes.',
#     'object/label': 'A list of labels, one per each object.',
# }
# _NUM_CLASSES = 1001
# def create_readable_names_for_imagenet_labels():
# def get_split(split_name, dataset_dir, file_pattern=None, reader=None):


import os
import tensorflow as tf
from tensorflow.contrib import slim
from tensorflow.contrib.slim import dataset_data_provider
from external import inception_preprocessing
from external import datasets_imagenet
  Applies the processing in external/inception_preprocessing
  to the TF-Slim ImageNet dataset class.

  Args:
    split_name: Either 'train' or 'validation'.
    batch_size: The number of images in each batch.
    dataset_dir: Directory where the ImageNet TFRecord files live.
                 Defaults to "~/tensorflow/data/imagenet"
    is_training: Whether to apply data augmentation and shuffling.
    num_readers: Number of parallel readers. Always set to one for evaluation.
    num_preprocessing_threads: Number of preprocessing threads.

  Returns:
    images: A `Tensor` of size [batch_size, image_size, image_size, 3]
    one_hot_labels: A `Tensor` of size [batch_size, num_classes], where
      each row has a single element set to one and the rest set to zeros.
    dataset.num_samples: The number of total samples in the dataset.
    dataset.num_classes: The number of object classes in the dataset.

  Raises:
    ValueError: if the split_name is not either 'train' or 'validation'.
  """

  with tf.device('/cpu:0'):
    if dataset_dir is None:
      dataset_dir = os.path.expanduser('~/tensorflow/data/imagenet')

    if not is_training:
      num_readers = 1


# Path: external/inception_preprocessing.py
# def apply_with_random_selector(x, func, num_cases):
# def distort_color(image, color_ordering=0, fast_mode=True, scope=None):
# def distorted_bounding_box_crop(image,
#                                 bbox,
#                                 min_object_covered=0.1,
#                                 aspect_ratio_range=(0.75, 1.33),
#                                 area_range=(0.05, 1.0),
#                                 max_attempts=100,
#                                 scope=None):
# def preprocess_for_train(image, height, width, bbox,
#                          fast_mode=True,
#                          scope=None):
# def preprocess_for_eval(image, height, width,
#                         central_fraction=0.875, scope=None):
# def preprocess_image(image, height, width,
#                      is_training=False,
#                      bbox=None,
#                      fast_mode=True):
# 
# Path: external/datasets_imagenet.py
# _FILE_PATTERN = '%s-*'
# _SPLITS_TO_SIZES = {
#     'train': 1281167,
#     'validation': 50000,
# }
# _ITEMS_TO_DESCRIPTIONS = {
#     'image': 'A color image of varying height and width.',
#     'label': 'The label id of the image, integer between 0 and 999',
#     'label_text': 'The text of the label.',
#     'object/bbox': 'A list of bounding boxes.',
#     'object/label': 'A list of labels, one per each object.',
# }
# _NUM_CLASSES = 1001
# def create_readable_names_for_imagenet_labels():
# def get_split(split_name, dataset_dir, file_pattern=None, reader=None):


# Path: imagenet_data_provider.py
import os
import tensorflow as tf
from tensorflow.contrib import slim
from tensorflow.contrib.slim import dataset_data_provider
from external import inception_preprocessing
from external import datasets_imagenet

  Applies the processing in external/inception_preprocessing
  to the TF-Slim ImageNet dataset class.

  Args:
    split_name: Either 'train' or 'validation'.
    batch_size: The number of images in each batch.
    dataset_dir: Directory where the ImageNet TFRecord files live.
                 Defaults to "~/tensorflow/data/imagenet"
    is_training: Whether to apply data augmentation and shuffling.
    num_readers: Number of parallel readers. Always set to one for evaluation.
    num_preprocessing_threads: Number of preprocessing threads.

  Returns:
    images: A `Tensor` of size [batch_size, image_size, image_size, 3]
    one_hot_labels: A `Tensor` of size [batch_size, num_classes], where
      each row has a single element set to one and the rest set to zeros.
    dataset.num_samples: The number of total samples in the dataset.
    dataset.num_classes: The number of object classes in the dataset.

  Raises:
    ValueError: if the split_name is not either 'train' or 'validation'.
  """

  with tf.device('/cpu:0'):
    if dataset_dir is None:
      dataset_dir = os.path.expanduser('~/tensorflow/data/imagenet')

    if not is_training:
      num_readers = 1


    dataset = datasets_imagenet.get_split(split_name, dataset_dir)