Skip to content

Commit bdeb1c1

Browse files
Fast previews for mochi.
1 parent 9c1ed58 commit bdeb1c1

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

comfy/latent_formats.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,21 @@ def __init__(self):
190190
0.9294154431013696, 1.3720942357788521, 0.881393668867029,
191191
0.9168315692124348, 0.9185249279345552, 0.9274757570805041]).view(1, self.latent_channels, 1, 1, 1)
192192

193-
self.latent_rgb_factors = None #TODO
193+
self.latent_rgb_factors =[
194+
[-0.0069, -0.0045, 0.0018],
195+
[ 0.0154, -0.0692, -0.0274],
196+
[ 0.0333, 0.0019, 0.0206],
197+
[-0.1390, 0.0628, 0.1678],
198+
[-0.0725, 0.0134, -0.1898],
199+
[ 0.0074, -0.0270, -0.0209],
200+
[-0.0176, -0.0277, -0.0221],
201+
[ 0.5294, 0.5204, 0.3852],
202+
[-0.0326, -0.0446, -0.0143],
203+
[-0.0659, 0.0153, -0.0153],
204+
[ 0.0185, -0.0217, 0.0014],
205+
[-0.0396, -0.0495, -0.0281]
206+
]
207+
self.latent_rgb_factors_bias = [-0.0940, -0.1418, -0.1453]
194208
self.taesd_decoder_name = None #TODO
195209

196210
def process_in(self, latent):

latent_preview.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ def decode_latent_to_preview(self, x0):
4747
if self.latent_rgb_factors_bias is not None:
4848
self.latent_rgb_factors_bias = self.latent_rgb_factors_bias.to(dtype=x0.dtype, device=x0.device)
4949

50-
latent_image = torch.nn.functional.linear(x0[0].permute(1, 2, 0), self.latent_rgb_factors, bias=self.latent_rgb_factors_bias)
50+
if x0.ndim == 5:
51+
x0 = x0[0, :, 0]
52+
else:
53+
x0 = x0[0]
54+
55+
latent_image = torch.nn.functional.linear(x0.movedim(0, -1), self.latent_rgb_factors, bias=self.latent_rgb_factors_bias)
5156
# latent_image = x0[0].permute(1, 2, 0) @ self.latent_rgb_factors
5257

5358
return preview_to_image(latent_image)

0 commit comments

Comments
 (0)