Skip to content

Conversation

@ChrisFab16
Copy link

  • Handle WAN VAE downscale_ratio which is a tuple (function, min, max) instead of integer
  • Fixes TypeError when using VAEEncodeForInpaint with Qwen Image/WAN VAEs
  • Backward compatible with standard VAEs that use integer downscale_ratio

nodes.py Outdated
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
# Handle WAN VAE downscale_ratio which can be a tuple (function, min, max)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these actually min/max?

It looks like x and y. This code looks like it might be solving the same problem:

    def spacial_compression_decode(self):
        try:
            return self.upscale_ratio[-1]
        except:
            return self.upscale_ratio

    def spacial_compression_encode(self):
        try:
            return self.downscale_ratio[-1]
        except:
            return self.downscale_ratio

Can you just call vae.spacial_compression_encode():

        x = (pixels.shape[1] // vae.spacial_compression_encode()) * vae.spacial_compression_encode()
        y = (pixels.shape[2] // vae.spacial_compression_encode()) * vae.spacial_compression_encode()

@ChrisFab16
Copy link
Author

Thanks for the feedback, @rattus128!
I updated VAEEncodeForInpaint to use vae.spacial_compression_encode() for the downscale ratio and offsets, matching the existing VAE helper used elsewhere. This removes the manual tuple handling and works for both WAN-style tuples and standard ints. Tested locally with mock VAEs; both tuple and int downscale cases behave as expected.

- Handle WAN VAE downscale_ratio which is a tuple (function, min, max) instead of integer
- Fixes TypeError when using VAEEncodeForInpaint with Qwen Image/WAN VAEs
- Backward compatible with standard VAEs that use integer downscale_ratio
@ChrisFab16 ChrisFab16 force-pushed the fix/wan-vae-downscale-ratio-inpaint branch from 58d8f0b to c01c1f8 Compare December 17, 2025 06:41
- Remove conflict markers at lines 1, 2455, 2456, 4910
- Remove duplicate file content after line 2454
- File now correctly ends at 'return import_failed'
- Reduced from 7364 to 2452 lines
- Verified: No conflict markers remain, Python syntax valid
@rattus128
Copy link
Contributor

If you check the diff here, I think your IDE or git or something has done a full whitespace reformat of the file. You will need to reduce the diff back to just the content changes with whitespace consistency to surrounds.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants