def __init__(self, ground_truth_filename=None, prediction_filename=None, ground_truth_fields=GROUND_TRUTH_FIELDS, prediction_fields=PREDICTION_FIELDS, tiou_thr=0.5, subset='validation', verbose=False): if not ground_truth_filename: raise IOError('Please input a valid ground truth file.') if not prediction_filename: raise IOError('Please input a valid prediction file.') self.subset = subset self.tiou_thr = tiou_thr self.verbose = verbose self.gt_fields = ground_truth_fields self.pred_fields = prediction_fields self.ap = None # Retrieve blocked videos from server. self.blocked_videos = get_blocked_videos() # Import ground truth and predictions. self.ground_truth, self.activity_index = self._import_ground_truth( ground_truth_filename) self.prediction = self._import_prediction(prediction_filename) if self.verbose: print '[INIT] Loaded annotations from {} subset.'.format(subset) nr_gt = len(self.ground_truth) print '\tNumber of ground truth instances: {}'.format(nr_gt) nr_pred = len(self.prediction) print '\tNumber of predictions: {}'.format(nr_pred) print '\tFixed threshold for tiou score: {}'.format(self.tiou_thr)
def __init__(self, ground_truth_filename=None, prediction_filename=None, ground_truth_fields=GROUND_TRUTH_FIELDS, prediction_fields=PREDICTION_FIELDS, tiou_thresholds=np.linspace(0.5, 0.95, 10), subset='validation', verbose=False, check_status=True): if not ground_truth_filename: raise IOError('Please input a valid ground truth file.') if not prediction_filename: raise IOError('Please input a valid prediction file.') self.subset = subset self.tiou_thresholds = tiou_thresholds self.verbose = verbose self.gt_fields = ground_truth_fields self.pred_fields = prediction_fields self.ap = None self.check_status = check_status # Retrieve blocked videos from server. if self.check_status: self.blocked_videos = get_blocked_videos() else: self.blocked_videos = list() # Import ground truth and predictions. self.ground_truth, self.activity_index = self._import_ground_truth( ground_truth_filename) self.prediction = self._import_prediction(prediction_filename) if self.verbose: print '[INIT] Loaded annotations from {} subset.'.format(subset) nr_gt = len(self.ground_truth) print '\tNumber of ground truth instances: {}'.format(nr_gt) nr_pred = len(self.prediction) print '\tNumber of predictions: {}'.format(nr_pred) print '\tFixed threshold for tiou score: {}'.format(self.tiou_thresholds)
def __init__(self, ground_truth_filename=None, prediction_filename=None, ground_truth_fields=GROUND_TRUTH_FIELDS, prediction_fields=PREDICTION_FIELDS, subset='validation', verbose=False, top_k=3, check_status=True): if not ground_truth_filename: raise IOError('Please input a valid ground truth file.') if not prediction_filename: raise IOError('Please input a valid prediction file.') self.subset = subset self.verbose = verbose self.gt_fields = ground_truth_fields self.pred_fields = prediction_fields self.top_k = top_k self.ap = None self.hit_at_k = None self.check_status = check_status # Retrieve blocked videos from server. if self.check_status: self.blocked_videos = get_blocked_videos() else: self.blocked_videos = list() # Import ground truth and predictions. self.ground_truth, self.activity_index = self._import_ground_truth( ground_truth_filename) self.prediction = self._import_prediction(prediction_filename) if self.verbose: print '[INIT] Loaded annotations from {} subset.'.format(subset) nr_gt = len(self.ground_truth) print '\tNumber of ground truth instances: {}'.format(nr_gt) nr_pred = len(self.prediction) print '\tNumber of predictions: {}'.format(nr_pred)
def __init__(self, ground_truth_filename=None, proposal_filename=None, ground_truth_fields=GROUND_TRUTH_FIELDS, proposal_fields=PROPOSAL_FIELDS, tiou_thresholds=np.linspace(0.5, 0.95, 10), max_avg_nr_proposals=None, subset='validation', verbose=False, check_status=True): if not ground_truth_filename: raise IOError('Please input a valid ground truth file.') if not proposal_filename: raise IOError('Please input a valid proposal file.') self.subset = subset self.tiou_thresholds = tiou_thresholds self.max_avg_nr_proposals = max_avg_nr_proposals self.verbose = verbose self.gt_fields = ground_truth_fields self.pred_fields = proposal_fields self.recall = None self.avg_recall = None self.proposals_per_video = None self.check_status = check_status # Retrieve blocked videos from server. if self.check_status: self.blocked_videos = get_blocked_videos() else: self.blocked_videos = list() # Import ground truth and proposals. self.ground_truth, self.activity_index = self._import_ground_truth( ground_truth_filename) self.proposal = self._import_proposal(proposal_filename) if self.verbose: print '[INIT] Loaded annotations from {} subset.'.format(subset) nr_gt = len(self.ground_truth) print '\tNumber of ground truth instances: {}'.format(nr_gt) nr_pred = len(self.proposal) print '\tNumber of proposals: {}'.format(nr_pred) print '\tFixed threshold for tiou score: {}'.format(self.tiou_thresholds)
def __init__(self, ground_truth_filename=None, prediction_filename=None, ground_truth_fields=GROUND_TRUTH_FIELDS, prediction_fields=PREDICTION_FIELDS, tiou_thresholds=np.linspace(0.5, 0.95, 10), limit_factor=None, min_tiou_thr=0.1, subset='testing', verbose=False, check_status=True, load_extra_annotations=False, characteristic_names_to_bins={'context-size': (range(-1, 7), ['0', '1', '2', '3', '4', '5', '6']), 'context-distance': (range(-1, 4), ['Inf', 'N', 'M', 'F']), 'agreement': (np.linspace(0, 1.0, 6), ['XW', 'W', 'M', 'H', 'XH']), 'coverage': (np.linspace(0, 1.0, 6), ['XS', 'S', 'M', 'L', 'XL']), 'length': (np.array([0, 30, 60, 120, 180, np.inf]), ['XS', 'S', 'M', 'L', 'XL']), 'num-instances': (np.array([-1, 1, 4, 8, np.inf]), ['XS', 'S', 'M', 'L'])}, normalize_ap=False, minimum_normalized_precision_threshold_for_detection=0.00, evaluate_with_multi_segments=None): if not ground_truth_filename: raise IOError('Please input a valid ground truth file.') if not prediction_filename: raise IOError('Please input a valid prediction file.') self.subset = subset self.tiou_thresholds = tiou_thresholds self.verbose = verbose self.gt_fields = ground_truth_fields self.pred_fields = prediction_fields self.ap = None self.check_status = check_status self.load_extra_annotations = load_extra_annotations self.characteristic_names_to_bins = characteristic_names_to_bins self.characteristic_names = characteristic_names_to_bins.keys() self.normalize_ap = normalize_ap self.minimum_normalized_precision_threshold_for_detection = minimum_normalized_precision_threshold_for_detection self.evaluate_with_multi_segments = evaluate_with_multi_segments # Retrieve blocked videos from server. if self.check_status: self.blocked_videos = get_blocked_videos() else: self.blocked_videos = list() # Import ground truth and predictions. self.ground_truth, self.activity_index = self._import_ground_truth( ground_truth_filename) self.average_num_instance_per_class = len(self.ground_truth) / len(self.activity_index) self.prediction = self._import_prediction(prediction_filename) self.limit_factor = limit_factor if self.limit_factor: self.prediction = self._limit_prediction() self.matched_gt_id_cols, self.fp_error_type_cols = [], [] for tiou in self.tiou_thresholds: self.matched_gt_id_cols += ['matched-gt-id-' + str(tiou)] self.fp_error_type_cols += ['fp-error-type-' + str(tiou)] self.min_tiou_thr = min_tiou_thr if self.verbose: print('[INIT] Loaded annotations from {} subset.'.format(subset)) nr_gt = len(np.unique(self.ground_truth['gt-id'])) print('\tNumber of ground truth instances: {}'.format(nr_gt)) nr_pred = len(self.prediction) print('\tNumber of predictions: {}'.format(nr_pred)) print('\tFixed threshold for tiou score: {}'.format(self.tiou_thresholds))