Ejemplo n.º 1
0
    def __init__(self):
        super(Branch2, self).__init__()
        self.conv_input = nn.Conv2d(in_channels=64,
                                    out_channels=64,
                                    kernel_size=3,
                                    stride=1,
                                    padding=1,
                                    bias=False)
        # self.conv_input2 = nn.Conv2d(in_channels=64, out_channels=64, kernel_size=3, stride=1, padding=1, bias=False)
        self.relu = nn.PReLU()
        self.convt_F11 = CARB(64)
        self.convt_F12 = CARB(64)
        self.convt_F13 = CARB(64)
        # style encode
        self.s_conv1 = nn.Conv2d(in_channels=64,
                                 out_channels=64,
                                 kernel_size=3,
                                 stride=1,
                                 padding=1,
                                 bias=False)
        self.s_conv2 = nn.Conv2d(in_channels=64,
                                 out_channels=64,
                                 kernel_size=3,
                                 stride=2,
                                 padding=1,
                                 bias=False)
        self.s_conv3 = nn.Conv2d(in_channels=64,
                                 out_channels=64,
                                 kernel_size=3,
                                 stride=2,
                                 padding=1,
                                 bias=False)
        #-------------
        self.u1 = upsample_block(64, 256)
        self.convt_shape1 = nn.Conv2d(in_channels=64,
                                      out_channels=3,
                                      kernel_size=3,
                                      stride=1,
                                      padding=1,
                                      bias=False)

        for m in self.modules():
            if isinstance(m, nn.Conv2d):
                n = m.kernel_size[0] * m.kernel_size[1] * m.out_channels
                m.weight.data.normal_(0, math.sqrt(2. / n))
                if m.bias is not None:
                    m.bias.data.zero_()
Ejemplo n.º 2
0
 def __init__(self):
     super(Branch6, self).__init__()
     self.conv_input = nn.Conv2d(in_channels=64,
                                 out_channels=64,
                                 kernel_size=3,
                                 stride=1,
                                 padding=1,
                                 bias=False)
     # self.conv_input2 = nn.Conv2d(in_channels=64, out_channels=64, kernel_size=3, stride=1, padding=1, bias=False)
     self.relu = nn.PReLU()
     self.convt_F11 = CARB(64)
     self.convt_F12 = CARB(64)
     self.convt_F13 = CARB(64)
     self.convt_F14 = CARB(64)
     self.convt_F15 = CARB(64)
     self.convt_F16 = CARB(64)
     self.convt_F17 = CARB(64)
     self.convt_F18 = CARB(64)
     self.s_conv1 = nn.Conv2d(in_channels=64,
                              out_channels=64,
                              kernel_size=3,
                              stride=1,
                              padding=1,
                              bias=False)
     self.s_conv2 = nn.Conv2d(in_channels=64,
                              out_channels=64,
                              kernel_size=3,
                              stride=2,
                              padding=1,
                              bias=False)
     self.s_conv3 = nn.Conv2d(in_channels=64,
                              out_channels=64,
                              kernel_size=3,
                              stride=1,
                              padding=1,
                              bias=False)
     self.s_conv4 = nn.Conv2d(in_channels=64,
                              out_channels=64,
                              kernel_size=3,
                              stride=2,
                              padding=1,
                              bias=False)
     self.s_conv5 = nn.Conv2d(in_channels=64,
                              out_channels=64,
                              kernel_size=3,
                              stride=1,
                              padding=1,
                              bias=False)
     self.s_conv6 = nn.Conv2d(in_channels=64,
                              out_channels=64,
                              kernel_size=3,
                              stride=2,
                              padding=1,
                              bias=False)
     self.s_conv7 = nn.Conv2d(in_channels=64,
                              out_channels=64,
                              kernel_size=3,
                              stride=1,
                              padding=1,
                              bias=False)
     self.s_conv8 = nn.Conv2d(in_channels=64,
                              out_channels=64,
                              kernel_size=3,
                              stride=2,
                              padding=1,
                              bias=False)
     self.u1 = upsample_block(64, 256)
     self.u2 = upsample_block(64, 256)
     self.u3 = upsample_block(64, 256)
     self.u4 = upsample_block(64, 256)
     self.u5 = upsample_block(64, 256)
     self.convt_shape1 = nn.Conv2d(in_channels=64,
                                   out_channels=3,
                                   kernel_size=3,
                                   stride=1,
                                   padding=1,
                                   bias=False)
     self.non_local = Nonlocal_CA(in_feat=64,
                                  inter_feat=64 // 8,
                                  reduction=8,
                                  sub_sample=False,
                                  bn_layer=False)
     for m in self.modules():
         if isinstance(m, nn.Conv2d):
             n = m.kernel_size[0] * m.kernel_size[1] * m.out_channels
             m.weight.data.normal_(0, math.sqrt(2. / n))
             if m.bias is not None:
                 m.bias.data.zero_()