fix missing resisidual for highest resolution of the unet

This commit is contained in:
Phil Wang
2022-06-15 18:01:12 -07:00
parent b4c3e5b854
commit 6647050c33
2 changed files with 8 additions and 3 deletions

View File

@@ -1489,8 +1489,10 @@ class Unet(nn.Module):
Upsample(dim_in)
]))
final_dim_in = dim * (1 if memory_efficient else 2)
self.final_conv = nn.Sequential(
ResnetBlock(dim, dim, groups = resnet_groups[0]),
ResnetBlock(final_dim_in, dim, groups = resnet_groups[0]),
nn.Conv2d(dim, self.channels_out, 1)
)
@@ -1682,7 +1684,7 @@ class Unet(nn.Module):
x = self.mid_block2(x, mid_c, t)
for init_block, sparse_attn, resnet_blocks, upsample in self.ups:
x = torch.cat((x, hiddens.pop()), dim=1)
x = torch.cat((x, hiddens.pop()), dim = 1)
x = init_block(x, c, t)
x = sparse_attn(x)
@@ -1691,6 +1693,9 @@ class Unet(nn.Module):
x = upsample(x)
if len(hiddens) > 0:
x = torch.cat((x, hiddens.pop()), dim = 1)
return self.final_conv(x)
class LowresConditioner(nn.Module):