How to use from the
Use from the
Diffusers library
pip install -U diffusers transformers accelerate
import torch
from diffusers import DiffusionPipeline

# switch to "mps" for apple devices
pipe = DiffusionPipeline.from_pretrained("kevin1103/SAGE", dtype=torch.bfloat16, device_map="cuda")

prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
image = pipe(prompt).images[0]

SAGE: Exploring the Boundaries of Unsafe Concept Domain with Semantic-Augment Erasing

arXiv | Code

Overview

This repository provides the released SAGE checkpoints for concept and artistic-style erasure in Stable Diffusion v1.4.

SAGE is a semantic-augmentation framework that updates the text encoder of a diffusion model to erase a target concept while retaining general image-generation ability. These checkpoints are intended for the original Stable Diffusion v1.4 pipeline.

Available checkpoints

The repository is organized by erased concept or artistic style.

SAGE/
β”œβ”€β”€ nudity/
β”‚   β”œβ”€β”€ TextEncoder-text_encoder_full-epoch_999.pt
β”œβ”€β”€ vangogh/
β”‚   β”œβ”€β”€ TextEncoder-text_encoder_layer0-epoch_999.pt
└── monet/
    β”œβ”€β”€ TextEncoder-text_encoder_layer0-epoch_999.pt

The exact filenames may differ between releases. Use the checkpoint filename present in each directory.

Directory Target Updated component
nudity/ nudity-related concepts full CLIP text encoder
vangogh/ Vincent van Gogh artistic style CLIP text-encoder layer 0
monet/ Claude Monet artistic style CLIP text-encoder layer 0

These files contain PyTorch state dictionaries for the edited text encoder. They are not complete Diffusers pipelines and require the original Stable Diffusion v1.4 model.

Base model

Use the original Stable Diffusion v1.4 model. The checkpoint should be loaded into the text_encoder component of the matching pipeline. Do not load these files as complete pipelines with StableDiffusionPipeline.from_pretrained.

Loading a checkpoint

pip install torch diffusers transformers accelerate
import torch
from diffusers import StableDiffusionPipeline

base_model = "CompVis/stable-diffusion-v1-4"
checkpoint = "path/to/TextEncoder-text_encoder_full-epoch_999.pt"

pipe = StableDiffusionPipeline.from_pretrained(
    base_model,
    torch_dtype=torch.float16,
)
state_dict = torch.load(checkpoint, map_location="cpu")
pipe.text_encoder.load_state_dict(state_dict, strict=False)
pipe = pipe.to("cuda")

image = pipe(
    "a photo of a nudity person",
    num_inference_steps=50,
    guidance_scale=7.5,
).images[0]
image.save("sage_result.png")

For the style checkpoints, replace checkpoint with the corresponding file under vangogh/ or monet/.

Reproducing generation

The complete implementation and evaluation scripts are available in the accompanying SAGE code repository. The reference generator accepts prompt CSV files containing case_number, prompt, and evaluation_seed.

python generate-scripts/generate_images.py \
  --prompts_path data/prompts/eval/SD-v1-4_NudeClasses_75_filtered.csv \
  --folder_suffix nudity \
  --save_path outputs/nudity \
  --target_ckpt path/to/nudity/TextEncoder-text_encoder_full-epoch_999.pt \
  --checkpoint_component text_encoder \
  --origin_or_target target

Evaluation settings

The paper-scale nudity evaluation uses the I2P prompt set with 4,703 samples, NudeNet confidence threshold 0.6, the paper subset of exposed-part labels, COCO-10k utility evaluation, and Q16 as an additional inappropriate-content classifier. Smaller files such as nudity_quick.csv, nudity.csv, and coco_200.csv are intended for environment checks and fast iteration.

The style experiments evaluate both target-style erasure and retention of other artists' styles for Vincent van Gogh and Claude Monet.

Citation

If you use SAGE, please cite the corresponding SAGE paper and the upstream Stable Diffusion and evaluation projects.

@article{zhu2025sage,
  title={SAGE: Exploring the Boundaries of Unsafe Concept Domain with Semantic-Augment Erasing},
  author={Zhu, Hongguang and Wei, Yunchao and Wang, Mengyu and Jiao, Siyu and Fang, Yan and Huang, Jiannan and Zhao, Yao},
  journal={arXiv preprint arXiv:2506.09363},
  year={2025}
}
Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Paper for kevin1103/SAGE