(self, in_size, out_size, in_channels, out_channels, ch_mult=2)
| 996 | |
| 997 | class Upsampler(nn.Module): |
| 998 | def __init__(self, in_size, out_size, in_channels, out_channels, ch_mult=2): |
| 999 | super().__init__() |
| 1000 | assert out_size >= in_size |
| 1001 | num_blocks = int(np.log2(out_size//in_size))+1 |
| 1002 | factor_up = 1.+ (out_size % in_size) |
| 1003 | print(f"Building {self.__class__.__name__} with in_size: {in_size} --> out_size {out_size} and factor {factor_up}") |
| 1004 | self.rescaler = LatentRescaler(factor=factor_up, in_channels=in_channels, mid_channels=2*in_channels, |
| 1005 | out_channels=in_channels) |
| 1006 | self.decoder = Decoder(out_ch=out_channels, resolution=out_size, z_channels=in_channels, num_res_blocks=2, |
| 1007 | attn_resolutions=[], in_channels=None, ch=in_channels, |
| 1008 | ch_mult=[ch_mult for _ in range(num_blocks)]) |
| 1009 | |
| 1010 | def forward(self, x): |
| 1011 | x = self.rescaler(x) |
nothing calls this directly
no test coverage detected