Downloads · 30 days
21
21% of all-time downloads
tmeral/sd-vae-ft-mse-spherical
sd-vae-ft-mse-spherical is a machine learning model from tmeral. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for diffusers. The card lists the license as apache-2.0.
A spherically-constrained fine-tune of stabilityai/sd-vae-ft-mse (AutoencoderKL, 4 latent channels).
Downloads · 30 days
21
21% of all-time downloads
All-time downloads
99
Public
Parameters
83.7M
343 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors335 MB · 99%
From the Hugging Face model README
A spherically-constrained fine-tune of stabilityai/sd-vae-ft-mse (AutoencoderKL, 4 latent channels).
The encoder output is constrained to lie on a hypersphere of radius sqrt(latent_channels) = 2.0 via a custom SphericalQuantConv layer trained during fine-tuning. The exported weights use a plain Conv2d (identical numerically) so the model loads directly via the standard diffusers AutoencoderKL API.
| Property | Value |
|---|---|
| Base model | stabilityai/sd-vae-ft-mse |
| Latent channels | 4 |
| Sphere radius | 2.0 (= sqrt(4)) |
| Training steps | 10,000 |
| Training resolution | 256x256 |
| Dataset | FLUX-Reason-6M (256px subset) |
| Effective batch size | 128 (batch_size=4 x grad_accum=1 x 4 GPUs x 8) |
See training_config.yaml for the full config. Key settings:
decoder_lr: 4e-5, encoder_lr: 4e-6l1_weight: 1.0, lpips_weight: 1.0, kl_weight: 1e-6, adv_weight: 0.0Computed on the FLUX-Reason-6M eval split at 256px:
| Metric | Value |
|---|---|
| rFID | 242.0 |
| LPIPS | 0.762 |
Important: The decoder was fine-tuned with latents on a hypersphere of radius 2.0. You must apply sphere projection before decoding. Skipping this step produces over-saturated, incorrect reconstructions.
import math
import torch
import torch.nn.functional as F
from diffusers import AutoencoderKL
SPHERE_RADIUS = math.sqrt(4) # = 2.0
vae = AutoencoderKL.from_pretrained("tmeral/sd-vae-ft-mse-spherical")
vae.eval()
# Encode an image ([-1, 1] normalized, shape [B, 3, H, W])
with torch.no_grad():
latents = vae.encode(image).latent_dist.mean
# Required: project onto sphere before decoding
latents = F.normalize(latents, p=2, dim=1) * SPHERE_RADIUS
reconstruction = vae.decode(latents).sample
See inference.py for a complete example.
