Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

Fix VAEEncodeForInpaint to support WAN VAE tuple downscale_ratio (#11572)

rattus6207f86c18d2
diff --git a/nodes.py b/nodes.py
index 56b74ebe3..1aa391f4a 100644
--- a/nodes.py
+++ b/nodes.py
@@ -378,14 +378,15 @@ class VAEEncodeForInpaint:
CATEGORY = "latent/inpaint"
def encode(self, vae, pixels, mask, grow_mask_by=6):
- x = (pixels.shape[1] // vae.downscale_ratio) * vae.downscale_ratio
- y = (pixels.shape[2] // vae.downscale_ratio) * vae.downscale_ratio
+ downscale_ratio = vae.spacial_compression_encode()
+ x = (pixels.shape[1] // downscale_ratio) * downscale_ratio
+ y = (pixels.shape[2] // downscale_ratio) * downscale_ratio
mask = torch.nn.functional.interpolate(mask.reshape((-1, 1, mask.shape[-2], mask.shape[-1])), size=(pixels.shape[1], pixels.shape[2]), mode="bilinear")
pixels = pixels.clone()
if pixels.shape[1] != x or pixels.shape[2] != y:
- x_offset = (pixels.shape[1] % vae.downscale_ratio) // 2
- y_offset = (pixels.shape[2] % vae.downscale_ratio) // 2
+ x_offset = (pixels.shape[1] % downscale_ratio) // 2
+ y_offset = (pixels.shape[2] % downscale_ratio) // 2
pixels = pixels[:,x_offset:x + x_offset, y_offset:y + y_offset,:]
mask = mask[:,:,x_offset:x + x_offset, y_offset:y + y_offset]