Example #1
0
    def __init__(self, classes, class_agnostic):
        super(_RFCN, self).__init__()
        self.classes = classes
        self.n_classes = len(classes)
        self.n_reg_classes = (1 if class_agnostic else len(classes))
        self.class_agnostic = class_agnostic
        self.n_bbox_reg = (4 if class_agnostic else len(classes))
        # loss
        self.RFCN_loss_cls = 0
        self.RFCN_loss_bbox = 0

        # define rpn
        self.RFCN_rpn = _RPN(self.dout_base_model)
        self.RFCN_proposal_target = _ProposalTargetLayer(self.n_classes)
        self.RFCN_psroi_cls_pool = _PSRoIPooling(cfg.POOLING_SIZE,
                                                 cfg.POOLING_SIZE,
                                                 spatial_scale=1.0 / 16.0,
                                                 group_size=7,
                                                 output_dim=self.n_classes)
        self.RFCN_psroi_loc_pool = _PSRoIPooling(cfg.POOLING_SIZE,
                                                 cfg.POOLING_SIZE,
                                                 spatial_scale=1.0 / 16.0,
                                                 group_size=7,
                                                 output_dim=4 *
                                                 self.n_reg_classes)

        self.grid_size = cfg.POOLING_SIZE * 2 if cfg.CROP_RESIZE_WITH_MAX_POOL else cfg.POOLING_SIZE

        self.RFCN_cls_net = nn.Conv2d(512,
                                      self.n_classes * 7 * 7, [1, 1],
                                      padding=0,
                                      stride=1)
        nn.init.normal(self.RFCN_cls_net.weight.data, 0.0, 0.01)

        self.RFCN_bbox_net = nn.Conv2d(512,
                                       4 * self.n_reg_classes * 7 * 7, [1, 1],
                                       padding=0,
                                       stride=1)
        nn.init.normal(self.RFCN_bbox_net.weight.data, 0.0, 0.01)

        self.RFCN_cls_score = nn.AvgPool2d((7, 7), stride=(7, 7))
        self.RFCN_bbox_pred = nn.AvgPool2d((7, 7), stride=(7, 7))
Example #2
0
 def __init__(self, output_dim, group_size, spatial_scale):
     super(test_PSRoIPooling, self).__init__()
     self.psroi_pool = _PSRoIPooling(output_dim, group_size, spatial_scale)
Example #3
0
    def __init__(self, classes, class_agnostic):
        super(_RFCN, self).__init__()
        self.classes = classes
        self.n_classes = len(classes)
        self.n_reg_classes = (1 if class_agnostic else len(classes))
        self.class_agnostic = class_agnostic
        self.n_bbox_reg = (4 if class_agnostic else len(classes))
        # loss
        self.RFCN_loss_cls = 0
        self.RFCN_loss_bbox = 0

        # define rpn
        self.RFCN_rpn = _RPN(self.dout_base_model)
        self.RFCN_proposal_target = _ProposalTargetLayer(self.n_classes)
        self.RFCN_tracking_proposal_target = _TrackingProposalTargetLayer(
            self.n_classes)
        #self.RFCN_roi_pool = _RoIPooling(cfg.POOLING_SIZE, cfg.POOLING_SIZE, 1.0/16.0)
        self.RFCN_psroi_cls_pool = _PSRoIPooling(cfg.POOLING_SIZE,
                                                 cfg.POOLING_SIZE,
                                                 spatial_scale=1.0 / 16.0,
                                                 group_size=7,
                                                 output_dim=self.n_classes)
        self.RFCN_psroi_loc_pool = _PSRoIPooling(cfg.POOLING_SIZE,
                                                 cfg.POOLING_SIZE,
                                                 spatial_scale=1.0 / 16.0,
                                                 group_size=7,
                                                 output_dim=4 *
                                                 self.n_reg_classes)
        #self.RFCN_roi_align = RoIAlignAvg(cfg.POOLING_SIZE, cfg.POOLING_SIZE, 1.0/16.0)

        self.grid_size = cfg.POOLING_SIZE * 2 if cfg.CROP_RESIZE_WITH_MAX_POOL else cfg.POOLING_SIZE
        #self.RFCN_roi_crop = _RoICrop()

        self.RFCN_cls_net = nn.Conv2d(512,
                                      self.n_classes * 7 * 7, [1, 1],
                                      padding=0,
                                      stride=1)
        nn.init.normal(self.RFCN_cls_net.weight.data, 0.0, 0.01)

        self.RFCN_bbox_net = nn.Conv2d(512,
                                       4 * self.n_reg_classes * 7 * 7, [1, 1],
                                       padding=0,
                                       stride=1)
        nn.init.normal(self.RFCN_bbox_net.weight.data, 0.0, 0.01)

        #self.corr_bbox_net = nn.Conv2d(1051, 4*self.n_reg_classes*7*7, [1,1], padding=0, stride=1)
        #nn.init.normal(self.corr_bbox_net.weight.data, 0.0, 0.01)

        self.conv3_corr_layer = Correlation(pad_size=8,
                                            kernel_size=1,
                                            max_displacement=8,
                                            stride1=2,
                                            stride2=2)
        self.conv4_corr_layer = Correlation(pad_size=8,
                                            kernel_size=1,
                                            max_displacement=8,
                                            stride1=1,
                                            stride2=1)
        self.conv5_corr_layer = Correlation(pad_size=8,
                                            kernel_size=1,
                                            max_displacement=8,
                                            stride1=1,
                                            stride2=1)

        self.RFCN_cls_score = nn.AvgPool2d((7, 7), stride=(7, 7))
        self.RFCN_bbox_pred = nn.AvgPool2d((7, 7), stride=(7, 7))
        self.RFCN_tracking_pred = nn.AvgPool2d((7, 7), stride=(7, 7))