Diffusers
Safetensors
File size: 2,291 Bytes
bd6e0c6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
---
license: apache-2.0
library_name: diffusers
pipeline_tag: text-to-image
---

# SafeDiffusion-R1: Online Reward Steering for Safe Diffusion Post-Training

SafeDiffusion-R1 is a safety post-training framework for Stable Diffusion based on Group Relative Policy Optimization (GRPO). It uses a closed-form, CLIP-based steering reward to bake safety priors directly into the UNet weights, eliminating the need for separately trained safety classifiers or inference-time interventions.

[**Project Page**](https://maxnorm8650.github.io/SafeDiffusion-R1/) | [**GitHub**](https://github.com/MAXNORM8650/SafeDiffusion-R1) | [**Paper**](https://huggingface.co/papers/2605.18719)

## Model Variants

The models are released as full Diffusers pipelines in different subfolders:

| Subfolder | Description |
|---|---|
| `scaled` | Main paper checkpoint. Best balance of safety and utility (Default). |
| `compact` | Optimized for lowest MMA-Diffusion ASR (adversarial robustness). |
| `empty-positive` | Ablation variant trained without safe anchors. |

## Sample Usage

You can load and use the model variants using the `diffusers` library. Since the repository uses subfolders for different variants, we recommend using `snapshot_download` to load the specific version you need.

```python
from huggingface_hub import snapshot_download
from diffusers import StableDiffusionPipeline
import os, torch

# Download the variant you want (e.g., "scaled")
local_root = snapshot_download(
    "ItsMaxNorm/SafeDiffusion-R1",
    allow_patterns="scaled/*",           # or "compact/*" / "empty-positive/*"
)

# Load the pipeline
pipe = StableDiffusionPipeline.from_pretrained(
    os.path.join(local_root, "scaled"),
    torch_dtype=torch.float16,
).to("cuda")

# Generate an image
prompt = "a photo of a cat sleeping on a couch"
img = pipe(prompt).images[0]
img.save("out.png")
```

## Citation

```bibtex
@misc{kumar2026safediffusionr1,
      title={SafeDiffusion-R1: Online Reward Steering for Safe Diffusion Post-Training}, 
      author={Komal Kumar and Ankan Deria and Abhishek Basu and Fahad Shamshad and Hisham Cholakkal and Karthik Nandakumar},
      year={2026},
      eprint={2605.18719},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2605.18719}, 
}
```