Example #1
0
    def __init__(self, cfg):
        super(RPNModule, self).__init__()

        self.cfg = cfg.clone()

        anchor_generator = make_anchor_generator(cfg)

        in_channels = cfg.MODEL.BACKBONE.OUT_CHANNELS
        rpn_head = registry.RPN_HEADS[cfg.MODEL.RPN.RPN_HEAD]
        head = rpn_head(cfg, in_channels,
                        anchor_generator.num_anchors_per_location())

        rpn_box_coder = BoxCoder3D()

        box_selector_train = make_rpn_postprocessor(cfg,
                                                    rpn_box_coder,
                                                    is_train=True)
        box_selector_test = make_rpn_postprocessor(cfg,
                                                   rpn_box_coder,
                                                   is_train=False)
        loss_evaluator = make_rpn_loss_evaluator(cfg, rpn_box_coder)
        self.seperate_classifier = SeperateClassifier(
            cfg.MODEL.SEPARATE_CLASSES_ID, len(cfg.INPUT.CLASSES))

        self.box_coder = rpn_box_coder
        self.anchor_generator = anchor_generator
        self.head = head
        self.box_selector_train = box_selector_train
        self.box_selector_test = box_selector_test
        self.loss_evaluator = loss_evaluator
        self.add_gt_proposals = cfg.MODEL.RPN.ADD_GT_PROPOSALS
    def __init__(self, cfg):
        super(RPNModule, self).__init__()

        self.cfg = cfg.clone()

        anchor_generator = make_anchor_generator(cfg)

        in_channels = cfg.SPARSE3D.nPlaneMap
        rpn_head = registry.RPN_HEADS[cfg.MODEL.RPN.RPN_HEAD]
        head = rpn_head(cfg, in_channels,
                        anchor_generator.num_anchors_per_location())

        rpn_box_coder = BoxCoder3D(is_corner_roi=False, weights=None)

        box_selector_train = make_rpn_postprocessor(cfg,
                                                    rpn_box_coder,
                                                    is_train=True)
        box_selector_test = make_rpn_postprocessor(cfg,
                                                   rpn_box_coder,
                                                   is_train=False)
        loss_evaluator = make_rpn_loss_evaluator(cfg, rpn_box_coder)
        class_specific = cfg.MODEL.CLASS_SPECIFIC
        self.seperate_classifier = SeperateClassifier(
            cfg.MODEL.SEPARATE_CLASSES_ID, len(cfg.INPUT.CLASSES),
            class_specific, 'RPN')

        self.box_coder = rpn_box_coder
        self.anchor_generator = anchor_generator
        self.head = head
        self.box_selector_train = box_selector_train
        self.box_selector_test = box_selector_test
        self.loss_evaluator = loss_evaluator
        self.add_gt_proposals = cfg.MODEL.RPN.ADD_GT_PROPOSALS
Example #3
0
def make_roi_box_post_processor(cfg):
    use_fpn = cfg.MODEL.ROI_HEADS.USE_FPN

    bbox_reg_weights = cfg.MODEL.ROI_HEADS.BBOX_REG_WEIGHTS
    box_coder = BoxCoder3D(weights=bbox_reg_weights)

    score_thresh = cfg.MODEL.ROI_HEADS.SCORE_THRESH
    nms_thresh = cfg.MODEL.ROI_HEADS.NMS
    nms_aug_thickness = cfg.MODEL.ROI_HEADS.NMS_AUG_THICKNESS_Y_Z
    detections_per_img = cfg.MODEL.ROI_HEADS.DETECTIONS_PER_IMG

    postprocessor = PostProcessor(score_thresh,
                                  nms_thresh,
                                  nms_aug_thickness=nms_aug_thickness,
                                  detections_per_img=detections_per_img,
                                  box_coder=box_coder)
    return postprocessor
Example #4
0
def make_roi_box_loss_evaluator(cfg):
    matcher = Matcher(
        cfg.MODEL.ROI_HEADS.FG_IOU_THRESHOLD,
        cfg.MODEL.ROI_HEADS.BG_IOU_THRESHOLD,
        allow_low_quality_matches=False,
    )

    bbox_reg_weights = cfg.MODEL.ROI_HEADS.BBOX_REG_WEIGHTS
    box_coder = BoxCoder3D(is_corner_roi=cfg.MODEL.CORNER_ROI,
                           weights=bbox_reg_weights)

    fg_bg_sampler = BalancedPositiveNegativeSampler(
        cfg.MODEL.ROI_HEADS.BATCH_SIZE_PER_IMAGE,
        cfg.MODEL.ROI_HEADS.POSITIVE_FRACTION)
    yaw_loss_mode = cfg.MODEL.LOSS.YAW_MODE
    add_gt_proposals = cfg.MODEL.RPN.ADD_GT_PROPOSALS
    ay = cfg.MODEL.ROI_HEADS.LABEL_AUG_THICKNESS_Y_TAR_ANC
    az = cfg.MODEL.ROI_HEADS.LABEL_AUG_THICKNESS_Z_TAR_ANC
    aug_thickness = {
        'target_Y': ay[0],
        'anchor_Y': ay[1],
        'target_Z': az[0],
        'anchor_Z': az[1]
    }
    in_classes = cfg.INPUT.CLASSES
    num_input_classes = len(in_classes)

    seperate_classes = cfg.MODEL.SEPARATE_CLASSES_ID
    class_specific = cfg.MODEL.CLASS_SPECIFIC
    seperate_classifier = SeperateClassifier(seperate_classes,
                                             num_input_classes, class_specific,
                                             'ROI_LOSS')

    loss_evaluator = FastRCNNLossComputation(matcher,
                                             fg_bg_sampler,
                                             box_coder,
                                             yaw_loss_mode,
                                             add_gt_proposals,
                                             aug_thickness,
                                             seperate_classifier,
                                             class_specific=class_specific)

    return loss_evaluator, seperate_classifier
Example #5
0
 def __init__(self,
              score_thresh=0.05,
              nms=0.5,
              nms_aug_thickness=None,
              detections_per_img=100,
              box_coder=None):
     """
     Arguments:
         score_thresh (float)
         nms (float)
         detections_per_img (int)
         box_coder (BoxCoder3D)
     """
     super(PostProcessor, self).__init__()
     self.score_thresh = score_thresh
     self.nms = nms
     self.detections_per_img = detections_per_img
     if box_coder is None:
         box_coder = BoxCoder3D(weights=(10., 10., 5., 5.))
     self.box_coder = box_coder
     self.nms_aug_thickness = nms_aug_thickness