Instructions to use kd5678/prefpaint-v1.0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use kd5678/prefpaint-v1.0 with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline from diffusers.utils import load_image # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("kd5678/prefpaint-v1.0", dtype=torch.bfloat16, device_map="cuda") prompt = "Turn this cat into a dog" input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png") image = pipe(image=input_image, prompt=prompt).images[0] - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -9,5 +9,34 @@ Our code and dataset are publicly available at https://prefpaint.github.io.
|
|
| 9 |
# Usage
|
| 10 |
|
| 11 |
```bash
|
|
|
|
|
|
|
|
|
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
```
|
|
|
|
| 9 |
# Usage
|
| 10 |
|
| 11 |
```bash
|
| 12 |
+
import os
|
| 13 |
+
from PIL import Image
|
| 14 |
+
from diffusers import AutoPipelineForInpainting
|
| 15 |
|
| 16 |
+
pipe = AutoPipelineForInpainting.from_pretrained(
|
| 17 |
+
'kd5678/prefpaint-v1.0', cache_dir='/data/kendong/cache')
|
| 18 |
+
pipe = pipe.to("cuda")
|
| 19 |
+
|
| 20 |
+
color_path = 'images.png'
|
| 21 |
+
mask_path = 'mask.png'
|
| 22 |
+
save_path = './results'
|
| 23 |
+
os.makedirs(save_path, exist_ok=True)
|
| 24 |
+
|
| 25 |
+
image, mask = Image.open(color_path), Image.open(mask_path).convert('L')
|
| 26 |
+
# You can provide your prompt here.
|
| 27 |
+
prompt = " "
|
| 28 |
+
result = pipe(prompt=prompt, image=image, mask_image=mask, eta=1.0).images[0]
|
| 29 |
+
result.save(os.path.join(save_path, 'results.png'))
|
| 30 |
+
|
| 31 |
+
```
|
| 32 |
+
|
| 33 |
+
# How to Cite
|
| 34 |
+
|
| 35 |
+
```
|
| 36 |
+
@article{liu2024prefpaint,
|
| 37 |
+
title={PrefPaint: Aligning Image Inpainting Diffusion Model with Human Preference},
|
| 38 |
+
author={Liu, Kendong and Zhu, Zhiyu and Li, Chuanhao and Liu, Hui and Zeng, Huanqiang and Hou, Junhui},
|
| 39 |
+
journal={arXiv preprint arXiv:2410.21966},
|
| 40 |
+
year={2024}
|
| 41 |
+
}
|
| 42 |
```
|