Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
renzhc
diffusers_dcu
Commits
480d8846
Unverified
Commit
480d8846
authored
Jan 25, 2023
by
Suraj Patil
Committed by
GitHub
Jan 25, 2023
Browse files
[doc] update example for pix2pix (#2101)
update example for pix2pix
parent
9dbf78e2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
9 deletions
+7
-9
docs/source/en/api/pipelines/stable_diffusion/pix2pix.mdx
docs/source/en/api/pipelines/stable_diffusion/pix2pix.mdx
+5
-7
src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_instruct_pix2pix.py
...e_diffusion/pipeline_stable_diffusion_instruct_pix2pix.py
+2
-2
No files found.
docs/source/en/api/pipelines/stable_diffusion/pix2pix.mdx
View file @
480d8846
...
...
@@ -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.jp
g"
url = "https://
huggingface.co/datasets/diffusers/diffusers-images-docs/resolve/main/mountain.pn
g"
def download_image(url):
...
...
@@ -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=
1
0, 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=
2
0,
image_
guidance_scale=1.
5
, guidance_scale=
7
).images
[0]
images[0].save("
snowy_mountains
.png")
```
## StableDiffusionInstructPix2PixPipeline
...
...
src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_instruct_pix2pix.py
View file @
480d8846
...
...
@@ -208,7 +208,7 @@ class StableDiffusionInstructPix2PixPipeline(DiffusionPipeline):
... return PIL.Image.open(BytesIO(response.content)).convert("RGB")
>>> img_url = "https://
raw.githubusercontent.com/timothybrooks/instruct-pix2pix/main/imgs/example.jp
g"
>>> img_url = "https://
huggingface.co/datasets/diffusers/diffusers-images-docs/resolve/main/mountain.pn
g"
>>> image = download_image(img_url).resize((512, 512))
...
...
@@ -217,7 +217,7 @@ class StableDiffusionInstructPix2PixPipeline(DiffusionPipeline):
... )
>>> pipe = pipe.to("cuda")
>>> prompt = "
turn him into cyborg
"
>>> prompt = "
make the mountains snowy
"
>>> image = pipe(prompt=prompt, image=image).images[0]
```
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment