Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
diffusers
Commits
4969f465
Unverified
Commit
4969f465
authored
Nov 09, 2022
by
Jesse Casey
Committed by
GitHub
Nov 09, 2022
Browse files
apply `repeat_interleave` fix for `mps` to stable diffusion image2image pipeline (#1135)
copy from other pipeline
parent
6c0335c7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py
...nes/stable_diffusion/pipeline_stable_diffusion_img2img.py
+4
-2
No files found.
src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py
View file @
4969f465
...
@@ -337,8 +337,10 @@ class StableDiffusionImg2ImgPipeline(DiffusionPipeline):
...
@@ -337,8 +337,10 @@ class StableDiffusionImg2ImgPipeline(DiffusionPipeline):
text_input_ids
=
text_input_ids
[:,
:
self
.
tokenizer
.
model_max_length
]
text_input_ids
=
text_input_ids
[:,
:
self
.
tokenizer
.
model_max_length
]
text_embeddings
=
self
.
text_encoder
(
text_input_ids
.
to
(
device
))[
0
]
text_embeddings
=
self
.
text_encoder
(
text_input_ids
.
to
(
device
))[
0
]
# duplicate text embeddings for each generation per prompt
# duplicate text embeddings for each generation per prompt, using mps friendly method
text_embeddings
=
text_embeddings
.
repeat_interleave
(
num_images_per_prompt
,
dim
=
0
)
bs_embed
,
seq_len
,
_
=
text_embeddings
.
shape
text_embeddings
=
text_embeddings
.
repeat
(
1
,
num_images_per_prompt
,
1
)
text_embeddings
=
text_embeddings
.
view
(
bs_embed
*
num_images_per_prompt
,
seq_len
,
-
1
)
# here `guidance_scale` is defined analog to the guidance weight `w` of equation (2)
# here `guidance_scale` is defined analog to the guidance weight `w` of equation (2)
# of the Imagen paper: https://arxiv.org/pdf/2205.11487.pdf . `guidance_scale = 1`
# of the Imagen paper: https://arxiv.org/pdf/2205.11487.pdf . `guidance_scale = 1`
...
...
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