def match_targets_to_proposals(self, proposal, target): match_quality_matrix = boxlist_iou(target, proposal) if len(proposal) == 0: return target[[]] matched_idxs = self.proposal_matcher(match_quality_matrix) target = target.copy_with_fields(["box3d", "calib"]) matched_targets = target[matched_idxs.clamp(min=0)] matched_targets.add_field("matched_idxs", matched_idxs) return matched_targets
def match_targets_to_proposals(self, proposal, target, copy_fields=[]): match_quality_matrix = boxlist_iou(target, proposal) matched_idxs = self.proposal_matcher(match_quality_matrix) # Fast RCNN only need "labels" field for selecting the targets target = target.copy_with_fields(["labels"] + copy_fields) # get the targets corresponding GT for each proposal # NB: need to clamp the indices because we can have a single # GT in the image, and matched_idxs can be -2, which goes # out of bounds matched_targets = target[matched_idxs.clamp(min=0)] matched_targets.add_field("matched_idxs", matched_idxs) return matched_targets
def align_left_right_targets(left_targets, right_targets, thresh=0.2): iou_matrix = boxlist_iou(left_targets, right_targets) if iou_matrix.numel() > 0: max_ious, max_iou_idxs = iou_matrix.max(dim=1) high_quality = max_ious >= thresh matched_idxs = max_iou_idxs[high_quality] matched_right_targets = right_targets[matched_idxs] matched_left_targets = left_targets[high_quality] else: matched_left_targets = left_targets[[]] matched_right_targets = right_targets[[]] return matched_left_targets, matched_right_targets
def match_targets_to_anchors(self, anchor, target, copied_fields=[]): match_quality_matrix = boxlist_iou(target, anchor) matched_idxs = self.proposal_matcher(match_quality_matrix) # RPN doesn't need any fields from target # for creating the labels, so clear them all target = target.copy_with_fields(copied_fields) # get the targets corresponding GT for each anchor # NB: need to clamp the indices because we can have a single # GT in the image, and matched_idxs can be -2, which goes # out of bounds matched_targets = target[matched_idxs.clamp(min=0)] matched_targets.add_field("matched_idxs", matched_idxs) return matched_targets