def __init__(self, root=None, image_loader=default_image_loader, data_fraction=None): """ args: root - path to the coco dataset. image_loader (default_image_loader) - The function to read the images. If installed, jpeg4py (https://github.com/ajkxyz/jpeg4py) is used by default. Else, opencv's imread is used. data_fraction (None) - Fraction of images to be used. The images are selected randomly. If None, all the images will be used """ root = env_settings().coco_dir if root is None else root super().__init__(root, image_loader) self.img_pth = os.path.join(root, 'train2014/') self.anno_path = os.path.join(root, 'annotations/instances_train2014.json') # Load the COCO set. self.coco_set = COCO(self.anno_path) self.cats = self.coco_set.cats self.sequence_list = self._get_sequence_list() if data_fraction is not None: self.sequence_list = random.sample( self.sequence_list, int(len(self.sequence_list) * data_fraction))
def __init__(self, root=None, image_loader=default_image_loader, min_length=0, max_target_area=1): """ args: root - path to the imagenet vid dataset. image_loader (default_image_loader) - The function to read the images. If installed, jpeg4py (https://github.com/ajkxyz/jpeg4py) is used by default. Else, opencv's imread is used. min_length - Minimum allowed sequence length. max_target_area - max allowed ratio between target area and image area. Can be used to filter out targets which cover complete image. """ root = env_settings().imagenetdet_dir if root is None else root super().__init__(root, image_loader) cache_file = os.path.join(root, 'cache.json') if os.path.isfile(cache_file): # If available, load the pre-processed cache file containing meta-info for each sequence with open(cache_file, 'r') as f: sequence_list_dict = json.load(f) self.sequence_list = sequence_list_dict else: # Else process the imagenet annotations and generate the cache file self.sequence_list = self.get_seqence_list(root) with open(cache_file, 'w') as f: json.dump(self.sequence_list, f) # Filter the sequences based on min_length and max_target_area in the first frame self.sequence_list = [x for x in self.sequence_list if len(x['anno']) >= min_length and get_target_to_image_ratio(x) < max_target_area] self.dataset_root = root
def __init__(self, root=None, image_loader=jpeg4py_loader, vid_ids=None, split=None, data_fraction=None): """ args: root - path to the lasot dataset. image_loader (jpeg4py_loader) - The function to read the images. jpeg4py (https://github.com/ajkxyz/jpeg4py) is used by default. vid_ids - List containing the ids of the videos (1 - 20) used for training. If vid_ids = [1, 3, 5], then the videos with subscripts -1, -3, and -5 from each class will be used for training. split - If split='train', the official train split (protocol-II) is used for training. Note: Only one of vid_ids or split option can be used at a time. data_fraction - Fraction of dataset to be used. The complete dataset is used by default """ root = env_settings().lasot_dir if root is None else root super().__init__('LaSOT', root, image_loader) # Keep a list of all classes self.class_list = [f for f in os.listdir(self.root)] self.class_to_id = { cls_name: cls_id for cls_id, cls_name in enumerate(self.class_list) } self.sequence_list = self._build_sequence_list(vid_ids, split) if data_fraction is not None: self.sequence_list = random.sample( self.sequence_list, int(len(self.sequence_list) * data_fraction)) self.seq_per_class = self._build_class_list()
def __init__(self, root=None, image_loader=jpeg4py_loader, set_ids=None, data_fraction=None): """ args: root - The path to the TrackingNet folder, containing the training sets. image_loader (jpeg4py_loader) - The function to read the images. jpeg4py (https://github.com/ajkxyz/jpeg4py) is used by default. set_ids (None) - List containing the ids of the TrackingNet sets to be used for training. If None, all the sets (0 - 11) will be used. data_fraction - Fraction of dataset to be used. The complete dataset is used by default """ root = env_settings().trackingnet_dir if root is None else root super().__init__('TrackingNet', root, image_loader) if set_ids is None: set_ids = [i for i in range(12)] self.set_ids = set_ids # Keep a list of all videos. Sequence list is a list of tuples (set_id, video_name) containing the set_id and # video_name for each sequence self.sequence_list = list_sequences(self.root, self.set_ids) if data_fraction is not None: self.sequence_list = random.sample(self.sequence_list, int(len(self.sequence_list) * data_fraction)) self.seq_to_class_map, self.seq_per_class = self._load_class_info() # we do not have the class_lists for the tracking net self.class_list = list(self.seq_per_class.keys()) self.class_list.sort()
def __init__(self, root=None, image_loader=default_image_loader, vid_ids=None, split=None, data_fraction=None): """ args: root - path to the lasot dataset. image_loader (default_image_loader) - The function to read the images. If installed, jpeg4py (https://github.com/ajkxyz/jpeg4py) is used by default. Else, opencv's imread is used. vid_ids - List containing the ids of the videos (1 - 20) used for training. If vid_ids = [1, 3, 5], then the videos with subscripts -1, -3, and -5 from each class will be used for training. split - If split='train', the official train split (protocol-II) is used for training. Note: Only one of vid_ids or split option can be used at a time. data_fraction (None) - Fraction of videos to be used. The videos are selected randomly. If None, all the videos will be used """ root = env_settings().lasot_dir if root is None else root super().__init__(root, image_loader) self.sequence_list = self._build_sequence_list(vid_ids, split) if data_fraction is not None: self.sequence_list = random.sample( self.sequence_list, int(len(self.sequence_list) * data_fraction))
def __init__(self, root=None, image_loader=jpeg4py_loader_w_failsafe, data_fraction=None, split="train"): """ args: root - path to SBD root folder image_loader - The function to read the images. jpeg4py (https://github.com/ajkxyz/jpeg4py) is used by default. data_fraction - Fraction of dataset to be used. The complete dataset is used by default split - dataset split ("train", "train_noval", "val") """ root = env_settings().sbd_dir if root is None else root super().__init__('SBD', root, image_loader) assert split in ["train", "train_noval", "val"] self.root = root self.image_path_list, self.anno_file_list = self._load_dataset(split) # Load mat fine anno_list = [loadmat(a) for a in self.anno_file_list] self.image_list = self._construct_image_list(anno_list) if data_fraction is not None: raise NotImplementedError
def __init__(self, root=None, image_loader=default_image_loader, set_ids=None, data_fraction=None): """ args: root - The path to the TrackingNet folder, containing the training sets. image_loader (default_image_loader) - The function to read the images. If installed, jpeg4py (https://github.com/ajkxyz/jpeg4py) is used by default. Else, opencv's imread is used. set_ids (None) - List containing the ids of the TrackingNet sets to be used for training. If None, all the sets (0 - 11) will be used. data_fraction (None) - Fraction of videos to be used. The videos are selected randomly. If None, all the videos will be used """ root = env_settings().trackingnet_dir if root is None else root super().__init__(root, image_loader) if set_ids is None: set_ids = [i for i in range(12)] self.set_ids = set_ids # Keep a list of all videos. Sequence list is a list of tuples (set_id, video_name) containing the set_id and # video_name for each sequence self.sequence_list = list_sequences(self.root, self.set_ids) if data_fraction is not None: self.sequence_list = random.sample(self.sequence_list, int(len(self.sequence_list) * data_fraction))
def __init__(self, root=None, image_loader=jpeg4py_loader, min_length=0, max_target_area=1, use_target_visible=False): root = env_settings().imagenet_dir if root is None else root super().__init__(root, image_loader) cache_file = os.path.join(root, 'cache.json') if os.path.isfile(cache_file): # If available, load the pre-processed cache file containing meta-info for each sequence with open(cache_file, 'r') as f: sequence_list_dict = json.load(f) self.sequence_list = sequence_list_dict else: # Else process the imagenet annotations and generate the cache file self.sequence_list = self._process_anno(root) with open(cache_file, 'w') as f: json.dump(self.sequence_list, f) # Filter the sequences based on min_length and max_target_area in the first frame self.sequence_list = [ x for x in self.sequence_list if len(x['anno']) >= min_length and get_target_to_image_ratio(x) < max_target_area ] if not use_target_visible: raise NotImplementedError # TODO add the class info # we do not have the class_lists for the tracking net self.class_list = self._get_class_list()
def __init__(self, root=None, image_loader=jpeg4py_loader, dtype='depth', split=None, seq_ids=None, data_fraction=None): """ args: root - path to the got-10k training data. Note: This should point to the 'train' folder inside GOT-10k image_loader (jpeg4py_loader) - The function to read the images. jpeg4py (https://github.com/ajkxyz/jpeg4py) is used by default. split - 'train' or 'val'. Note: The validation split here is a subset of the official got-10k train split, not NOT the official got-10k validation split. To use the official validation split, provide that as the root folder instead. seq_ids - List containing the ids of the videos to be used for training. Note: Only one of 'split' or 'seq_ids' options can be used at the same time. data_fraction - Fraction of dataset to be used. The complete dataset is used by default """ root = env_settings().cdtb_dir if root is None else root super().__init__('CDTB', root, image_loader) # all folders inside the root self.sequence_list = self._get_sequence_list() # seq_id is the index of the folder inside the CDTB root path if split is not None: if seq_ids is not None: raise ValueError('Cannot set both split_name and seq_ids.') ltr_path = os.path.join( os.path.dirname(os.path.realpath(__file__)), '..') if split == 'train': file_path = os.path.join(ltr_path, 'data_specs', 'cdtb_train_split.txt') elif split == 'val': file_path = os.path.join(ltr_path, 'data_specs', 'cdtb_val_split.txt') else: raise ValueError('Unknown split name.') self.sequence_list = pandas.read_csv(file_path, header=None, squeeze=True).values.tolist() elif seq_ids is not None: self.sequence_list = [self.sequence_list[i] for i in seq_ids] else: # raise ValueError('Set either split_name or vid_ids.') print('Using all 80 sequences ...') if data_fraction is not None: self.sequence_list = random.sample( self.sequence_list, int(len(self.sequence_list) * data_fraction)) # self.sequence_meta_info = self._load_meta_info() self.seq_per_class = self._build_seq_per_class() self.class_list = list(self.seq_per_class.keys()) self.class_list.sort() self.dtype = dtype
def __init__(self, root=None, image_loader=jpeg4py_loader_w_failsafe, data_fraction=None, min_area=None, split="train"): """ args: root - path to lvis root folder image_loader (jpeg4py_loader) - The function to read the images. jpeg4py (https://github.com/ajkxyz/jpeg4py) is used by default. data_fraction - Fraction of dataset to be used. The complete dataset is used by default min_area - Objects with area less than min_area are filtered out. Default is 0.0 split - 'train' or 'val'. """ root = env_settings().lvis_dir if root is None else root super().__init__('LVIS', root, image_loader) self.img_pth = os.path.join(root, 'images', f'{split}2017/') self.anno_path = os.path.join(root, 'annotations', f'lvis_v0.5_{split}.json') # Load the LVIS set. self.lvis_set = lvis_pk.LVIS(self.anno_path) self.cats = self.lvis_set.cats self.class_list = self.get_class_list() # the parent class thing would happen in the sampler self.image_list = self._get_image_list(min_area=min_area) if data_fraction is not None: self.image_list = random.sample(self.image_list, int(len(self.image_list) * data_fraction)) self.im_per_class = self._build_im_per_class()
def resnet50(name, is_test=False, pretrained=False): net = ResNet(name, Block=Bottleneck, layers=50, is_test=is_test) if pretrained: params_path = os.path.join(env_settings().backbone_dir, 'ResNet50') print("=> loading backbone model from '{}'".format(params_path)) params, _ = fluid.load_dygraph(params_path) net.load_dict(params) print("Done") return net
def AlexNet(name, is_test, output_layers, pretrained=False): net = alexnet(name, is_test=is_test, output_layers=output_layers) if pretrained: params_path = os.path.join(env_settings().backbone_dir, 'AlexNet') print("=> loading backbone model from '{}'".format(params_path)) params, _ = fluid.load_dygraph(params_path) net.load_dict(params) print("Done") return net
def __init__(self, root=None, image_loader=opencv_loader, split=None, seq_ids=None): """ args: root - path to the got-10k training data. Note: This should point to the 'train' folder inside GOT-10k image_loader (jpeg4py_loader) - The function to read the images. jpeg4py (https://github.com/ajkxyz/jpeg4py) is used by default. split - 'train' or 'val'. Note: The validation split here is a subset of the official got-10k train split, not NOT the official got-10k validation split. To use the official validation split, provide that as the root folder instead. seq_ids - List containing the ids of the videos to be used for training. Note: Only one of 'split' or 'seq_ids' options can be used at the same time. """ root = env_settings().got10k_dir if root is None else root self.root_i = env_settings().got10k_i_dir super().__init__(root, image_loader) # all folders inside the root self.sequence_list = self._get_sequence_list() # seq_id is the index of the folder inside the got10k root path if split is not None: if seq_ids is not None: raise ValueError('Cannot set both split_name and seq_ids.') ltr_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..') if split == 'train': file_path = os.path.join(ltr_path, 'data_specs', 'got10k_train_split.txt') elif split == 'val': file_path = os.path.join(ltr_path, 'data_specs', 'got10k_val_split.txt') else: raise ValueError('Unknown split name.') seq_ids = pandas.read_csv(file_path, header=None, squeeze=True, dtype=np.int64).values.tolist() elif seq_ids is None: seq_ids = list(range(0, len(self.sequence_list))) # self.seq_ids = seq_ids self.sequence_list = [self.sequence_list[i] for i in seq_ids] self.sequence_meta_info = self._load_meta_info() self.seq_per_class = self._build_seq_per_class() self.class_list = list(self.seq_per_class.keys()) self.class_list.sort()
def __init__(self, root=None, image_loader=default_image_loader): root = env_settings().coco_dir if root is None else root super().__init__(root, image_loader) self.img_pth = os.path.join(root, 'train2017/') self.anno_path = os.path.join(root, 'annotations/instances_train2017.json') # Load the COCO set. self.coco_set = COCO(self.anno_path) self.cats = self.coco_set.cats self.sequence_list = self._get_sequence_list()
def __init__(self, root=None, image_loader=default_image_loader): root = env_settings().coco_dir if root is None else root super().__init__(root, image_loader) self.img_pth = os.path.join(root, 'train2014/') self.anno_path = os.path.join(root, 'annotations/instances_train2014.json') # Load the COCO set. self.coco_set = COCO(self.anno_path) self.cats = self.coco_set.cats self.num_cats = len(self.cats.keys())+1 self.map_id_cat = {cat_id: i+1 for i, cat_id in enumerate(list(self.coco_set.cats.keys()))} #背景层 self.sequence_list = self._get_sequence_list()
def __init__(self, root=None, image_loader=opencv_loader, vid_ids=None, split=None): """ args: root - path to the lasot dataset. image_loader (jpeg4py_loader) - The function to read the images. jpeg4py (https://github.com/ajkxyz/jpeg4py) is used by default. vid_ids - List containing the ids of the videos (1 - 20) used for training. If vid_ids = [1, 3, 5], then the videos with subscripts -1, -3, and -5 from each class will be used for training. split - If split='train', the official train split (protocol-II) is used for training. Note: Only one of vid_ids or split option can be used at a time. """ root = env_settings().ptb_dir if root is None else root print('init PrincetonRGBD, root is %s'%root) super().__init__(root, image_loader) self.sequence_list = self._build_sequence_list(vid_ids, split)
def __init__(self, root=None, image_loader=jpeg4py_loader, max_target_area=1): super().__init__(root, image_loader) raise NotImplementedError root = env_settings().imagenetdet_dir if root is None else root cache_file = os.path.join(root, 'cache.json') if os.path.isfile(cache_file): with open(cache_file, 'r') as f: self.sequence_list = json.load(f) else: self.sequence_list = self._process_anno(root) with open(cache_file, 'w') as f: json.dump(self.sequence_list, f) self.sequence_list = [x for x in self.sequence_list if get_target_to_image_ratio(x) < max_target_area] self.class_list = self._get_class_list()
def __init__(self, root=None, image_loader=jpeg4py_loader): root = env_settings().coco_dir if root is None else root super().__init__(root, image_loader) self.img_pth = os.path.join(root, 'train2014/') self.anno_path = os.path.join(root, 'annotations/instances_train2014.json') # Load the COCO set. self.coco_set = COCO(self.anno_path) self.cats = self.coco_set.cats self.class_list = self.get_class_list( ) # the parent class thing would happen in the sampler self.sequence_list = self._get_sequence_list() self.seq_per_class = self._build_seq_per_class()
def __init__(self, root=None, image_loader=default_image_loader, set_ids=None): """ args: root - The path to the TrackingNet folder, containing the training sets. image_loader (jpeg4py_loader) - The function to read the images. jpeg4py (https://github.com/ajkxyz/jpeg4py) is used by default. set_ids (None) - List containing the ids of the TrackingNet sets to be used for training. If None, all the sets (0 - 11) will be used. """ root = env_settings().trackingnet_dir if root is None else root super().__init__(root, image_loader) if set_ids is None: set_ids = [i for i in range(12)] self.set_ids = set_ids # Keep a list of all videos. Sequence list is a list of tuples (set_id, video_name) containing the set_id and # video_name for each sequence self.sequence_list = list_sequences(self.root, self.set_ids)
def __init__(self, root=None, image_loader=jpeg4py_loader, data_fraction=None, min_area=None): """ args: root - path to MSRA10k root folder image_loader (jpeg4py_loader) - The function to read the images. jpeg4py (https://github.com/ajkxyz/jpeg4py) is used by default. data_fraction - Fraction of dataset to be used. The complete dataset is used by default min_area - Objects with area less than min_area are filtered out. Default is 0.0 """ root = env_settings().msra10k_dir if root is None else root super().__init__('MSRA10k', root, image_loader) self.image_list = self._load_dataset(min_area=min_area) if data_fraction is not None: raise NotImplementedError
def __init__(self, root=None, image_loader=jpeg4py_loader, data_fraction=None, split="train", version="2014"): """ args: root - path to the coco dataset. image_loader (default_image_loader) - The function to read the images. If installed, jpeg4py (https://github.com/ajkxyz/jpeg4py) is used by default. Else, opencv's imread is used. data_fraction (None) - Fraction of images to be used. The images are selected randomly. If None, all the images will be used split - 'train' or 'val'. version - version of coco dataset (2014 or 2017) """ root = env_settings().coco_dir if root is None else root super().__init__('COCO', root, image_loader) # self.img_pth = os.path.join(root, 'images/{}{}/'.format(split, version)) # self.anno_path = os.path.join(root, 'annotations/instances_{}{}.json'.format(split, version)) self.img_pth = os.path.join(root, 'train2014/') self.anno_path = os.path.join(root, 'annotations/instances_train2014.json') # Load the COCO set. self.coco_set = COCO(self.anno_path) self.cats = self.coco_set.cats self.class_list = self.get_class_list() self.sequence_list = self._get_sequence_list() if data_fraction is not None: self.sequence_list = random.sample( self.sequence_list, int(len(self.sequence_list) * data_fraction)) self.seq_per_class = self._build_seq_per_class()
def __init__(self, root=None, image_loader=jpeg4py_loader, data_fraction=None, min_area=None, split="train", version="2014"): """ args: root - path to coco root folder image_loader (jpeg4py_loader) - The function to read the images. jpeg4py (https://github.com/ajkxyz/jpeg4py) is used by default. data_fraction - Fraction of dataset to be used. The complete dataset is used by default min_area - Objects with area less than min_area are filtered out. Default is 0.0 split - 'train' or 'val'. version - version of coco dataset (2014 or 2017) """ root = env_settings().coco_dir if root is None else root super().__init__('COCO', root, image_loader) self.img_pth = os.path.join(root, 'images/{}{}/'.format(split, version)) self.anno_path = os.path.join( root, 'annotations/instances_{}{}.json'.format(split, version)) self.coco_set = COCO(self.anno_path) self.cats = self.coco_set.cats self.class_list = self.get_class_list( ) # the parent class thing would happen in the sampler self.image_list = self._get_image_list(min_area=min_area) if data_fraction is not None: self.image_list = random.sample( self.image_list, int(len(self.image_list) * data_fraction)) self.im_per_class = self._build_im_per_class()
def __init__(self, root=None, dtype='colormap', split=None, image_loader=jpeg4py_loader, vid_ids=None): # split=None, data_fraction=None): """ args: image_loader (jpeg4py_loader) - The function to read the images. jpeg4py (https://github.com/ajkxyz/jpeg4py) is used by default. vid_ids - List containing the ids of the videos (1 - 20) used for training. If vid_ids = [1, 3, 5], then the videos with subscripts -1, -3, and -5 from each class will be used for training. # split - If split='train', the official train split (protocol-II) is used for training. Note: Only one of # vid_ids or split option can be used at a time. # data_fraction - Fraction of dataset to be used. The complete dataset is used by default root - path to the lasot depth dataset. dtype - colormap or depth,, colormap + depth if colormap, it returns the colormap by cv2, if depth, it returns [depth, depth, depth] """ root = env_settings().depthtrack_dir if root is None else root super().__init__('DepthTrack', root, image_loader) self.root = root self.dtype = dtype self.split = split # colormap or depth self.sequence_list = self._build_sequence_list() self.seq_per_class, self.class_list = self._build_class_list() self.class_list.sort() self.class_to_id = { cls_name: cls_id for cls_id, cls_name in enumerate(self.class_list) }
def __init__(self, root=None, version='2019', split='train', cleanup=None, all_frames=False, sequences=None, multiobj=True, vis_threshold=10, image_loader=jpeg4py_loader): """ args: root - Dataset root path. If unset, it uses the path in your local.py config. version - '2018' or '2019' split - 'test', 'train', 'valid', or 'jjtrain', 'jjvalid'. 'jjvalid' corresponds to a custom validation dataset consisting of 300 videos randomly sampled from the train set. 'jjtrain' contains the remaining videos used for training. cleanup - List of actions to take to to clean up known problems in the dataset. 'aspects': remove frames with weird aspect ratios, 'starts': fix up start frames from original meta data all_frames - Whether to use an "all_frames" split. sequences - List of sequence names. Limit to a subset of sequences if not None. multiobj - Whether the dataset will return all objects in a sequence or multiple sequences with one object in each. vis_threshold - Minimum number of pixels required to consider a target object "visible". image_loader - Image loader. """ root = env_settings().youtubevos_dir if root is None else root super().__init__(name="YouTubeVOS", root=Path(root), version=version, split=split, multiobj=multiobj, vis_threshold=vis_threshold, image_loader=image_loader) split_folder = self.split if self.split.startswith("jj"): split_folder = "train" dset_path = self.root / self.version / split_folder self._anno_path = dset_path / 'Annotations' if all_frames: self._jpeg_path = self.root / self.version / ( split_folder + "_all_frames") / 'JPEGImages' else: self._jpeg_path = dset_path / 'JPEGImages' self.meta = YouTubeVOSMeta(dset_path) meta_path = dset_path / "generated_meta.json" if meta_path.exists(): self.gmeta = VOSMeta(filename=meta_path) else: self.gmeta = VOSMeta.generate('YouTubeVOS', self._jpeg_path, self._anno_path) self.gmeta.save(meta_path) if all_frames: self.gmeta.enable_all_frames(self._jpeg_path) if self.split not in ['train', 'valid', 'test']: self.gmeta.select_split('youtubevos', self.split) if sequences is None: sequences = self.gmeta.get_sequence_names() to_remove = set() cleanup = {} if cleanup is None else set(cleanup) if 'aspect' in cleanup: # Remove sequences with unusual aspect ratios for seq_name in sequences: a = self.gmeta.get_aspect_ratio(seq_name) if a < 1.45 or a > 1.9: to_remove.add(seq_name) if 'starts' in cleanup: # Fix incorrect start frames for some objects found with ytvos_start_frames_test() bad_start_frames = [ ("0e27472bea", '2', ['00055', '00060'], '00065'), ("5937b08d69", '4', ['00000'], '00005'), ("5e1ce354fd", '5', ['00010', '00015'], '00020'), ("7053e4f41e", '2', ['00000', '00005', '00010', '00015'], '00020'), ("720e3fa04c", '2', ['00050'], '00055'), ("c73c8e747f", '2', ['00035'], '00040') ] for seq_name, obj_id, bad_frames, good_frame in bad_start_frames: # bad_frames is from meta.json included with the dataset # good_frame is from the generated meta - and the first actual frame where the object was seen. if seq_name in self.meta._data: frames = self.meta.object_frames(seq_name, obj_id) for f in bad_frames: frames.remove(f) assert frames[0] == good_frame sequences = [seq for seq in sequences if seq not in to_remove] self.sequence_names = sequences self._samples = [] for seq in sequences: obj_ids = self.meta.object_ids(seq) if self.multiobj: # Multiple objects per sample self._samples.append((seq, obj_ids)) else: # One object per sample self._samples.extend([(seq, [obj_id]) for obj_id in obj_ids]) print("%s loaded." % self.get_name()) if len(to_remove) > 0: print(" %d sequences were removed, (%d remaining)." % (len(to_remove), len(sequences)))
def __init__(self, root=None, image_loader=default_image_loader, split=None, seq_ids=None, data_fraction=None): """ args: root - path to the got-10k training data. Note: This should point to the 'train' folder inside GOT-10k image_loader (default_image_loader) - The function to read the images. If installed, jpeg4py (https://github.com/ajkxyz/jpeg4py) is used by default. Else, opencv's imread is used. split - 'train' or 'val'. Note: The validation split here is a subset of the official got-10k train split, not NOT the official got-10k validation split. To use the official validation split, provide that as the root folder instead. seq_ids - List containing the ids of the videos to be used for training. Note: Only one of 'split' or 'seq_ids' options can be used at the same time. data_fraction (None) - Fraction of videos to be used. The videos are selected randomly. If None, all the videos will be used """ root = env_settings().got10k_dir if root is None else root super().__init__(root, image_loader) # all folders inside the root self.sequence_list = self._get_sequence_list() # seq_id is the index of the folder inside the got10k root path if split is not None: if seq_ids is not None: raise ValueError('Cannot set both split_name and seq_ids.') ltr_path = os.path.join( os.path.dirname(os.path.realpath(__file__)), '../..') if split == 'train': file_path = os.path.join(ltr_path, 'data_specs', 'got10k_train_split.txt') elif split == 'val': file_path = os.path.join(ltr_path, 'data_specs', 'got10k_val_split.txt') elif split == 'vottrain': file_path = os.path.join(ltr_path, 'data_specs', 'got10k_vot_train_split.txt') elif split == 'votval': file_path = os.path.join(ltr_path, 'data_specs', 'got10k_vot_val_split.txt') else: raise ValueError('Unknown split name.') seq_ids = pandas.read_csv(file_path, header=None, squeeze=True, dtype=np.int64).values.tolist() elif seq_ids is None: seq_ids = list(range(0, len(self.sequence_list))) # self.seq_ids = seq_ids self.sequence_list = [self.sequence_list[i] for i in seq_ids] # original # self.sequence_list = [self.sequence_list[i-1] for i in seq_ids] # my changed version if data_fraction is not None: self.sequence_list = random.sample( self.sequence_list, int(len(self.sequence_list) * data_fraction)) self.sequence_meta_info = self._load_meta_info()
def set_default(self): self.env = env_settings() self.use_gpu = True
def __init__(self, root=None, sequences='bear', version='2017', split='train', multiobj=True, vis_threshold=10, image_loader=jpeg4py_loader): """ args: root - Dataset root path. If unset, it uses the path in your local.py config. sequences - List of sequence names. Limit to a subset of sequences if not None. version - '2016' or '2017 split - Any name in DAVIS/ImageSets/<year> multiobj - Whether the dataset will return all objects in a sequence or multiple sequences with one object in each. vis_threshold - Minimum number of pixels required to consider a target object "visible". image_loader (jpeg4py_loader) - The function to read the images. jpeg4py (https://github.com/ajkxyz/jpeg4py) is used by default. """ if version == '2017': if split in ['train', 'val']: root = env_settings().davis_dir if root is None else root elif split in ['test-dev']: root = env_settings( ).davis_testdev_dir if root is None else root else: raise Exception('Unknown split {}'.format(split)) else: root = env_settings().davis_dir if root is None else root super().__init__(name='DAVIS', root=Path(root), version=version, split=split, multiobj=multiobj, vis_threshold=vis_threshold, image_loader=image_loader) dset_path = Path('gdrive/My Drive/DAVIS') self._jpeg_path = Path('gdrive/My Drive/DAVIS/JPEGImages/480p') self._anno_path = Path('gdrive/My Drive/DAVIS/Annotations/480p') meta_path = Path('gdrive/My Drive/DAVIS/generated_meta.json') self.gmeta = VOSMeta.generate('DAVIS', self._jpeg_path, self._anno_path) self.gmeta.save(meta_path) if sequences is None: if self.split != 'all': print("use created sequeceses") #fname = Path('gdrive/My Drive/DAVIS/ImageSets') / self.version / (self.split + '.txt') #sequences = open(fname).read().splitlines() else: #sequences = [p for p in sorted(self._jpeg_path.glob("*")) if p.is_dir()] print("create Sequences") sequences = [self._jpeg_path / 'bear'] self.sequence_names = [self._jpeg_path / 'bear'] print("seq names") print(self.sequence_names) self._samples = [] seq = "bear" obj_ids = self.gmeta.get_obj_ids(seq) if self.multiobj: # Multiple objects per sample self._samples.append((seq, obj_ids)) else: # One object per sample self._samples.extend([(seq, [obj_id]) for obj_id in obj_ids]) '''for seq in sequences: obj_ids = self.gmeta.get_obj_ids(seq) if self.multiobj: # Multiple objects per sample self._samples.append((seq, obj_ids)) else: # One object per sample self._samples.extend([(seq, [obj_id]) for obj_id in obj_ids]) ''' print("%s loaded." % self.get_name())