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
45572c24
Unverified
Commit
45572c24
authored
Feb 19, 2023
by
YiYi Xu
Committed by
GitHub
Feb 19, 2023
Browse files
fix the get_indices function (#2418)
Co-authored-by:
yiyixuxu
<
yixu310@gmail,com
>
parent
5f65ef4d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
1 deletion
+2
-1
src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_attend_and_excite.py
..._diffusion/pipeline_stable_diffusion_attend_and_excite.py
+2
-1
No files found.
src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_attend_and_excite.py
View file @
45572c24
...
...
@@ -47,6 +47,7 @@ EXAMPLE_DOC_STRING = """
>>> # use get_indices function to find out indices of the tokens you want to alter
>>> pipe.get_indices(prompt)
{0: '<|startoftext|>', 1: 'a</w>', 2: 'cat</w>', 3: 'and</w>', 4: 'a</w>', 5: 'frog</w>', 6: '<|endoftext|>'}
>>> token_indices = [2, 5]
>>> seed = 6141
...
...
@@ -662,7 +663,7 @@ class StableDiffusionAttendAndExcitePipeline(DiffusionPipeline):
def
get_indices
(
self
,
prompt
:
str
)
->
Dict
[
str
,
int
]:
"""Utility function to list the indices of the tokens you wish to alte"""
ids
=
self
.
tokenizer
(
prompt
).
input_ids
indices
=
{
tok
:
i
for
tok
,
i
in
zip
(
self
.
tokenizer
.
convert_ids_to_tokens
(
ids
),
range
(
len
(
ids
)))}
indices
=
{
i
:
tok
for
tok
,
i
in
zip
(
self
.
tokenizer
.
convert_ids_to_tokens
(
ids
),
range
(
len
(
ids
)))}
return
indices
@
torch
.
no_grad
()
...
...
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