def _load_data(self, cfg): """ Load frame paths and annotations from files Args: cfg (CfgNode): config """ # Loading frame paths. self._image_paths, self._video_idx_to_name = ava_helper.load_image_lists( cfg, is_train=(self._split == "train")) # Loading annotations for boxes and labels. boxes_and_labels = ava_helper.load_boxes_and_labels(cfg, mode=self._split) assert len(boxes_and_labels) == len(self._image_paths) boxes_and_labels = [ boxes_and_labels[self._video_idx_to_name[i]] for i in range(len(self._image_paths)) ] # Get indices of keyframes and corresponding boxes and labels. ( self._keyframe_indices, self._keyframe_boxes_and_labels, ) = ava_helper.get_keyframe_data(boxes_and_labels) # Calculate the number of used boxes. self._num_boxes_used = ava_helper.get_num_boxes_used( self._keyframe_indices, self._keyframe_boxes_and_labels) self.print_summary()
def __init__(self, overall_iters, cfg, mode): """ overall_iters (int): the overall number of iterations of one epoch. cfg (CfgNode): configs. mode (str): `train`, `val`, or `test` mode. """ self.cfg = cfg self.lr = None self.loss = ScalarMeter(cfg.LOG_PERIOD) self.full_ava_test = cfg.AVA.FULL_TEST_ON_VAL self.mode = mode self.iter_timer = Timer() self.data_timer = Timer() self.net_timer = Timer() self.all_preds_train = [] self.all_ori_boxes_train = [] self.all_metadata_train = [] self.all_preds = [] self.all_ori_boxes = [] self.all_metadata = [] self.overall_iters = overall_iters self.categories, self.class_whitelist = read_labelmap( os.path.join(cfg.AVA.ANNOTATION_DIR, cfg.AVA.LABEL_MAP_FILE)) gt_filename = os.path.join(cfg.AVA.ANNOTATION_DIR, cfg.AVA.GROUNDTRUTH_FILE) self.full_groundtruth = read_csv(gt_filename, self.class_whitelist) self.mini_groundtruth = get_ava_mini_groundtruth(self.full_groundtruth) _, self.video_idx_to_name = ava_helper.load_image_lists( cfg, mode == "train") self.output_dir = cfg.OUTPUT_DIR
def __init__(self, overall_iters, cfg, mode): """ overall_iters (int): the overall number of iterations of one epoch. cfg (CfgNode): configs. mode (str): `train`, `val`, or `test` mode. """ is_custom_dataset = cfg.TRAIN.DATASET == "custom" and cfg.TEST.DATASET == "custom" if is_custom_dataset: logger.info("Creating AVA Meter for custom dataset in %s mode" % mode) else: logger.info("Creating AVA Meter for AVA dataset in %s mode" % mode) self.cfg = cfg self.lr = None self.loss = ScalarMeter(cfg.LOG_PERIOD) self.full_ava_test = cfg.AVA.FULL_TEST_ON_VAL if not is_custom_dataset else cfg.CUSTOM_DATASET.FULL_TEST_ON_VAL self.mode = mode self.iter_timer = Timer() self.all_preds = [] self.all_ori_boxes = [] self.all_metadata = [] self.overall_iters = overall_iters self.excluded_keys = read_exclusions( os.path.join(cfg.AVA.ANNOTATION_DIR, cfg.AVA.EXCLUSION_FILE) ) if not is_custom_dataset else read_exclusions( os.path.join(cfg.CUSTOM_DATASET.ANNOTATION_DIR, cfg.CUSTOM_DATASET.EXCLUSION_FILE)) self.categories, self.class_whitelist = read_labelmap( os.path.join(cfg.AVA.ANNOTATION_DIR, cfg.AVA.LABEL_MAP_FILE) ) if not is_custom_dataset else read_labelmap( os.path.join(cfg.CUSTOM_DATASET.ANNOTATION_DIR, cfg.CUSTOM_DATASET.LABEL_MAP_FILE)) gt_filename = os.path.join( cfg.AVA.ANNOTATION_DIR, cfg.AVA.GROUNDTRUTH_FILE ) if not is_custom_dataset else os.path.join( cfg.CUSTOM_DATASET.ANNOTATION_DIR, cfg.CUSTOM_DATASET.GROUNDTRUTH_FILE) self.full_groundtruth = read_csv(gt_filename, self.class_whitelist) self.mini_groundtruth = get_ava_mini_groundtruth(self.full_groundtruth) _, self.video_idx_to_name = ava_helper.load_image_lists( cfg, mode == "train" ) if not is_custom_dataset else custom_helper.load_image_lists( cfg, mode == "train")