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
857c04cf
"...git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "8c31925b3b61dab675404e2b1309cfe0488471cd"
Unverified
Commit
857c04cf
authored
Feb 16, 2023
by
Patrick von Platen
Committed by
GitHub
Feb 16, 2023
Browse files
[Pix2Pix0] Add utility function to get edit vector (#2383)
uP
parent
2e7a2865
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_pix2pix_zero.py
...table_diffusion/pipeline_stable_diffusion_pix2pix_zero.py
+14
-0
No files found.
src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_pix2pix_zero.py
View file @
857c04cf
...
@@ -542,6 +542,20 @@ class StableDiffusionPix2PixZeroPipeline(DiffusionPipeline):
...
@@ -542,6 +542,20 @@ class StableDiffusionPix2PixZeroPipeline(DiffusionPipeline):
"""Constructs the edit direction to steer the image generation process semantically."""
"""Constructs the edit direction to steer the image generation process semantically."""
return
(
embs_target
.
mean
(
0
)
-
embs_source
.
mean
(
0
)).
unsqueeze
(
0
)
return
(
embs_target
.
mean
(
0
)
-
embs_source
.
mean
(
0
)).
unsqueeze
(
0
)
@
torch
.
no_grad
()
def
get_embeds
(
self
,
prompt
:
List
[
str
])
->
torch
.
FloatTensor
:
input_ids
=
self
.
tokenizer
(
prompt
,
padding
=
"max_length"
,
max_length
=
self
.
tokenizer
.
model_max_length
,
truncation
=
True
,
return_tensors
=
"pt"
,
).
input_ids
embeds
=
self
.
text_encoder
(
input_ids
)[
0
]
return
embeds
.
mean
(
0
)[
None
]
@
torch
.
no_grad
()
@
torch
.
no_grad
()
@
replace_example_docstring
(
EXAMPLE_DOC_STRING
)
@
replace_example_docstring
(
EXAMPLE_DOC_STRING
)
def
__call__
(
def
__call__
(
...
...
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