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
543ee1e0
Unverified
Commit
543ee1e0
authored
Aug 09, 2022
by
Suraj Patil
Committed by
GitHub
Aug 09, 2022
Browse files
[LDMTextToImagePipeline] make text model generic (#162)
make text model generic
parent
75b6c165
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
4 deletions
+3
-4
src/diffusers/pipelines/latent_diffusion/pipeline_latent_diffusion.py
...s/pipelines/latent_diffusion/pipeline_latent_diffusion.py
+3
-4
No files found.
src/diffusers/pipelines/latent_diffusion/pipeline_latent_diffusion.py
View file @
543ee1e0
...
...
@@ -45,11 +45,11 @@ class LDMTextToImagePipeline(DiffusionPipeline):
# get unconditional embeddings for classifier free guidance
if
guidance_scale
!=
1.0
:
uncond_input
=
self
.
tokenizer
([
""
]
*
batch_size
,
padding
=
"max_length"
,
max_length
=
77
,
return_tensors
=
"pt"
)
uncond_embeddings
=
self
.
bert
(
uncond_input
.
input_ids
.
to
(
torch_device
))
uncond_embeddings
=
self
.
bert
(
uncond_input
.
input_ids
.
to
(
torch_device
))
[
0
]
# get prompt text embeddings
text_input
=
self
.
tokenizer
(
prompt
,
padding
=
"max_length"
,
max_length
=
77
,
return_tensors
=
"pt"
)
text_embeddings
=
self
.
bert
(
text_input
.
input_ids
.
to
(
torch_device
))
text_embeddings
=
self
.
bert
(
text_input
.
input_ids
.
to
(
torch_device
))
[
0
]
latents
=
torch
.
randn
(
(
batch_size
,
self
.
unet
.
in_channels
,
self
.
unet
.
sample_size
,
self
.
unet
.
sample_size
),
...
...
@@ -618,5 +618,4 @@ class LDMBertModel(LDMBertPreTrainedModel):
output_hidden_states
=
output_hidden_states
,
return_dict
=
return_dict
,
)
sequence_output
=
outputs
[
0
]
return
sequence_output
return
outputs
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