nn.PixelShuffle(2), nn.Conv2d(G, args.n_colors, kSize, padding=(kSize - 1) // 2, stride=1) ]) else: raise ValueError("scale must be 2 or 3 or 4.") def forward(self, x): f__1 = self.SFENet1(x) x = self.SFENet2(f__1) RDBs_out = [] for i in range(self.D): x = self.RDBs[i](x) RDBs_out.append(x) x = self.GFF(torch.cat(RDBs_out, 1)) x += f__1 return self.UPNet(x) if __name__ == '__main__': from help_func.my_torchsummary import summary from option import args model = RDN(args) summary(model, (3, 192, 192))
# global feature fusion self.gff = nn.Sequential( nn.Conv2d(self.G * self.D, self.G0, kernel_size=1), nn.Conv2d(self.G0, self.G0, kernel_size=3, padding=3 // 2)) self.output = nn.Conv2d(self.G0, output_num_channels, kernel_size=3, padding=3 // 2) def forward(self, x): sfe1 = self.sfe1(x) sfe2 = self.sfe2(sfe1) x = sfe2 local_features = [] for i in range(self.D): x = self.rdbs[i](x) local_features.append(x) x = self.gff(torch.cat(local_features, 1)) + sfe1 # global residual learning x = self.output(x) return x if __name__ == '__main__': from help_func.my_torchsummary import summary net = RDN(input_num_channels=3, output_num_channels=3) summary(net, (3, 64, 64), device='cpu')
2, stride=1), nn.PixelShuffle(2), nn.Conv2d(G, G * 4, kSize, padding=(kSize - 1) // 2, stride=1), nn.PixelShuffle(2), nn.Conv2d(G, 3, kSize, padding=(kSize - 1) // 2, stride=1) ]) else: raise ValueError("scale must be 2 or 3 or 4.") def forward(self, x): _x = self.SFENet1_input4(x) _x = self.SFENet2(_x) RDBs_out = [] for i in range(self.D): _x = self.RDBs[i](_x) RDBs_out.append(_x) _x = self.GFF(torch.cat(RDBs_out, 1)) # x += f__1 return self.UPNet(_x) + x[:, :3, ...] if __name__ == '__main__': from help_func.my_torchsummary import summary from option import args model = RDN(args) summary(model, (4, 64, 64))