Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/diffusers/models/autoencoders/autoencoder_kl_wan.py
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,10 @@ def tiled_encode(self, x: torch.Tensor) -> AutoencoderKLOutput:
blend_height = tile_latent_min_height - tile_latent_stride_height
blend_width = tile_latent_min_width - tile_latent_stride_width

# Apply patchify if patch_size is specified
if self.config.patch_size is not None:
x = patchify(x, patch_size=self.config.patch_size)

# Split x into overlapping tiles and encode them separately.
# The tiles have an overlap to avoid seams between tiles.
rows = []
Expand Down Expand Up @@ -1392,6 +1396,10 @@ def tiled_decode(self, z: torch.Tensor, return_dict: bool = True) -> Union[Decod

dec = torch.cat(result_rows, dim=3)[:, :, :, :sample_height, :sample_width]

# Apply unpatchify if patch_size is specified
if self.config.patch_size is not None:
dec = unpatchify(dec, patch_size=self.config.patch_size)

if not return_dict:
return (dec,)
return DecoderOutput(sample=dec)
Expand Down