def __init__(self, anchor, match_threshold=0.5, unmatched_threshold=0.5): """Constructs anchor labeler to assign labels to anchors. Args: anchor: an instance of class Anchors. match_threshold: a float number between 0 and 1 representing the lower-bound threshold to assign positive labels for anchors. An anchor with a score over the threshold is labeled positive. unmatched_threshold: a float number between 0 and 1 representing the upper-bound threshold to assign negative labels for anchors. An anchor with a score below the threshold is labeled negative. """ similarity_calc = iou_similarity.IouSimilarity() matcher = argmax_matcher.ArgMaxMatcher( match_threshold, unmatched_threshold=unmatched_threshold, negatives_lower_than_unmatched=True, force_match_for_each_row=True) box_coder = faster_rcnn_box_coder.FasterRcnnBoxCoder() self._target_assigner = target_assigner.TargetAssigner( similarity_calc, matcher, box_coder) self._anchor = anchor self._match_threshold = match_threshold self._unmatched_threshold = unmatched_threshold
def __init__(self, match_threshold=0.5, unmatched_threshold=0.5): """Constructs anchor labeler to assign labels to anchors. Args: match_threshold: a float number between 0 and 1 representing the lower-bound threshold to assign positive labels for anchors. An anchor with a score over the threshold is labeled positive. unmatched_threshold: a float number between 0 and 1 representing the upper-bound threshold to assign negative labels for anchors. An anchor with a score below the threshold is labeled negative. """ self.similarity_calc = iou_similarity.IouSimilarity() self.target_gather = target_gather.TargetGather() self.matcher = box_matcher.BoxMatcher( thresholds=[unmatched_threshold, match_threshold], indicators=[-1, -2, 1], force_match_for_each_col=True) self.box_coder = faster_rcnn_box_coder.FasterRcnnBoxCoder()
def __init__(self, anchor, match_threshold=0.7, unmatched_threshold=0.3, rpn_batch_size_per_im=256, rpn_fg_fraction=0.5, has_centerness=False, center_match_iou_threshold=0.3, center_unmatched_iou_threshold=0.1, num_center_samples_per_im=256): """Constructs rpn anchor labeler to assign labels and centerness to anchors. Args: anchor: an instance of class Anchors. match_threshold: a float number between 0 and 1 representing the lower-bound threshold to assign positive labels for anchors. An anchor with a score over the threshold is labeled positive. unmatched_threshold: a float number between 0 and 1 representing the upper-bound threshold to assign negative labels for anchors. An anchor with a score below the threshold is labeled negative. rpn_batch_size_per_im: number of anchors that are sampled per image. rpn_fg_fraction: has_centerness: whether to include centerness target creation. An anchor is paired with one centerness score. center_match_iou_threshold: a float number between 0 and 1 representing the lower-bound threshold to sample foreground anchors for centerness regression. An anchor with a score over the threshold is sampled as foreground sample for centerness regression. We sample mostly from the foreground region (255 out of 256 samples). That is, we sample 255 vs 1 (foreground vs background) anchor points to learn centerness regression. center_unmatched_iou_threshold: a float number between 0 and 1 representing the lower-bound threshold to sample background anchors for centerness regression. An anchor with a score over the threshold is sampled as foreground sample for centerness regression. We sample very sparsely from the background region (1 out of 256 samples). That is, we sample 255 vs 1 (foreground vs background) anchor points to learn centerness regression. num_center_samples_per_im: number of anchor points per image that are sampled as centerness targets. """ super(OlnAnchorLabeler, self).__init__(anchor, match_threshold=match_threshold, unmatched_threshold=unmatched_threshold, rpn_batch_size_per_im=rpn_batch_size_per_im, rpn_fg_fraction=rpn_fg_fraction) similarity_calc = iou_similarity.IouSimilarity() matcher = argmax_matcher.ArgMaxMatcher( match_threshold, unmatched_threshold=unmatched_threshold, negatives_lower_than_unmatched=True, force_match_for_each_row=True) box_coder = faster_rcnn_box_coder.FasterRcnnBoxCoder() if has_centerness: center_matcher = argmax_matcher.ArgMaxMatcher( center_match_iou_threshold, unmatched_threshold=center_match_iou_threshold, negatives_lower_than_unmatched=True, force_match_for_each_row=True, ) else: center_matcher = None self._target_assigner = target_assigner.OlnTargetAssigner( similarity_calc, matcher, box_coder, center_matcher=center_matcher) self._num_center_samples_per_im = num_center_samples_per_im self._center_unmatched_iou_threshold = center_unmatched_iou_threshold self._rpn_batch_size_per_im = rpn_batch_size_per_im self._rpn_fg_fraction = rpn_fg_fraction