Add model card for Self-NPO (Diffusion-NPO)
Browse filesThis PR adds a comprehensive model card for **Self-NPO**, a data-free negative preference optimization approach, which is part of the broader **Diffusion-NPO** framework.
The update includes:
- A link to the paper: [Self-NPO: Data-Free Diffusion Model Enhancement via Truncated Diffusion Fine-Tuning](https://huggingface.co/papers/2505.11777).
- Relevant metadata: `license` (Apache 2.0), `pipeline_tag` (text-to-image), and `library_name` (diffusers).
- The full abstract of the paper.
- An overview and key features of the model, extracted from the GitHub README.
- A detailed sample usage section for inference, with code snippets directly from the GitHub repository.
- Example outputs, Model Zoo, Citation, and License information from the GitHub README.
This model card significantly improves the discoverability and usability of the model on the Hugging Face Hub.
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
pipeline_tag: text-to-image
|
| 4 |
+
library_name: diffusers
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
# Self-NPO: Data-Free Diffusion Model Enhancement via Truncated Diffusion Fine-Tuning
|
| 8 |
+
|
| 9 |
+
This repository contains models and code for **Self-NPO**, a method presented in the paper [Self-NPO: Data-Free Diffusion Model Enhancement via Truncated Diffusion Fine-Tuning](https://huggingface.co/papers/2505.11777). The implementation is part of the broader [Diffusion-NPO GitHub repository](https://github.com/G-U-N/Diffusion-NPO).
|
| 10 |
+
|
| 11 |
+
## Abstract
|
| 12 |
+
Diffusion models have demonstrated remarkable success in various visual generation tasks, including image, video, and 3D content generation. Preference optimization (PO) is a prominent and growing area of research that aims to align these models with human preferences. While existing PO methods primarily concentrate on producing favorable outputs, they often overlook the significance of classifier-free guidance (CFG) in mitigating undesirable results. Diffusion-NPO addresses this gap by introducing negative preference optimization (NPO), training models to generate outputs opposite to human preferences and thereby steering them away from unfavorable outcomes through CFG. However, prior NPO approaches rely on costly and fragile procedures for obtaining explicit preference annotations (e.g., manual pairwise labeling or reward model training), limiting their practicality in domains where such data are scarce or difficult to acquire. In this work, we propose Self-NPO, specifically truncated diffusion fine-tuning, a data-free approach of negative preference optimization by directly learning from the model itself, eliminating the need for manual data labeling or reward model training. This data-free approach is highly efficient (less than 1% training cost of Diffusion-NPO) and achieves comparable performance to Diffusion-NPO in a data-free manner. We demonstrate that Self-NPO integrates seamlessly into widely used diffusion models, including SD1.5, SDXL, and CogVideoX, as well as models already optimized for human preferences, consistently enhancing both their generation quality and alignment with human preferences.
|
| 13 |
+
|
| 14 |
+
<div align="center">
|
| 15 |
+
|
| 16 |
+
# Diffusion-NPO: Negative Preference Optimization for Better Preference Aligned Generation of Diffusion Models
|
| 17 |
+
|
| 18 |
+
By Fu-Yun Wang¹, Yunhao Shui², Jingtan Piao¹, Keqiang Sun¹, Hongsheng Li¹
|
| 19 |
+
<br>
|
| 20 |
+
¹CUHK-MMLab ²Shanghai Jiao Tong University
|
| 21 |
+
|
| 22 |
+
[](https://arxiv.org/abs/XXXX.XXXXX) [](https://github.com/G-U-N/Diffusion-NPO/blob/main/LICENSE)
|
| 23 |
+
|
| 24 |
+

|
| 25 |
+
|
| 26 |
+
</div>
|
| 27 |
+
|
| 28 |
+
## Overview
|
| 29 |
+
This repository contains the official implementation for **Diffusion-NPO: Negative Preference Optimization for Better Preference Aligned Generation of Diffusion Models**.
|
| 30 |
+
|
| 31 |
+
Diffusion-NPO introduces **Negative Preference Optimization (NPO)**, a novel plug-and-play approach to enhance the alignment of diffusion models with human preferences. By training a model to understand and avoid undesirable outputs, NPO improves the effectiveness of classifier-free guidance (CFG) in diffusion models, leading to superior image and video generation quality.
|
| 32 |
+
|
| 33 |
+
## Key Features
|
| 34 |
+
* **Enhanced Preference Alignment**: Improves high-frequency details, color, lighting, and low-frequency structures in generated images and videos.
|
| 35 |
+
* **Plug-and-Play**: Seamlessly integrates with models like Stable Diffusion (SD1.5, SDXL), VideoCrafter2, and their preference-optimized variants (Dreamshaper, Juggernaut).
|
| 36 |
+
* **No New Data or Strategies Required**: Adapts existing preference optimization methods (e.g., DPO, RL, Differentiable Reward) with minimal modifications.
|
| 37 |
+
* **Comprehensive Validation**: Demonstrated effectiveness across text-to-image and text-to-video tasks using metrics like PickScore, HPSv2, ImageReward, and LAION-Aesthetic.
|
| 38 |
+
|
| 39 |
+
## Usage: Inference
|
| 40 |
+
To run inference with SDXL using a Self-NPO optimized model, follow these steps. The code below is adapted from the [Diffusion-NPO GitHub repository](https://github.com/G-U-N/Diffusion-NPO).
|
| 41 |
+
|
| 42 |
+
```bash
|
| 43 |
+
python gen_xl.py --generation_path="results/sdxl_cfg5/origin/" --merge_weight=0.0 --cfg=5
|
| 44 |
+
|
| 45 |
+
python gen_xl.py --generation_path="results/sdxl_cfg5/origin+npo/" --npo_lora_path="weights/sdxl/sdxl_beta2k_2kiter.safetensors" --merge_weight=0.0 --cfg=5
|
| 46 |
+
|
| 47 |
+
python gen_xl.py --generation_path="results/sdxl_cfg5/dpo/" --merge_weight=0.0 --cfg=5
|
| 48 |
+
|
| 49 |
+
python gen_xl.py --generation_path="results/sdxl_cfg5/dpo+npo/" --npo_lora_path="weights/sdxl/sdxl_beta2k_2kiter.safetensors" --merge_weight=0.0 --cfg=5
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
**Key arguments for `gen_xl.py`:**
|
| 53 |
+
* `--generation_path`: Specifies the output directory and implicitly the positive model used (as per the original script's context).
|
| 54 |
+
* `--cfg`: Classifier-Free Guidance scale value.
|
| 55 |
+
* `--npo_lora_path`: Path to the NPO LoRA weights (e.g., `weights/sdxl/sdxl_beta2k_2kiter.safetensors`).
|
| 56 |
+
* `--merge_weight`: The beta parameter for merging NPO weights, as discussed in the paper. For evaluation of NPO impact via CFG, it's typically set to `0.0`.
|
| 57 |
+
|
| 58 |
+
## Example Outputs
|
| 59 |
+
Below are example comparisons of generations with and without NPO, as presented in the GitHub repository:
|
| 60 |
+
|
| 61 |
+
| Prompt | w/o NPO | w/ NPO |
|
| 62 |
+
|--------|---------|--------|
|
| 63 |
+
| "an attractive young woman rolling her eyes" |  |  |
|
| 64 |
+
| "Black old man with white hair" |  |  |
|
| 65 |
+
|
| 66 |
+
_Note: The images above link to the same `preface_teaser` image from the GitHub README as placeholders, since the specific asset URLs for the examples were not provided._
|
| 67 |
+
|
| 68 |
+
## Model Zoo
|
| 69 |
+
Pre-trained NPO weight offsets are available for the following models:
|
| 70 |
+
- Stable Diffusion v1-5: [Download](https://huggingface.co/wangfuyun/Diffusion-NPO/tree/main/weights)
|
| 71 |
+
- Stable Diffusion XL: [Download](https://huggingface.co/wangfuyun/Diffusion-NPO/tree/main/weights)
|
| 72 |
+
|
| 73 |
+
Base model weights can be obtained from:
|
| 74 |
+
- [Stable Diffusion v1-5](https://huggingface.co/stabilityai/stable-diffusion-v1-5)
|
| 75 |
+
- [Stable Diffusion XL](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0)
|
| 76 |
+
- [DreamShaper](https://huggingface.co/Lykon/DreamShaper)
|
| 77 |
+
- [VideoCrafter2](https://huggingface.co/VideoCrafter/VideoCrafter2)
|
| 78 |
+
|
| 79 |
+
## Citation
|
| 80 |
+
If you find this work useful, please cite our paper:
|
| 81 |
+
|
| 82 |
+
```bibtex
|
| 83 |
+
@inproceedings{
|
| 84 |
+
wang2025diffusionnpo,
|
| 85 |
+
title={Diffusion-{NPO}: Negative Preference Optimization for Better Preference Aligned Generation of Diffusion Models},
|
| 86 |
+
author={Fu-Yun Wang and Yunhao Shui and Jingtan Piao and Keqiang Sun and Hongsheng Li},
|
| 87 |
+
booktitle={The Thirteenth International Conference on Learning Representations},
|
| 88 |
+
year={2025},
|
| 89 |
+
url={https://openreview.net/forum?id=iJi7nz5Cxc}
|
| 90 |
+
}
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
## License
|
| 94 |
+
This project is licensed under the Apache License, Version 2.0. See the [LICENSE](https://github.com/G-U-N/Diffusion-NPO/blob/main/LICENSE) file for details.
|