コード例 #1
0
def build_ssd(phase, model, size=300, cfg=None):
    if phase != "test" and phase != "train":
        print("ERROR: Phase: " + phase + " not recognized")
        return
    if size != 300 and size != 600 and size != 800:
        print("ERROR: You specified size " + repr(size) + ". However, " +
              "currently only SSD300 (size=300) is supported!")
        return
    print(phase)
    if model == 'resnet50':
        base = Backbone(model, [6, 7, 8, 9, 10, 11])
        neck = None
        #neck = Neck(in_channels = [512,1024,2048,512,256,256], out_channels = cfg['neck_out'])
        head = SSDHead(num_classes=cfg['num_classes'],
                       in_channels=[512, 1024, 2048, 512, 256, 256],
                       aspect_ratios=cfg['aspect_ratios'])
    else:
        base = Backbone(model, [6, 7, 8, 9, 10, 11])
        neck = None
        #neck = Neck(in_channels = [128,256,512,256,256], out_channels = cfg['neck_out'])
        head = SSDHead(num_classes=cfg['num_classes'],
                       in_channels=[128, 256, 512, 256, 256],
                       aspect_ratios=cfg['aspect_ratios'])

    return SSD(phase, size, base, neck, head, cfg)
コード例 #2
0
 def __init__(self, n_classes=80):
     super().__init__()
     output_ch = (5 + 1 + n_classes) * 3 * 6
     radian = np.pi / 180
     angles = [
         -radian * 60, -radian * 30, 0, radian * 30, radian * 60,
         radian * 90
     ]
     self.backbone = Backbone()
     self.neck = Neck()
     self.head = Head(output_ch)
     self.yolo1 = YoloLayer(num_classes=n_classes,
                            anchors=[[12, 16], [19, 36], [40, 28]],
                            angles=angles,
                            stride=8,
                            scale_x_y=1.2,
                            ignore_thresh=0.6)
     self.yolo2 = YoloLayer(num_classes=n_classes,
                            anchors=[[36, 75], [76, 55], [72, 146]],
                            angles=angles,
                            stride=16,
                            scale_x_y=1.1,
                            ignore_thresh=0.6)
     self.yolo3 = YoloLayer(num_classes=n_classes,
                            anchors=[[142, 110], [192, 243], [459, 401]],
                            angles=angles,
                            stride=32,
                            scale_x_y=1.05,
                            ignore_thresh=0.6)
コード例 #3
0
ファイル: model_test.py プロジェクト: 2017TJM/Yolov1.pytorch
 def setUpClass(self):
     self.backbone = Backbone().to(device)
     self.yolo_c_head = Yolo(head=ClassificationHead()).to(device)
     self.yolo_d_head = Yolo(
         DetectionHead(input_size=cfg.detection_head_input_size,
                       C=cfg.C,
                       B=cfg.B)).to(device)
     self.x = t.ones(1, 3, 448, 448).to(device)
コード例 #4
0
def build_ssd(phase, size=300, cfg=None):
    if phase != "test" and phase != "train":
        print("ERROR: Phase: " + phase + " not recognized")
        return
    if size != 300 and size != 600 and size != 800:
        print("ERROR: You specified size " + repr(size) + ". However, " +
              "currently only SSD300 (size=300) is supported!")
        return
    print(phase)
    base = Backbone(cfg['model'], [6, 7, 8, 9, 10, 11])
    #neck=None
    neck = Neck(in_channels=cfg['backbone_out'], out_channels=cfg['neck_out'])
    head = SSDHead(num_classes=cfg['num_classes'],
                   in_channels=cfg['neck_out'],
                   aspect_ratios=cfg['aspect_ratios'])

    return SSD(phase, size, base, neck, head, cfg)
コード例 #5
0
    def __init__(self,
                 vocab_size,
                 dataset_configs,
                 hidden_dim=512,
                 embed_dim=300,
                 bidirection=True,
                 graph_node_features=1024):
        super(mainModel, self).__init__()
        dataset_configs = vars(dataset_configs)
        self.first_output_dim = dataset_configs["first_output_dim"]
        self.fpn_feature_dim = dataset_configs["fpn_feature_dim"]
        self.feature_dim = dataset_configs[
            dataset_configs['feature_type']]['feature_dim']
        self.query_encoder = QueryEncoder(vocab_size, hidden_dim, embed_dim,
                                          dataset_configs["lstm_layers"],
                                          bidirection)

        channels_list = [
            (self.feature_dim + 256, self.first_output_dim, 3, 1),
            (self.first_output_dim, self.first_output_dim * 2, 3, 2),
            ((self.first_output_dim * 2), self.first_output_dim * 4, 3, 2),
        ]
        conv_func = conv_with_kaiming_uniform(use_bn=True, use_relu=True)
        self.backbone_net = Backbone(channels_list, conv_func)
        self.fpn = FPN([256, 512, 1024], 512, conv_func)
        self.fcos = build_fcos(dataset_configs, self.fpn_feature_dim)
        # self.query_fc = nn.Linear(1024, self.feature_dim)
        self.prop_fc = nn.Linear(self.feature_dim, self.feature_dim)
        self.position_transform = nn.Linear(3, 256)

        for t in range(len(channels_list)):
            if t > 0:
                setattr(self, "qInput%d" % t,
                        nn.Linear(1024, channels_list[t - 1][1]))
            else:
                setattr(self, "qInput%d" % t,
                        nn.Linear(1024, self.feature_dim))
コード例 #6
0
 def __init__(self, head):
     super(Yolo, self).__init__()
     self.head = head
     self.backbone = Backbone()