Exemple #1
0
    def __init__(self, image_set, data_path, mc):
        imdb.__init__(self, 'kitti_' + image_set, mc)
        self._image_set = image_set
        self._data_root_path = data_path

        self._image_path = os.path.join(self._data_root_path, 'training',
                                        'image_2')
        self._label_path = os.path.join(self._data_root_path, 'training',
                                        'label_2')
        self._classes = self.mc.CLASS_NAMES
        self._class_to_idx = dict(zip(self.classes, range(self.num_classes)))

        # a list of string indices of images in the directory
        self._image_idx = self._load_image_set_idx()
        # a dict of image_idx -> [[cx, cy, w, h, cls_idx]]. x,y,w,h are not divided by
        # the image width and height
        self._rois = self._load_kitti_annotation()

        ## batch reader ##
        self._perm_idx = None
        self._cur_idx = 0
        # TODO(bichen): add a random seed as parameter
        self._shuffle_image_idx()

        self._eval_tool = './src/dataset/kitti-eval/cpp/evaluate_object'
Exemple #2
0
    def __init__(self, image_set, data_path, mc):
        imdb.__init__(self, 'vid_' + image_set, mc)
        self._image_set = image_set
        self._data_root_path = data_path
        self._data_path = os.path.join(data_path, 'Data/VID', image_set)
        self._idx_path = os.path.join(data_path, 'ImageSets/VID')
        self._anno_path = os.path.join(data_path, 'Annotations/VID', image_set)
        self._classes = self.mc.CLASS_NAMES
        self._raw_cnames = ('n02691156', 'n02419796', 'n02131653', 'n02834778',
                            'n01503061', 'n02924116', 'n02958343', 'n02402425',
                            'n02084071', 'n02121808', 'n02503517', 'n02118333',
                            'n02510455', 'n02342885', 'n02374451', 'n02129165',
                            'n01674464', 'n02484322', 'n03790512', 'n02324045',
                            'n02509815', 'n02411705', 'n01726692', 'n02355227',
                            'n02129604', 'n04468005', 'n01662784', 'n04530566',
                            'n02062744', 'n02391049')
        self._class_to_idx = dict(zip(self.classes, xrange(self.num_classes)))
        self._raw_cname_to_idx = dict(
            zip(self._raw_cnames, xrange(len(self._raw_cnames))))

        # a list of string indices of images in the directory
        self._image_idx = self._load_image_set_idx()
        # a dict of image_idx -> [[cx, cy, w, h, cls_idx]]. x,y,w,h are not divided by
        # the image width and height
        self._rois = self._load_vid_annotation()

        ## batch reader ##
        self._perm_idx = None
        self._cur_idx = 0
        # TODO(bichen): add a random seed as parameter
        self._shuffle_image_idx()
Exemple #3
0
    def __init__(self, image_set, data_argument=True):
        '''Initialize the class.

        Args:
            image_set: mark the property of data, value is 'train' or 'test'.    
        '''
        imdb.__init__(self, 'kitti_' + image_set)
        self._image_set = image_set
        self._data_path = os.path.join(cfg.DATA_DIR, image_set)
        self._classes = ['Car', 'Pedestrian', 'Cyclist']
        self._dont_care = [
            'DontCare', 'Misc', 'Person_sitting', 'Truck', 'Tram'
        ]
        self._class_to_ind = dict(
            zip(self._classes, xrange(len(self._classes))))
        self._image_names, self._boxes, self._obj_num = self.read_annotations()
        self._shuffle_inds()

        # data_argument: if True, then apply data argument
        # screen: if True, means the data has been preprocessed, then
        #            the bounding boxes info are [cls_index, xc, yc, w, h], and have been
        #            normalized
        # image_ext: 'jpg' or 'png'
        self.config = {
            'data_argument': data_argument,
            'screen': True,
            'image_ext': '.png'
        }
    def __init__(self, image_set, year=2007, data_argument=True):
        '''Initialize the class
        By default: Using 2007 dataset

        Args:
            image_set: mark the property of data, value is 'train' or 'test'
        '''
        imdb.__init__(self, 'voc_' + year + '_' + image_set)
        self._image_set = image_set
        self._classes = ('aeroplane', 'bicycle', 'bird', 'boat', 'bottle',
                         'bus', 'car', 'cat', 'chair', 'cow', 'diningtable',
                         'dog', 'horse', 'motorbike', 'person', 'pottdplant',
                         'sheep', 'sofa', 'train', 'tvmonitor')
        self._class_to_ind = dict(
            zip(self._classes, xrange(len(self._classes))))
        self._data_path = os.path.join(cfg.DATA_DIR, 'VOCdevkit' + year,
                                       'VOC' + year)
        # image name (without ext)
        self._image_index = self._load_image_set_index()
        self._image_names, self._boxes, self._obj_num = self.read_annotations()
        self._shuffle_inds()

        # data_argument: if True, then implement data argument
        # image_ext: 'jpg' or 'png'
        self.config = {'data_argument': data_argument, 'image_ext': '.jpg'}
Exemple #5
0
    def __init__(self, image_set, data_path, mc):
        imdb.__init__(self, 'ILSVRC2013_' + image_set, mc)
        self._image_set = image_set
        self._data_path = data_path
        self._classes = self.mc.CLASS_NAMES
        #self._class_to_idx = dict(zip(self.classes, range(self.num_classes)))

        # a list of string indices of images in the directory
        self._image_idx = self._load_image_set_idx()

        # a list of class labels
        self.labels = self._load_imagenet_labels()

        ## batch reader ##
        self._perm_idx = None
        self._cur_idx = 0
        self._shuffle_image_idx()
Exemple #6
0
    def __init__(self,
                 image_set='train',
                 data_path='/home/bryant/MATLAB-tools/caltech/',
                 mc=None):
        imdb.__init__(self, 'caltech_' + image_set, mc)
        self._image_set = image_set
        self._data_root_path = data_path
        self._image_path = os.path.join(self._data_root_path, 'raw_image/')
        self._label_path = os.path.join(self._data_root_path,
                                        'raw_annotations/')
        if image_set == 'test':
            self._image_set_num = [
                'set06/', 'set07/', 'set08/', 'set09/', 'set10/'
            ]
            self._image_set_stride = 30  # sample 1 frame every 4 frames from _image_set
        elif image_set == 'valdation':
            self._image_set_num = ['set05/']
            self._image_set_stride = 30  # sample 1 frame every 4 frames from _image_set
        elif image_set == 'train':
            self._image_set_num = [
                'set00/', 'set01/', 'set02/', 'set03/', 'set04/', 'set05/'
            ]
            self._image_set_stride = 3  # sample 1 frame every 4 frames from _image_set
        self._classes = self.mc.CLASS_NAMES
        self._class_to_idx = dict(zip(self.classes, xrange(self.num_classes)))

        # a list of string indices of images in the directory
        self._image_idx = self._load_image_set_idx()
        # a dict of image_idx -> [[cx, cy, w, h, cls_idx]]. x,y,w,h are not divided by
        # the image width and height
        if image_set == 'train':
            self._rois = self.gt_roidb()
            if mc.DATA_AUGMENTATION:
                self._append_flip_rois()
        ## batch reader ##
        self._perm_idx = None
        self._cur_idx = 0
        # TODO(bichen): add a random seed as parameter
        if image_set == 'train':
            self._shuffle_image_idx()

        self._eval_tool = None  # './src/dataset/kitti-eval/cpp/evaluate_object'
  def __init__(self, image_set, year, data_path, mc):
    imdb.__init__(self, 'voc_'+year+'_'+image_set, mc)
    self._year = year
    self._image_set = image_set
    self._data_root_path = data_path
    self._data_path = os.path.join(self._data_root_path, 'VOC' + self._year)
    self._classes = self.mc.CLASS_NAMES
    self._class_to_idx = dict(zip(self.classes, range(self.num_classes)))

    # a list of string indices of images in the directory
    self._image_idx = self._load_image_set_idx()
    # a dict of image_idx -> [[cx, cy, w, h, cls_idx]]. x,y,w,h are not divided by
    # the image width and height
    self._rois = self._load_pascal_annotation()

    ## batch reader ##
    self._perm_idx = None
    self._cur_idx = 0
    # TODO(bichen): add a random seed as parameter
    self._shuffle_image_idx()
Exemple #8
0
 def __init__(self, name, mc):
     imdb.__init__(self, name, mc)
     self.left_margin = 0
     self.right_margin = 0
     self.top_margin = 0
     self.bottom_margin = 0
Exemple #9
0
    def __init__(self, image_set, data_path, mc):

        imdb.__init__(self, 'bosch' + image_set, mc)

        self._image_set = image_set  # train, test or trainval

        self._data_root_path = data_path

        #self._image_path = os.path.join(self._data_root_path, 'training', 'image_2')
        #self._label_path = os.path.join(self._data_root_path, 'training', 'label_2')

        self._classes = self.mc.CLASS_NAMES
        self._class_to_idx = dict(zip(self.classes, range(self.num_classes)))

        self._input_yaml = image_set + ".yaml"
        self._bosch_data = yaml.load(
            open(os.path.join(data_path, self._input_yaml), 'rb').read())

        #image_dict= bosch_data[0]  # bosch_data content image dictionary 'boxes' and 'path'
        # a list of string indices of images in the directory
        self._image_idx = []
        self._image_path = []

        # a dict of image_idx -> [[cx, cy, w, h, cls_idx]]. x,y,w,h are not divided by
        # the image width and height
        # '006303': [[75.735, 243.735, 151.47, 127.01000000000002, 0], [111.485, 238.64499999999998, 222.97, 114.95000000000002, 0], [237.58, 216.33999999999997, 116.94, 64.84, 0], [303.685, 210.755, 151.11, 58.44999999999999, 0], [434.94, 197.68, 52.72000000000003, 37.78, 0], ]
        self._rois = {}

        idx_counter = 0
        for imgdict in self._bosch_data:
            image_path = os.path.join(data_path, imgdict['path'])

            roi = {}
            bboxes = []
            for box in imgdict['boxes']:
                w = box["x_max"] - box["x_min"]
                h = box["y_max"] - box["y_min"]
                if w < 0:
                    print("Warning negative value of width %f, %s" %
                          (w, imgdict['path']))
                    w = abs(w)
                if h < 0:
                    print("Warning negative value of height %f, %s" %
                          (h, imgdict['path']))
                    h = abs(h)
                cx = box["x_min"] + w / 2
                cy = box["y_min"] + h / 2
                class_idx = 3
                if "Red" in box['label']:
                    class_idx = 0
                elif 'Yellow' in box['label']:
                    class_idx = 1
                elif 'Green' in box['label']:
                    class_idx = 2
                bboxes.append([cx, cy, w, h, class_idx])

            self._image_idx.append(idx_counter)

            self._rois[idx_counter] = bboxes
            self._image_path.append(image_path)

            idx_counter = idx_counter + 1

        ## batch reader ##
        self._perm_idx = None
        self._cur_idx = 0
        self._shuffle_image_idx()