Views
No views yet
.safetensors weights. The model uses a custom architecture — it is
not a transformers / diffusers model and does not load via AutoModel. You need
the galaxy_diffusion package from the code repository to instantiate it.| File | Contents |
|---|---|
latent_diffusion_galaxy10_xattn_v1.model.safetensors | UNet denoiser (LatentUNetCA, cross-attention conditioning), ~27.9M params |
latent_diffusion_galaxy10_xattn_v1.vae.safetensors | VAE (image ↔ 4×32×32 latent), ~1.09M params |
latent_diffusion_galaxy10_xattn_v1.config.json | constructor args (vae_config, unet_config, unet_type) + latent normalisation stats (latents_mean, latents_std) |
galaxy10_classifier.model.safetensors | GalaxyCNN evaluation classifier, ~1.75M params (val acc 0.829) |
galaxy10_classifier.config.json | classifier metadata (val_acc, epoch) |
1pip install "git+https://github.com/LLapsus/galaxy-diffusion.git"
2pip install huggingface_hub safetensors1import json
2import torch
3from huggingface_hub import snapshot_download
4from safetensors.torch import load_file
5
6from galaxy_diffusion.models.vae import VAE
7from galaxy_diffusion.models.unet import LatentUNetCA
8
9path = snapshot_download("llapsus/galaxy-diffusion") # downloads all files
10cfg = json.load(open(f"{path}/latent_diffusion_galaxy10_xattn_v1.config.json"))
11
12vae = VAE(**cfg["vae_config"])
13vae.load_state_dict(load_file(f"{path}/latent_diffusion_galaxy10_xattn_v1.vae.safetensors"))
14vae.eval()
15
16unet = LatentUNetCA(**cfg["unet_config"])
17unet.load_state_dict(load_file(f"{path}/latent_diffusion_galaxy10_xattn_v1.model.safetensors"))
18unet.eval()1from galaxy_diffusion.diffusion.ddpm import cosine_schedule, sample_cfg
2
3device = "cuda"
4vae, unet = vae.to(device), unet.to(device)
5
6_, alpha, alpha_bar = cosine_schedule(1000)
7alpha, alpha_bar = alpha.to(device), alpha_bar.to(device)
8
9latents_mean = torch.tensor(cfg["latents_mean"])
10latents_std = torch.tensor(cfg["latents_std"])
11
12images = sample_cfg(
13 unet, vae,
14 classes=list(range(10)), # one image per class
15 alpha=alpha, alpha_bar=alpha_bar,
16 latent_shape=(cfg["unet_config"]["latent_channels"], 32, 32),
17 latents_mean=latents_mean, latents_std=latents_std,
18 device=device,
19 guidance_scale=2.5, # see "Guidance scale" below
20 cfg_rescale=0.7, # CFG rescaling (Lin et al., 2023)
21) # -> tensor (10, 3, 256, 256) in [-1, 1]GalaxyCNN from
galaxy_diffusion.models.classifier.LatentUNetCA): time conditioning via AdaGN, class conditioning via a
cross-attention block after each encoder/decoder level + bottleneck; cosine noise
schedule (T=1000); trained with Min-SNR-weighted MSE and 10% CFG label dropout.GalaxyCNN): trained on VAE-reconstructed images (to match the
distribution of diffusion outputs) for evaluating class fidelity of generated samples.w ≈ 3, but latent-space coverage
analysis shows w ≈ 2.5 is the better fidelity/diversity operating point (matched
within-class spread). Higher w over-extrapolates samples toward neighbouring classes.
See the coverage analysis in the code repository.