File size: 2,436 Bytes
063e6f5 d2506a2 8d05992 7fc7539 063e6f5 9acc087 8ef7258 d2506a2 8ef7258 d2506a2 8ef7258 d2506a2 8ef7258 d2506a2 8d05992 |
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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
---
license: mit
pipeline_tag: text-to-image
library_name: diffusers
datasets:
- pickapic-anonymous/pickapic_v1
---
This repository contains public models of [Latent Preference Optimization (LPO)](https://github.com/Kwai-Kolors/LPO) based on SD1.5 and SDXL. The merged models represent the merged weights of the LoRA weights with the original models.
The corresponding github repository is [https://github.com/Kwai-Kolors/LPO](https://github.com/Kwai-Kolors/LPO).
## 🛠️ Usage
### SDXL
```python
from diffusers import StableDiffusionXLPipeline, UNet2DConditionModel, AutoencoderKL
import torch
unet = UNet2DConditionModel.from_pretrained(
'casiatao/LPO',
subfolder="lpo_sdxl_merge/unet",
torch_dtype=torch.float16
)
vae = AutoencoderKL.from_pretrained(
'madebyollin/sdxl-vae-fp16-fix',
torch_dtype=torch.float16,
)
pipe = StableDiffusionXLPipeline.from_pretrained(
'stabilityai/stable-diffusion-xl-base-1.0',
unet=unet,
vae=vae,
torch_dtype=torch.float16
)
pipe = pipe.to("cuda")
prompt = "A cat holding a sign that says hello world"
generator=torch.Generator(device="cuda").manual_seed(42)
image = pipe(
prompt=prompt,
guidance_scale=5.0,
num_inference_steps=20,
generator=generator,
output_type='pil',
).images[0]
image.save("img_sdxl.png")
```
### SD1.5
```python
from diffusers import StableDiffusionPipeline, UNet2DConditionModel
import torch
unet = UNet2DConditionModel.from_pretrained(
'casiatao/LPO',
subfolder="lpo_sd15_merge/unet",
torch_dtype=torch.float16
)
pipe = StableDiffusionPipeline.from_pretrained(
'sd-legacy/stable-diffusion-v1-5',
unet=unet,
torch_dtype=torch.float16
)
pipe = pipe.to("cuda")
prompt = "a photo of a cat"
generator=torch.Generator(device="cuda").manual_seed(42)
image = pipe(
prompt=prompt,
guidance_scale=5.0,
num_inference_steps=20,
generator=generator,
output_type='pil',
).images[0]
image.save("img_sd15.png")
```
## ❤️ Citation
If you find this repository helpful, please consider giving it a like ❤️ and citing:
```bibtex
@article{zhang2025diffusion,
title={Diffusion Model as a Noise-Aware Latent Reward Model for Step-Level Preference Optimization},
author={Zhang, Tao and Da, Cheng and Ding, Kun and Jin, Kun and Li, Yan and Gao, Tingting and Zhang, Di and Xiang, Shiming and Pan, Chunhong},
journal={arXiv preprint arXiv:2502.01051},
year={2025}
}
``` |