# Path: lib/datasets/factory.py
# def get_imdb(name):
#     """Get an imdb (image database) by name."""
#     if not __sets.has_key(name):
#         print (list_imdbs())
#         raise KeyError('Unknown dataset: {}'.format(name))
#     return __sets[name]()


from lib.datasets.factory import get_imdb
import numpy as np
import tensorflow as tf
import cv2
import random
import cfg

class DataFetcher:
    def __init__(self, imdb_name, resize=True):
        imdb = get_imdb(imdb_name)
        # Ignore the background class!!! So ['gt_classes'] must minus 1.
        self.classes = [ np.zeros(imdb.num_classes - 1) for i in range(imdb.num_images) ]
        for i, anno in enumerate(imdb.gt_roidb()):
            np.put(self.classes[i], map(lambda x: x-1, anno['gt_classes']), 1)
            # np.put(self.classes[i], random.choice(map(lambda x: x-1, anno['gt_classes'])), 1)
        self.images = [ imdb.image_path_at(i) for i in range(imdb.num_images) ]
        assert len(self.classes) == len(self.images)

        self._perm = np.random.permutation(np.arange(len(self.images)))
        self._cur = 0
        self.resize = resize

    def nextbatch(self, batch_size=1):
        # if all images have been trained, permuate again.
        blobs = {'data':[], 'path':[], 'classes':[], 'keep_prob':[], 'im_info':[]}
        for batch in range(batch_size):

# Path: lib/datasets/factory.py
# def get_imdb(name):
#     """Get an imdb (image database) by name."""
#     if not __sets.has_key(name):
#         print (list_imdbs())
#         raise KeyError('Unknown dataset: {}'.format(name))
#     return __sets[name]()


# Path: deepSimGAN/util.py
from lib.datasets.factory import get_imdb
import numpy as np
import tensorflow as tf
import cv2
import random
import cfg


class DataFetcher:
    def __init__(self, imdb_name, resize=True):
        imdb = get_imdb(imdb_name)
        # Ignore the background class!!! So ['gt_classes'] must minus 1.
        self.classes = [ np.zeros(imdb.num_classes - 1) for i in range(imdb.num_images) ]
        for i, anno in enumerate(imdb.gt_roidb()):
            np.put(self.classes[i], map(lambda x: x-1, anno['gt_classes']), 1)
            # np.put(self.classes[i], random.choice(map(lambda x: x-1, anno['gt_classes'])), 1)
        self.images = [ imdb.image_path_at(i) for i in range(imdb.num_images) ]
        assert len(self.classes) == len(self.images)

        self._perm = np.random.permutation(np.arange(len(self.images)))
        self._cur = 0
        self.resize = resize

    def nextbatch(self, batch_size=1):
        # if all images have been trained, permuate again.
        blobs = {'data':[], 'path':[], 'classes':[], 'keep_prob':[], 'im_info':[]}
        for batch in range(batch_size):

            if self._cur >= len(self.images):