Skip to content

Commit

Permalink
[doc] update example for pix2pix (open-mmlab#2101)
Browse files Browse the repository at this point in the history
update example for pix2pix
  • Loading branch information
patil-suraj authored Jan 25, 2023
1 parent 9dbf78e commit 480d884
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
12 changes: 5 additions & 7 deletions docs/source/en/api/pipelines/stable_diffusion/pix2pix.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,9 @@ import torch
from diffusers import StableDiffusionInstructPix2PixPipeline

model_id = "timbrooks/instruct-pix2pix"
pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(
model_id, torch_dtype=torch.float16, safety_checker=None
).to("cuda")
pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to("cuda")

url = "https://raw.githubusercontent.com/timothybrooks/instruct-pix2pix/main/imgs/example.jpg"
url = "https://huggingface.co/datasets/diffusers/diffusers-images-docs/resolve/main/mountain.png"


def download_image(url):
Expand All @@ -61,9 +59,9 @@ def download_image(url):

image = download_image(url)

prompt = "turn him into a cyborg"
images = pipe(prompt, image=image, num_inference_steps=10, guidance_scale=1.1, image_guidance_scale=1).images
images[0].save("david_cyborg.png")
prompt = "make the mountains snowy"
edit = pipe(prompt, image=image, num_inference_steps=20, image_guidance_scale=1.5, guidance_scale=7).images[0]
images[0].save("snowy_mountains.png")
```

## StableDiffusionInstructPix2PixPipeline
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def __call__(
... return PIL.Image.open(BytesIO(response.content)).convert("RGB")
>>> img_url = "https://raw.githubusercontent.com/timothybrooks/instruct-pix2pix/main/imgs/example.jpg"
>>> img_url = "https://huggingface.co/datasets/diffusers/diffusers-images-docs/resolve/main/mountain.png"
>>> image = download_image(img_url).resize((512, 512))
Expand All @@ -217,7 +217,7 @@ def __call__(
... )
>>> pipe = pipe.to("cuda")
>>> prompt = "turn him into cyborg"
>>> prompt = "make the mountains snowy"
>>> image = pipe(prompt=prompt, image=image).images[0]
```
Expand Down

0 comments on commit 480d884

Please sign in to comment.