Views
No views yet



1pip install accelerate transformers
2pip install git+https://github.com/huggingface/diffusers1import torch
2from diffusers import StableDiffusionXLInstructPix2PixPipeline
3from diffusers.utils import load_image
4
5resolution = 768
6image = load_image(
7 "https://hf.co/datasets/diffusers/diffusers-images-docs/resolve/main/mountain.png"
8).resize((resolution, resolution))
9edit_instruction = "Turn sky into a cloudy one"
10
11pipe = StableDiffusionXLInstructPix2PixPipeline.from_pretrained(
12 "diffusers/sdxl-instructpix2pix-768", torch_dtype=torch.float16
13).to("cuda")
14
15edited_image = pipe(
16 prompt=edit_instruction,
17 image=image,
18 height=resolution,
19 width=resolution,
20 guidance_scale=3.0,
21 image_guidance_scale=1.5,
22 num_inference_steps=30,
23).images[0]
24edited_image.save("edited_image.png")