예제 #1
0
 def __init__(self, num_classes):
     super(UNet, self).__init__()
     self.backbone = mobilenet_v2(pretrained=True)
     self.up_convs = nn.ModuleList([
         ConvNormAct(1280, 256),
         ConvNormAct(352, 128),
         ConvNormAct(160, 64)
     ])
     self.cls_conv = nn.Conv2d(88, num_classes, 3, padding=1)
     initialize_weights(self.up_convs)
     initialize_weights(self.cls_conv)
예제 #2
0
 def __init__(self, num_classes):
     super(UNet, self).__init__()
     self.stages = resnet34(
         pretrained=True, replace_stride_with_dilation=[False, False,
                                                        True]).stages
     self.up_convs = nn.ModuleList([
         ConvNormAct(512, 128),
         ConvNormAct(256, 64),
         ConvNormAct(128, 64)
     ])
     self.cls_conv = nn.Conv2d(128, num_classes, 3, padding=1)
     initialize_weights(self.up_convs)
     initialize_weights(self.cls_conv)
예제 #3
0
 def __init__(
         self,
         num_classes,
         img_size=(416, 416),
         anchors=[
             [[116, 90], [156, 198], [373, 326]],
             [[30, 61], [62, 45], [59, 119]],
             [[10, 13], [16, 30], [33, 23]],
         ]):
     super(YOLOV3, self).__init__()
     self.backbone = mobilenet_v2(pretrained=True)
     depth = 5
     width = [512, 256, 128]
     planes_list = [1280, 96, 32]
     self.spp = nn.Sequential(ConvNormAct(1280, 320, 1, activate=nn.ReLU(True)), SPP())
     self.fpn = FPN(planes_list, width, depth)
     self.head = nn.ModuleList([])
     self.yolo_layers = nn.ModuleList([])
     for i in range(3):
         self.head.append(
             nn.Sequential(
                 SeparableConvNormAct(width[i],
                                      width[i],
                                      activate=nn.ReLU(True)),
                 nn.Conv2d(width[i],
                           len(anchors[i]) * (6 + num_classes), 1),
             ))
         self.yolo_layers.append(
             YOLOLayer(
                 anchors=np.float32(anchors[i]),
                 nc=num_classes,
                 img_size=img_size,
                 yolo_index=i,
             ))
     initialize_weights(self.fpn)
     initialize_weights(self.head)
예제 #4
0
 def __init__(self, num_classes):
     super(DeepLabV3Plus, self).__init__()
     self.backbone = resnet50(
         pretrained=True, replace_stride_with_dilation=[False, False, True])
     self.project = ConvNormAct(256, 128, 1)
     self.aspp = ASPP(2048, 256, [6, 12, 18])
     self.cls_conv = nn.Conv2d(384, num_classes, 3, padding=1)
     # init weight and bias
     initialize_weights(self.aspp)
     initialize_weights(self.project)
     initialize_weights(self.cls_conv)