コード例 #1
0
    def __init__(self,
                 num_classes,
                 mode="training",
                 feat_stride=16,
                 anchor_scales=[8, 16, 32],
                 ratios=[0.5, 1, 2],
                 backbone='vgg'):
        super(FasterRCNN, self).__init__()
        self.feat_stride = feat_stride
        if backbone == 'vgg':
            self.extractor, classifier = decom_vgg16()

            self.rpn = RegionProposalNetwork(512,
                                             512,
                                             ratios=ratios,
                                             anchor_scales=anchor_scales,
                                             feat_stride=self.feat_stride,
                                             mode=mode)
            self.head = VGG16RoIHead(n_class=num_classes + 1,
                                     roi_size=7,
                                     spatial_scale=1,
                                     classifier=classifier)
        elif backbone == 'resnet50':
            self.extractor, classifier = resnet50()

            self.rpn = RegionProposalNetwork(1024,
                                             512,
                                             ratios=ratios,
                                             anchor_scales=anchor_scales,
                                             feat_stride=self.feat_stride,
                                             mode=mode)
            self.head = Resnet50RoIHead(n_class=num_classes + 1,
                                        roi_size=14,
                                        spatial_scale=1,
                                        classifier=classifier)
コード例 #2
0
 def __init__(self, num_classes = 20, pretrain = False):
     super(CenterNet_Resnet50, self).__init__()
     # 512,512,3 -> 16,16,2048
     self.backbone = resnet50(pretrain=pretrain)
     # 16,16,2048 -> 128,128,64
     self.decoder = resnet50_Decoder(2048)
     #-----------------------------------------------------------------#
     #   对获取到的特征进行上采样,进行分类预测和回归预测
     #   128, 128, 64 -> 128, 128, 64 -> 128, 128, num_classes
     #                -> 128, 128, 64 -> 128, 128, 2
     #                -> 128, 128, 64 -> 128, 128, 2
     #-----------------------------------------------------------------#
     self.head = resnet50_Head(channel=64, num_classes=num_classes)
コード例 #3
0
    def __init__(self,
                 num_classes,
                 mode="training",
                 loc_normalize_mean=(0., 0., 0., 0.),
                 loc_normalize_std=(0.1, 0.1, 0.2, 0.2),
                 feat_stride=16,
                 anchor_scales=[8, 16, 32],
                 ratios=[0.5, 1, 2],
                 backbone='vgg'):
        super(FasterRCNN, self).__init__()

        self.loc_normalize_mean = loc_normalize_mean
        self.loc_normalize_std = loc_normalize_std
        self.feat_stride = feat_stride
        if backbone == 'vgg':
            self.extractor, self.classifier = decom_vgg16()
            self.rpn = RegionProposalNetwork(512,
                                             512,
                                             ratios=ratios,
                                             anchor_scales=anchor_scales,
                                             feat_stride=self.feat_stride,
                                             mode=mode)
            self.head = VGG16RoIHead(n_class=num_classes + 1,
                                     roi_size=7,
                                     spatial_scale=(1. / self.feat_stride),
                                     classifier=self.classifier)
        elif backbone == 'resnet50':
            self.extractor, self.classifier = resnet50()
            # 完成RPN的3×3、两个1×1卷积、Proposal,返回 输出结果为 rpn_locs, rpn_scores, rois, roi_indices, anchor
            # 其中rois为从先验框rpn_locs中选出的得分较高的候选框
            self.rpn = RegionProposalNetwork(1024,
                                             512,
                                             ratios=ratios,
                                             anchor_scales=anchor_scales,
                                             feat_stride=self.feat_stride,
                                             mode=mode)

            self.head = Resnet50RoIHead(n_class=num_classes + 1,
                                        roi_size=14,
                                        spatial_scale=(1. / self.feat_stride),
                                        classifier=self.classifier)
コード例 #4
0
ファイル: frcnn.py プロジェクト: ccl-1/faster_rcnn_pytorch
 def __init__(self,num_classes,
             mode='training',
             loc_normalize_mean=(0.,0.,0.,0.),
             loc_normalize_std=(0.1,0.1,0.2,0.2),
             feat_stride=16,
             anchor_scales=[8, 16, 32],
             rotios = [0.5, 1, 2],
             backbone='vgg'):
     super(FasterRCNN,self).__init__()
     
     self.loc_normalize_mean = loc_normalize_mean
     self.loc_normalize_std = loc_normalize_std
     self.feat_stride = feat_stride
     
     if backbone == 'vgg' :
         self.extractor,classifier = decom_vgg16()
         self.rpn = RegionProposalNetwork(512,512, 
                                         ratios = rotios,
                                         anchor_scales = anchor_scales,
                                         feat_stride=feat_stride,
                                         mode=mode)
         self.head = VGG16RoIHead(n_class=num_classes+1,
                                 roi_size=7,
                                 spatial_scale=(1. / self.feat_stride),
                                 classifier=classifier)
     elif backbone == 'resnet50':
         self.extractor,classifier = resnet50()
         self.rpn = RegionProposalNetwork(1024,512,
                                         ratios=rotios,
                                         anchor_scales = anchor_scales,
                                         feat_stride=feat_stride,
                                         mode=mode)
         self.head = Resnet50RoIHead(n_class=num_classes+1,
                                     roi_size=14,
                                     spatial_scale=(1. / self.feat_stride),
                                     classifier=classifier)
コード例 #5
0
ファイル: centernet.py プロジェクト: zy9957/centernet-pytorch
 def __init__(self, num_classes=20, pretrain=False):
     super(CenterNet_Resnet50, self).__init__()
     self.backbone = resnet50(pretrain=pretrain)
     self.decoder = resnet50_Decoder(2048)
     self.head = resnet50_Head(channel=64, num_classes=num_classes)