Views
No views yet
| Parameter | Value |
|---|---|
| Base model | FLUX.2-dev VAE (AutoencoderKLFlux2) |
| Training steps | 10,000 |
| Dataset | FLUX-Reason-6M (1024x1024) |
| Weights | EMA (decay=0.9999) |
| Sphere radius | sqrt(32) ~ 5.66 |
| Latent channels | 32 |
| Decoder LR | 4e-5 |
| Encoder LR | 4e-6 |
| Loss | L1 + LPIPS + KL + adversarial (after 10k steps) |
1from diffusers import AutoencoderKLFlux2
2import torch
3
4# Load the fine-tuned VAE
5vae = AutoencoderKLFlux2.from_pretrained("tmeral/spherical-vae-flux")
6vae = vae.to("cuda").eval()
7
8# Encode an image (B, 3, H, W) -> latent
9image = torch.randn(1, 3, 512, 512, device="cuda") # replace with real image
10with torch.no_grad():
11 latent = vae.encode(image).latent_dist.sample()
12
13# Apply spherical projection (optional, for strict sphere constraint)
14import math
15radius = math.sqrt(32)
16latent_flat = latent.flatten(2) # (B, C, H*W)
17norms = latent_flat.norm(dim=1, keepdim=True) # (B, 1, H*W)
18latent_flat = latent_flat / norms * radius
19latent = latent_flat.view_as(latent)
20
21# Decode back to pixel space
22with torch.no_grad():
23 recon = vae.decode(latent).sample
24
25print(f"Input: {image.shape} -> Latent: {latent.shape} -> Recon: {recon.shape}")


| File | Description |
|---|---|
diffusion_pytorch_model.safetensors | Model weights in safetensors format |
config.json | Diffusers model config |
spherical_vae_metadata.json | Spherical VAE training metadata (radius, channels, base model) |
inference.py | Self-contained encode/decode inference script |
training_config.yaml | Full training configuration |
comparison_*.png | Qualitative comparison images at 256/512/1024 |