lib/datasets/imagenetVID.py
def _load_imagenet_annotation(self, index):
        """
        Load image and bounding boxes info from txt files of imagenet.
        """
        # filename = os.path.join(self._data_path, 'Annotations', self._image_set, index + '.xml')
        filename = index.replace('Data', 'Annotations').replace('.JPEG', '') + '.xml'

        assert os.path.exists(filename), '%s' % (filename)

        # print 'Loading: {}'.format(filename)
        def get_data_from_tag(node, tag):
            return node.getElementsByTagName(tag)[0].childNodes[0].data

        with open(filename) as f:
            data = minidom.parseString(f.read())

        objs = data.getElementsByTagName('object')
        num_objs = len(objs)
        # filter the objects not in video synsets.
        # print('before:',num_objs)
        used_objs = []
        for id, obj in enumerate(objs):
            if str(get_data_from_tag(obj, "name")).lower().strip() in self._wnid_to_ind:
                used_objs.append(obj)
        objs = used_objs
        num_objs = len(objs)
        # print('after:', num_objs)
        ##########################################

        boxes = np.zeros((num_objs, 4), dtype=np.uint16)
        gt_classes = np.zeros((num_objs), dtype=np.int32)
        overlaps = np.zeros((num_objs, self.num_classes), dtype=np.float32)
        trackid = np.zeros((num_objs), dtype=np.int32)

        # Load object bounding boxes into a data frame.
        for ix, obj in enumerate(objs):
            x1 = float(get_data_from_tag(obj, 'xmin'))
            y1 = float(get_data_from_tag(obj, 'ymin'))
            x2 = float(get_data_from_tag(obj, 'xmax'))
            y2 = float(get_data_from_tag(obj, 'ymax'))
            cls = self._wnid_to_ind[
                str(get_data_from_tag(obj, "name")).lower().strip()]
            boxes[ix, :] = [x1, y1, x2, y2]
            gt_classes[ix] = cls
            overlaps[ix, cls] = 1.0
            trackid[ix] = int(get_data_from_tag(obj, 'trackid'))

        overlaps = scipy.sparse.csr_matrix(overlaps)

        return {'boxes': boxes,
                'gt_classes': gt_classes,
                'gt_overlaps': overlaps,
                'trackid': trackid,
                'flipped': False}

        Load image and bounding boxes info from txt files of imagenet.
        
Load image and bounding boxes info from txt files of imagenet.
Load image and bounding boxes info from txt files of imagenet .
def _load_imagenet_annotation(self, index):
        filename = index.replace('Data', 'Annotations').replace('.JPEG', '') + '.xml'
        assert os.path.exists(filename), '%s' % (filename)
        def get_data_from_tag(node, tag):
            return node.getElementsByTagName(tag)[0].childNodes[0].data
        with open(filename) as f:
            data = minidom.parseString(f.read())
        objs = data.getElementsByTagName('object')
        num_objs = len(objs)
        used_objs = []
        for id, obj in enumerate(objs):
            if str(get_data_from_tag(obj, "name")).lower().strip() in self._wnid_to_ind:
                used_objs.append(obj)
        objs = used_objs
        num_objs = len(objs)
        boxes = np.zeros((num_objs, 4), dtype=np.uint16)
        gt_classes = np.zeros((num_objs), dtype=np.int32)
        overlaps = np.zeros((num_objs, self.num_classes), dtype=np.float32)
        trackid = np.zeros((num_objs), dtype=np.int32)
        for ix, obj in enumerate(objs):
            x1 = float(get_data_from_tag(obj, 'xmin'))
            y1 = float(get_data_from_tag(obj, 'ymin'))
            x2 = float(get_data_from_tag(obj, 'xmax'))
            y2 = float(get_data_from_tag(obj, 'ymax'))
            cls = self._wnid_to_ind[
                str(get_data_from_tag(obj, "name")).lower().strip()]
            boxes[ix, :] = [x1, y1, x2, y2]
            gt_classes[ix] = cls
            overlaps[ix, cls] = 1.0
            trackid[ix] = int(get_data_from_tag(obj, 'trackid'))
        overlaps = scipy.sparse.csr_matrix(overlaps)
        return {'boxes': boxes,
                'gt_classes': gt_classes,
                'gt_overlaps': overlaps,
                'trackid': trackid,
                'flipped': False}
def _load_imagenet_annotation ( self , index ) : filename = index . replace ( 'Data' , 'Annotations' ) . replace ( '.JPEG' , '' ) + '.xml' assert os . path . exists ( filename ) , '%s' % ( filename ) def get_data_from_tag ( node , tag ) : return node . getElementsByTagName ( tag ) [ 0 ] . childNodes [ 0 ] . data with open ( filename ) as f : data = minidom . parseString ( f . read ( ) ) objs = data . getElementsByTagName ( 'object' ) num_objs = len ( objs ) used_objs = [ ] for id , obj in enumerate ( objs ) : if str ( get_data_from_tag ( obj , "name" ) ) . lower ( ) . strip ( ) in self . _wnid_to_ind : used_objs . append ( obj ) objs = used_objs num_objs = len ( objs ) boxes = np . zeros ( ( num_objs , 4 ) , dtype = np . uint16 ) gt_classes = np . zeros ( ( num_objs ) , dtype = np . int32 ) overlaps = np . zeros ( ( num_objs , self . num_classes ) , dtype = np . float32 ) trackid = np . zeros ( ( num_objs ) , dtype = np . int32 ) for ix , obj in enumerate ( objs ) : x1 = float ( get_data_from_tag ( obj , 'xmin' ) ) y1 = float ( get_data_from_tag ( obj , 'ymin' ) ) x2 = float ( get_data_from_tag ( obj , 'xmax' ) ) y2 = float ( get_data_from_tag ( obj , 'ymax' ) ) cls = self . _wnid_to_ind [ str ( get_data_from_tag ( obj , "name" ) ) . lower ( ) . strip ( ) ] boxes [ ix , : ] = [ x1 , y1 , x2 , y2 ] gt_classes [ ix ] = cls overlaps [ ix , cls ] = 1.0 trackid [ ix ] = int ( get_data_from_tag ( obj , 'trackid' ) ) overlaps = scipy . sparse . csr_matrix ( overlaps ) return { 'boxes' : boxes , 'gt_classes' : gt_classes , 'gt_overlaps' : overlaps , 'trackid' : trackid , 'flipped' : False }
Load image and bounding boxes info from txt files of imagenet.
Load image and bounding boxes info from txt files of imagenet .
"""
        Load image and bounding boxes info from txt files of imagenet.
        """ # filename = os.path.join(self._data_path, 'Annotations', self._image_set, index + '.xml') # print 'Loading: {}'.format(filename) # filter the objects not in video synsets. # print('before:',num_objs) # print('after:', num_objs) ########################################## # Load object bounding boxes into a data frame.
self
index