Instructions to use sui1234bian/ksae-slider-sd15 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use sui1234bian/ksae-slider-sd15 with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("sui1234bian/ksae-slider-sd15", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
import torch
from diffusers import DiffusionPipeline
# switch to "mps" for apple devices
pipe = DiffusionPipeline.from_pretrained("sui1234bian/ksae-slider-sd15", dtype=torch.bfloat16, device_map="cuda")
prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
image = pipe(prompt).images[0]k-SAE attribute slider for Stable Diffusion 1.5
Course project for IERG4320/IEMS5726A Data Science in Practice (CUHK, 2026-27 Term 1). A reproduction of All-in-One Slider for Attribute Manipulation in Diffusion Models (CVPR 2026, arXiv:2508.19195) on SD1.5.
The checkpoint is a k-sparse autoencoder trained on CLIP text-encoder activations (layer 10, EOS token). It factorises the 768-d conditioning space into 6,144 sparse directions; one 37 MB module provides continuous sliders for 52 facial attributes, with no per-attribute training and no UNet modification.
Files
| file | size | content |
|---|---|---|
model.pt |
37 MB | k-SAE weights (W_enc, b_enc, W_dec, b_dec) + config + steps + val EV |
directions.npz |
160 KB | 52 unit steering directions (names, vectors [52, 768]) |
meta.json |
<1 KB | training summary (F, k, steps, best step, explained variance) |
history.json |
4 KB | per-200-step training log (loss, val MSE, EV, L0, dead fraction) |
acts_meta.json |
<1 KB | activation extraction stats (768-d, layer 10, EOS) |
dataset_stats.json |
14 KB | prompt dataset statistics (52 classes, splits, attribute phrases) |
Reported metrics
- validation explained variance 0.9504 after 3,000 steps (46,824 train / 5,176 val)
- 52 directions, mean pairwise |cosine| 0.131
- CLIP score vs slider strength (Spearman): smile +1.000, age +1.000, bald +0.900, eyeglasses +0.900, mustache +0.400
- 81.5% of dictionary directions never enter the top-k (documented limitation)
Usage
import torch
from huggingface_hub import hf_hub_download
ckpt = torch.load(hf_hub_download("USER/ksae-slider-sd15", "model.pt"),
map_location="cuda", weights_only=True)
# ckpt["config"] -> {"d_in": 768, "n_features": 6144, "k": 32, "aux_k": 128}
# ckpt["state"] -> W_enc, b_enc, W_dec, b_dec, steps_since_fired
Steering (see pipeline/steering.py in the source code submission):
- run the prompt through the CLIP text encoder with a forward hook on
text_model.encoder.layers[9]; - add
+strength * directionto the conditional branch and-strength * directionto the unconditional branch; - feed the resulting
prompt_embedsto the SD1.5 UNet as usual.
Do not pass attention_mask to the text encoder: SD1.5 was trained without it and
adding it collapses the output to noise.
License and scope
Trained on the contrastive prompt set released with the reference paper and intended for research and coursework only. The base model (SD1.5) is not redistributed here.
Citation
@article{ye2026allinoneslider,
title={All-in-One Slider for Attribute Manipulation in Diffusion Models},
author={Ye, Weixin and Zhu, Hongguang and Wang, Wei and Liu, Yahui and Wang, Mengyu and Nie, Xuecheng},
journal={arXiv preprint arXiv:2508.19195},
year={2026}
}
- Downloads last month
- -
Model tree for sui1234bian/ksae-slider-sd15
Base model
stable-diffusion-v1-5/stable-diffusion-v1-5