许可协议: cc
标签:
- 图像到图像
数据集:
- peter-sushko/RealEdit
管道类型: 图像到图像
REALEDIT: 将Reddit编辑作为图像变换的大规模实证数据集
项目页面: https://peter-sushko.github.io/RealEdit/
数据: https://huggingface.co/datasets/peter-sushko/RealEdit
有两种运行推理的方式:通过Diffusers或原始的InstructPix2Pix管道。
选项1:使用🧨Diffusers:
安装必要的库:
pip install torch==2.7.0 diffusers==0.33.1 transformers==4.51.3 accelerate==1.6.0 pillow==11.2.1 requests==2.32.3
然后运行:
import torch
import requests
import PIL
from diffusers import StableDiffusionInstructPix2PixPipeline, EulerAncestralDiscreteScheduler
model_id = "peter-sushko/RealEdit"
pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(
model_id,
torch_dtype=torch.float16,
safety_checker=None
)
pipe.to("cuda")
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
url = "https://raw.githubusercontent.com/AyanaBharadwaj/RealEdit/refs/heads/main/example_imgs/simba.jpg"
def download_image(url):
image = PIL.Image.open(requests.get(url, stream=True).raw)
image = PIL.ImageOps.exif_transpose(image)
image = image.convert("RGB")
return image
image = download_image(url)
prompt = "给他戴上王冠"
result = pipe(prompt, image=image, num_inference_steps=50, image_guidance_scale=2).images[0]
result.save("output.png")
选项2:通过InstructPix2Pix管道:
克隆仓库并设置目录结构:
git clone https://github.com/timothybrooks/instruct-pix2pix.git
cd instruct-pix2pix
mkdir checkpoints
将微调后的检查点下载到checkpoints
目录:
cd checkpoints
返回仓库根目录,按照InstructPix2Pix安装指南设置环境。
编辑单张图片
python edit_cli.py \
--input [你的图片路径] \
--output imgs/output.jpg \
--edit "你的编辑指令" \
--ckpt checkpoints/realedit_model.ckpt
引用
如果你觉得这个检查点有帮助,请引用:
@misc{sushko2025realeditredditeditslargescale,
title={REALEDIT: 将Reddit编辑作为图像变换的大规模实证数据集},
author={Peter Sushko and Ayana Bharadwaj and Zhi Yang Lim and Vasily Ilin and Ben Caffee and Dongping Chen and Mohammadreza Salehi and Cheng-Yu Hsieh and Ranjay Krishna},
year={2025},
eprint={2502.03629},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2502.03629},
}