| 11 | from torchvision import transforms |
| 12 | |
| 13 | class ConvBlock(torch.nn.Module): |
| 14 | def __init__(self,in_channels,out_channels,down=True,use_act=True,**kwargs): |
| 15 | super(ConvBlock, self).__init__() |
| 16 | self.conv = torch.nn.Sequential( |
| 17 | torch.nn.Conv2d(in_channels=in_channels,out_channels=out_channels,padding_mode='reflect',**kwargs) |
| 18 | if down |
| 19 | else torch.nn.ConvTranspose2d(in_channels=in_channels,out_channels=out_channels,**kwargs), |
| 20 | torch.nn.BatchNorm2d(num_features=out_channels), |
| 21 | torch.nn.ReLU(inplace=True) if use_act else torch.nn.Identity() |
| 22 | ) |
| 23 | def forward(self,x): |
| 24 | return self.conv(x) |
| 25 | |
| 26 | class ResidualBlock(torch.nn.Module): |
| 27 | def __init__(self,channels): |