# Path: datasets/Dataset.py
# class AbstractDataset(ABC):
# class FileListDataset(AbstractDataset):
#   def __init__(self, config, subset, num_classes):
#   def n_examples_per_epoch(self):
#   def create_input_tensors_dict(self, batch_size):
#   def num_classes(self):
#   def load_example(self, input_filenames):
#   def process_raw_example(self, example):
#   def load_raw_example(self, img_filename, label_filename=None, *args):
#   def load_image(self, img_filename):
#   def load_annotation(self, img, img_filename, annotation_filename):
#   def postproc_annotation(self, ann_filename, ann):
#   def resize_example(self, tensors):
#   def jointly_resize_examples(self, tensors_batch):
#   def augment_example_before_resize(self, tensors):
#   def augment_example_after_resize(self, tensors):
#   def jointly_augment_examples_before_resize(self, tensors_batch):
#   def jointly_augment_examples_after_resize(self, tensors_batch):
#   def postproc_example_initial(self, tensors):
#   def postproc_example_before_assembly(self, tensors):
#   def postproc_example_before_resize(self, tensors):
#   def assemble_example(self, tensors):
#   def create_summaries(self, data):
#   def __init__(self, config, dataset_name, subset, default_path, num_classes):
#   def _load_inputfile_lists(self):
#   def n_examples_per_epoch(self):
#   def create_input_tensors_dict(self, batch_size):
#     def _load_example(*input_filenames):
#     def _filter_example(tensors):
#   def _batch(self, tfdata, batch_size):
#   def get_extraction_keys(self):
#   def read_inputfile_lists(self):


from abc import abstractmethod
from datasets.Dataset import AbstractDataset, DataKeys
import tensorflow as tf



class FeedDataset(AbstractDataset):
  def __init__(self, config, subset, data_keys_to_use, num_classes=2):
    super().__init__(config, subset, num_classes)
    self._data_keys_to_use = data_keys_to_use

    self._batch_size = -1
    if subset == "val":
      self._batch_size = config.int("batch_size_val", -1)
      if self._batch_size == -1:
        self._batch_size = config.int("batch_size_eval", -1)
    if self._batch_size == -1:
      self._batch_size = config.int("batch_size")

    self._placeholders = self._create_placeholders()

  def get_batch_size(self):
    return self._batch_size

  def _create_placeholders(self):
    dtypes_and_shapes = {
      DataKeys.IMAGES: (tf.float32, (None, None, 3)),
      DataKeys.SEGMENTATION_LABELS: (tf.uint8, (None, None, 1)),
      DataKeys.BBOX_GUIDANCE: (tf.uint8, (None, None, 1)),
      DataKeys.IMAGE_FILENAMES: (tf.string, ()),

# Path: datasets/Dataset.py
# class AbstractDataset(ABC):
# class FileListDataset(AbstractDataset):
#   def __init__(self, config, subset, num_classes):
#   def n_examples_per_epoch(self):
#   def create_input_tensors_dict(self, batch_size):
#   def num_classes(self):
#   def load_example(self, input_filenames):
#   def process_raw_example(self, example):
#   def load_raw_example(self, img_filename, label_filename=None, *args):
#   def load_image(self, img_filename):
#   def load_annotation(self, img, img_filename, annotation_filename):
#   def postproc_annotation(self, ann_filename, ann):
#   def resize_example(self, tensors):
#   def jointly_resize_examples(self, tensors_batch):
#   def augment_example_before_resize(self, tensors):
#   def augment_example_after_resize(self, tensors):
#   def jointly_augment_examples_before_resize(self, tensors_batch):
#   def jointly_augment_examples_after_resize(self, tensors_batch):
#   def postproc_example_initial(self, tensors):
#   def postproc_example_before_assembly(self, tensors):
#   def postproc_example_before_resize(self, tensors):
#   def assemble_example(self, tensors):
#   def create_summaries(self, data):
#   def __init__(self, config, dataset_name, subset, default_path, num_classes):
#   def _load_inputfile_lists(self):
#   def n_examples_per_epoch(self):
#   def create_input_tensors_dict(self, batch_size):
#     def _load_example(*input_filenames):
#     def _filter_example(tensors):
#   def _batch(self, tfdata, batch_size):
#   def get_extraction_keys(self):
#   def read_inputfile_lists(self):


# Path: datasets/FeedDataset.py
from abc import abstractmethod
from datasets.Dataset import AbstractDataset, DataKeys
import tensorflow as tf




class FeedDataset(AbstractDataset):
  def __init__(self, config, subset, data_keys_to_use, num_classes=2):
    super().__init__(config, subset, num_classes)
    self._data_keys_to_use = data_keys_to_use

    self._batch_size = -1
    if subset == "val":
      self._batch_size = config.int("batch_size_val", -1)
      if self._batch_size == -1:
        self._batch_size = config.int("batch_size_eval", -1)
    if self._batch_size == -1:
      self._batch_size = config.int("batch_size")

    self._placeholders = self._create_placeholders()

  def get_batch_size(self):
    return self._batch_size

  def _create_placeholders(self):
    dtypes_and_shapes = {
      DataKeys.IMAGES: (tf.float32, (None, None, 3)),
      DataKeys.SEGMENTATION_LABELS: (tf.uint8, (None, None, 1)),
      DataKeys.BBOX_GUIDANCE: (tf.uint8, (None, None, 1)),
      DataKeys.IMAGE_FILENAMES: (tf.string, ()),

      DataKeys.OBJ_TAGS: (tf.string, ()),