easier to read
MODIFY
examples/stable_diffusion.py
examples/stable_diffusion.py
@@ -113,11 +113,11 @@ class Decoder:
x = x.reshape(bs, c, py, 1, px, 1).expand(bs, c, py, 2, px, 2).reshape(bs, c, py*2, px*2)
x = l['upsample']['conv'](x)
- return self.conv_out(self.norm_out(x).swish())
+ return x.sequential([self.norm_out, Tensor.swish, self.conv_out])
class Encoder:
- def __init__(self, decode=False):
+ def __init__(self):
sz = [(128, 128), (128, 256), (256, 512), (512, 512)]
self.conv_in = Conv2d(3,128,3, padding=1)
@@ -140,8 +140,7 @@ class Encoder:
for b in l['block']: x = b(x)
if 'downsample' in l: x = l['downsample']['conv'](x)
- x = self.mid(x)
- return self.conv_out(self.norm_out(x).swish())
+ return x.sequential([self.mid, self.norm_out, Tensor.swish, self.conv_out])
class AutoencoderKL:
def __init__(self):

easier to read