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
faa6cbc9
Unverified
Commit
faa6cbc9
authored
Jul 28, 2023
by
kathath
Committed by
GitHub
Jul 28, 2023
Browse files
Fix repeat of negative prompt (#4335)
fix repeat of negative prompt
parent
306a7bd0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
src/diffusers/pipelines/semantic_stable_diffusion/pipeline_semantic_stable_diffusion.py
...ic_stable_diffusion/pipeline_semantic_stable_diffusion.py
+2
-2
No files found.
src/diffusers/pipelines/semantic_stable_diffusion/pipeline_semantic_stable_diffusion.py
View file @
faa6cbc9
...
@@ -442,7 +442,7 @@ class SemanticStableDiffusionPipeline(DiffusionPipeline):
...
@@ -442,7 +442,7 @@ class SemanticStableDiffusionPipeline(DiffusionPipeline):
if
do_classifier_free_guidance
:
if
do_classifier_free_guidance
:
uncond_tokens
:
List
[
str
]
uncond_tokens
:
List
[
str
]
if
negative_prompt
is
None
:
if
negative_prompt
is
None
:
uncond_tokens
=
[
""
]
uncond_tokens
=
[
""
]
*
batch_size
elif
type
(
prompt
)
is
not
type
(
negative_prompt
):
elif
type
(
prompt
)
is
not
type
(
negative_prompt
):
raise
TypeError
(
raise
TypeError
(
f
"`negative_prompt` should be the same type to `prompt`, but got
{
type
(
negative_prompt
)
}
!="
f
"`negative_prompt` should be the same type to `prompt`, but got
{
type
(
negative_prompt
)
}
!="
...
@@ -471,7 +471,7 @@ class SemanticStableDiffusionPipeline(DiffusionPipeline):
...
@@ -471,7 +471,7 @@ class SemanticStableDiffusionPipeline(DiffusionPipeline):
# duplicate unconditional embeddings for each generation per prompt, using mps friendly method
# duplicate unconditional embeddings for each generation per prompt, using mps friendly method
seq_len
=
uncond_embeddings
.
shape
[
1
]
seq_len
=
uncond_embeddings
.
shape
[
1
]
uncond_embeddings
=
uncond_embeddings
.
repeat
(
batch_size
,
num_images_per_prompt
,
1
)
uncond_embeddings
=
uncond_embeddings
.
repeat
(
1
,
num_images_per_prompt
,
1
)
uncond_embeddings
=
uncond_embeddings
.
view
(
batch_size
*
num_images_per_prompt
,
seq_len
,
-
1
)
uncond_embeddings
=
uncond_embeddings
.
view
(
batch_size
*
num_images_per_prompt
,
seq_len
,
-
1
)
# For classifier free guidance, we need to do two forward passes.
# For classifier free guidance, we need to do two forward passes.
...
...
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