---
title: dpo-sdxl-text2image-v1
canonical_url: "https://www.modelscope.cn/models/AI-ModelScope/dpo-sdxl-text2image-v1"
md_url: "https://www.modelscope.cn/models/AI-ModelScope/dpo-sdxl-text2image-v1.md"
repository: AI-ModelScope/dpo-sdxl-text2image-v1
last_updated: 2023-12-25
license: openrail++
pipeline_tag: text-to-image-synthesis
tasks:
  - text-to-image-synthesis
parameters: 2.6B
tensor_type:
  - F32
library_name:
  - pytorch
  - safetensors
  - diffusers
frameworks:
  - Pytorch
language:
  - en
downloads: 88
stars: 1
---

# dpo-sdxl-text2image-v1

> dpo-sdxl-text2image-v1 - AI-ModelScope 在 ModelScope 开源的模型。Diffusion Model Alignment Using Direct Preference Optimization

AI-ModelScope/dpo-sdxl-text2image-v1 是 ModelScope 魔搭社区上的 2.6B 参数text-to-image-synthesis模型，采用 openrail++ 许可。

- **Repository**: AI-ModelScope/dpo-sdxl-text2image-v1
- **License**: openrail++
- **Tasks**: text-to-image-synthesis
- **Parameters**: 2.6B
- **Downloads**: 88
- **Stars**: 1
- **Last updated**: 2023-12-25

Source: https://www.modelscope.cn/models/AI-ModelScope/dpo-sdxl-text2image-v1

---

# Diffusion Model Alignment Using Direct Preference Optimization

![row01](01.gif)

Direct Preference Optimization (DPO) for text-to-image diffusion models is a method to align diffusion models to text human preferences by directly optimizing on human comparison data. Please check our paper at [Diffusion Model Alignment Using Direct Preference Optimization](https://arxiv.org/abs/2311.12908).

This model is fine-tuned from [stable-diffusion-xl-base-1.0](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0) on offline human preference data [pickapic_v2](https://huggingface.co/datasets/yuvalkirstain/pickapic_v2).

## Code
*Code will come soon!!!*

## SD1.5
We also have a model finedtuned from [stable-diffusion-v1-5](https://huggingface.co/runwayml/stable-diffusion-v1-5) available at [dpo-sd1.5-text2image-v1](https://huggingface.co/mhdang/dpo-sd1.5-text2image-v1).

## A quick example
```python
from diffusers import StableDiffusionXLPipeline, UNet2DConditionModel
from modelscope import snapshot_download
import torch

# load pipeline
model_id_base = "AI-ModelScope/stable-diffusion-xl-base-1.0"
local_base = snapshot_download(model_id_base,revision='master')
pipe = StableDiffusionXLPipeline.from_pretrained(local_base, torch_dtype=torch.float16, variant="fp16", use_safetensors=True).to("cuda")

# load finetuned model
unet_id = "AI-ModelScope/dpo-sdxl-text2image-v1"
local_unet = snapshot_download(unet_id,revision='master')
unet = UNet2DConditionModel.from_pretrained(local_unet, subfolder="unet", torch_dtype=torch.float16)
pipe.unet = unet
pipe = pipe.to("cuda")

prompt = "Two cats playing chess on a tree branch"
image = pipe(prompt, guidance_scale=5).images[0].resize((512,512))
    
image.save("cats_playing_chess.png")
```

More details coming soon.
