Buckets:
| import torch | |
| from einops import rearrange | |
| from torch import Tensor, nn | |
| class QwenAutoencoder(nn.Module): | |
| """qwen-ae-f8-16c: the Qwen-Image VAE (f8, 16 latent channels).""" | |
| def __init__(self): | |
| super().__init__() | |
| from diffusers import AutoencoderKLQwenImage | |
| self.ae = AutoencoderKLQwenImage.from_pretrained("Qwen/Qwen-Image", subfolder="vae") | |
| self.compression = 8 | |
| self.channels = 16 | |
| self.register_buffer("latents_mean", torch.tensor(self.ae.latents_mean).view(1, -1, 1, 1, 1)) | |
| self.register_buffer("latents_std", torch.tensor(self.ae.latents_std).view(1, -1, 1, 1, 1)) | |
| def decode(self, x: Tensor) -> Tensor: | |
| x = rearrange(x, "b c h w -> b c 1 h w") | |
| x = (x * self.latents_std) + self.latents_mean | |
| return rearrange(self.ae.decode(x).sample, "b c 1 h w -> b c h w") | |
Xet Storage Details
- Size:
- 858 Bytes
- Xet hash:
- 39f26b7d56e183a423a80a202b8ea993cb49f27d34b46e69a2caf6104602bb7d
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.