lib/datasets/imagenetVID_PLUS.py
def _load_image_set_index(self):
        '''
        Load all the image index.
        '''
        if self._image_set == 'train':
            path_det_txt = os.path.join(self._data_path, 'ImageSets', 'DET_train_30classes.txt')
            path_vid_txt = os.path.join(self._data_path, 'ImageSets', 'VID_train_every10frames.txt')
            # vid samples.
            with open(path_vid_txt, 'r') as f:
                prefix = 'data/imagenet/ILSVRC/Data/VID/'
                lines = f.readlines()
                clean_vid_lines = []
                zero_index = []
                for line_id in range(len(lines)):
                    line = lines[line_id]
                    items = line.split()
                    if items[2] == '0':
                        zero_index.append(line_id)
                    clean_vid_lines.append(os.path.join(prefix, items[0], '%06d' % int(items[2])))
            # det samples.
            with open(path_det_txt) as f:
                prefix = 'data/imagenet/ILSVRC/Data/DET/'
                lines = f.readlines()
                clean_det_lines = []
                for line in lines:
                    items = line.split()
                    clean_det_lines.append(os.path.join(prefix, items[0]))
            vid_plus_indexes = np.append(clean_vid_lines, clean_det_lines)
            self._vid_num = len(clean_vid_lines)
            self._det_num = len(clean_det_lines)
            return vid_plus_indexes, zero_index
        else:
            vid_set_file = os.path.join(self._data_path, 'ImageSets', 'VID', 'val.txt')
            assert os.path.exists(vid_set_file), vid_set_file + ' does not exist.'
            image_indexes = []
            # [vid,...[index...]]
            structured_indexes = []
            last_dir = None
            tmp_holder = None
            i = 0
            with open(vid_set_file, 'r') as f:
                for x in f.readlines():
                    line = x.strip().split(' ')
                    dir_name = os.path.dirname(line[0])
                    if dir_name != last_dir:
                        if tmp_holder is not None:
                            structured_indexes.append(tmp_holder)
                        tmp_holder = []
                        last_dir = dir_name
                    image_indexes.append(self._data_path + '/Data/VID/val/' + line[0])
                    tmp_holder.append(i)
                    i += 1
                # Add the last vid.
                structured_indexes.append(tmp_holder)

            print('Total number of videos are: %d.' % (len(structured_indexes)))
            print('Total number of video images are: %d.' % (len(image_indexes)))
            return image_indexes, structured_indexes

        Load all the image index.
        
Load all the image index.
Load all the image index .
def _load_image_set_index(self):
        if self._image_set == 'train':
            path_det_txt = os.path.join(self._data_path, 'ImageSets', 'DET_train_30classes.txt')
            path_vid_txt = os.path.join(self._data_path, 'ImageSets', 'VID_train_every10frames.txt')
            with open(path_vid_txt, 'r') as f:
                prefix = 'data/imagenet/ILSVRC/Data/VID/'
                lines = f.readlines()
                clean_vid_lines = []
                zero_index = []
                for line_id in range(len(lines)):
                    line = lines[line_id]
                    items = line.split()
                    if items[2] == '0':
                        zero_index.append(line_id)
                    clean_vid_lines.append(os.path.join(prefix, items[0], '%06d' % int(items[2])))
            with open(path_det_txt) as f:
                prefix = 'data/imagenet/ILSVRC/Data/DET/'
                lines = f.readlines()
                clean_det_lines = []
                for line in lines:
                    items = line.split()
                    clean_det_lines.append(os.path.join(prefix, items[0]))
            vid_plus_indexes = np.append(clean_vid_lines, clean_det_lines)
            self._vid_num = len(clean_vid_lines)
            self._det_num = len(clean_det_lines)
            return vid_plus_indexes, zero_index
        else:
            vid_set_file = os.path.join(self._data_path, 'ImageSets', 'VID', 'val.txt')
            assert os.path.exists(vid_set_file), vid_set_file + ' does not exist.'
            image_indexes = []
            structured_indexes = []
            last_dir = None
            tmp_holder = None
            i = 0
            with open(vid_set_file, 'r') as f:
                for x in f.readlines():
                    line = x.strip().split(' ')
                    dir_name = os.path.dirname(line[0])
                    if dir_name != last_dir:
                        if tmp_holder is not None:
                            structured_indexes.append(tmp_holder)
                        tmp_holder = []
                        last_dir = dir_name
                    image_indexes.append(self._data_path + '/Data/VID/val/' + line[0])
                    tmp_holder.append(i)
                    i += 1
                structured_indexes.append(tmp_holder)
            print('Total number of videos are: %d.' % (len(structured_indexes)))
            print('Total number of video images are: %d.' % (len(image_indexes)))
            return image_indexes, structured_indexes
def _load_image_set_index ( self ) : if self . _image_set == 'train' : path_det_txt = os . path . join ( self . _data_path , 'ImageSets' , 'DET_train_30classes.txt' ) path_vid_txt = os . path . join ( self . _data_path , 'ImageSets' , 'VID_train_every10frames.txt' ) with open ( path_vid_txt , 'r' ) as f : prefix = 'data/imagenet/ILSVRC/Data/VID/' lines = f . readlines ( ) clean_vid_lines = [ ] zero_index = [ ] for line_id in range ( len ( lines ) ) : line = lines [ line_id ] items = line . split ( ) if items [ 2 ] == '0' : zero_index . append ( line_id ) clean_vid_lines . append ( os . path . join ( prefix , items [ 0 ] , '%06d' % int ( items [ 2 ] ) ) ) with open ( path_det_txt ) as f : prefix = 'data/imagenet/ILSVRC/Data/DET/' lines = f . readlines ( ) clean_det_lines = [ ] for line in lines : items = line . split ( ) clean_det_lines . append ( os . path . join ( prefix , items [ 0 ] ) ) vid_plus_indexes = np . append ( clean_vid_lines , clean_det_lines ) self . _vid_num = len ( clean_vid_lines ) self . _det_num = len ( clean_det_lines ) return vid_plus_indexes , zero_index else : vid_set_file = os . path . join ( self . _data_path , 'ImageSets' , 'VID' , 'val.txt' ) assert os . path . exists ( vid_set_file ) , vid_set_file + ' does not exist.' image_indexes = [ ] structured_indexes = [ ] last_dir = None tmp_holder = None i = 0 with open ( vid_set_file , 'r' ) as f : for x in f . readlines ( ) : line = x . strip ( ) . split ( ' ' ) dir_name = os . path . dirname ( line [ 0 ] ) if dir_name != last_dir : if tmp_holder is not None : structured_indexes . append ( tmp_holder ) tmp_holder = [ ] last_dir = dir_name image_indexes . append ( self . _data_path + '/Data/VID/val/' + line [ 0 ] ) tmp_holder . append ( i ) i += 1 structured_indexes . append ( tmp_holder ) print ( 'Total number of videos are: %d.' % ( len ( structured_indexes ) ) ) print ( 'Total number of video images are: %d.' % ( len ( image_indexes ) ) ) return image_indexes , structured_indexes
Load all the image index.
Load all the image index .
'''
        Load all the image index.
        ''' # vid samples. # det samples. # [vid,...[index...]] # Add the last vid.
self