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
3b66cc0f
Commit
3b66cc0f
authored
Feb 07, 2023
by
Patrick von Platen
Browse files
make style
parent
717a956a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12 additions
and
19 deletions
+12
-19
examples/research_projects/onnxruntime/textual_inversion/textual_inversion.py
...ojects/onnxruntime/textual_inversion/textual_inversion.py
+3
-3
examples/textual_inversion/textual_inversion.py
examples/textual_inversion/textual_inversion.py
+3
-3
src/diffusers/pipelines/alt_diffusion/pipeline_alt_diffusion_img2img.py
...pipelines/alt_diffusion/pipeline_alt_diffusion_img2img.py
+6
-4
src/diffusers/pipelines/stable_diffusion/pipeline_cycle_diffusion.py
...rs/pipelines/stable_diffusion/pipeline_cycle_diffusion.py
+0
-3
src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_depth2img.py
...s/stable_diffusion/pipeline_stable_diffusion_depth2img.py
+0
-3
src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint_legacy.py
...ble_diffusion/pipeline_stable_diffusion_inpaint_legacy.py
+0
-3
No files found.
examples/research_projects/onnxruntime/textual_inversion/textual_inversion.py
View file @
3b66cc0f
...
@@ -752,9 +752,9 @@ def main():
...
@@ -752,9 +752,9 @@ def main():
# Let's make sure we don't update any embedding weights besides the newly added token
# Let's make sure we don't update any embedding weights besides the newly added token
index_no_updates
=
torch
.
arange
(
len
(
tokenizer
))
!=
placeholder_token_id
index_no_updates
=
torch
.
arange
(
len
(
tokenizer
))
!=
placeholder_token_id
with
torch
.
no_grad
():
with
torch
.
no_grad
():
accelerator
.
unwrap_model
(
text_encoder
).
get_input_embeddings
().
weight
[
index_no_updates
]
=
(
accelerator
.
unwrap_model
(
text_encoder
).
get_input_embeddings
().
weight
[
orig_embeds_params
[
index_no_updates
]
index_no_updates
)
]
=
orig_embeds_params
[
index_no_updates
]
# Checks if the accelerator has performed an optimization step behind the scenes
# Checks if the accelerator has performed an optimization step behind the scenes
if
accelerator
.
sync_gradients
:
if
accelerator
.
sync_gradients
:
...
...
examples/textual_inversion/textual_inversion.py
View file @
3b66cc0f
...
@@ -749,9 +749,9 @@ def main():
...
@@ -749,9 +749,9 @@ def main():
# Let's make sure we don't update any embedding weights besides the newly added token
# Let's make sure we don't update any embedding weights besides the newly added token
index_no_updates
=
torch
.
arange
(
len
(
tokenizer
))
!=
placeholder_token_id
index_no_updates
=
torch
.
arange
(
len
(
tokenizer
))
!=
placeholder_token_id
with
torch
.
no_grad
():
with
torch
.
no_grad
():
accelerator
.
unwrap_model
(
text_encoder
).
get_input_embeddings
().
weight
[
index_no_updates
]
=
(
accelerator
.
unwrap_model
(
text_encoder
).
get_input_embeddings
().
weight
[
orig_embeds_params
[
index_no_updates
]
index_no_updates
)
]
=
orig_embeds_params
[
index_no_updates
]
# Checks if the accelerator has performed an optimization step behind the scenes
# Checks if the accelerator has performed an optimization step behind the scenes
if
accelerator
.
sync_gradients
:
if
accelerator
.
sync_gradients
:
...
...
src/diffusers/pipelines/alt_diffusion/pipeline_alt_diffusion_img2img.py
View file @
3b66cc0f
...
@@ -418,9 +418,6 @@ class AltDiffusionImg2ImgPipeline(DiffusionPipeline):
...
@@ -418,9 +418,6 @@ class AltDiffusionImg2ImgPipeline(DiffusionPipeline):
def
check_inputs
(
def
check_inputs
(
self
,
prompt
,
strength
,
callback_steps
,
negative_prompt
=
None
,
prompt_embeds
=
None
,
negative_prompt_embeds
=
None
self
,
prompt
,
strength
,
callback_steps
,
negative_prompt
=
None
,
prompt_embeds
=
None
,
negative_prompt_embeds
=
None
):
):
if
not
isinstance
(
prompt
,
str
)
and
not
isinstance
(
prompt
,
list
):
raise
ValueError
(
f
"`prompt` has to be of type `str` or `list` but is
{
type
(
prompt
)
}
"
)
if
strength
<
0
or
strength
>
1
:
if
strength
<
0
or
strength
>
1
:
raise
ValueError
(
f
"The value of strength should in [0.0, 1.0] but is
{
strength
}
"
)
raise
ValueError
(
f
"The value of strength should in [0.0, 1.0] but is
{
strength
}
"
)
...
@@ -613,7 +610,12 @@ class AltDiffusionImg2ImgPipeline(DiffusionPipeline):
...
@@ -613,7 +610,12 @@ class AltDiffusionImg2ImgPipeline(DiffusionPipeline):
self
.
check_inputs
(
prompt
,
strength
,
callback_steps
,
negative_prompt
,
prompt_embeds
,
negative_prompt_embeds
)
self
.
check_inputs
(
prompt
,
strength
,
callback_steps
,
negative_prompt
,
prompt_embeds
,
negative_prompt_embeds
)
# 2. Define call parameters
# 2. Define call parameters
batch_size
=
1
if
isinstance
(
prompt
,
str
)
else
len
(
prompt
)
if
prompt
is
not
None
and
isinstance
(
prompt
,
str
):
batch_size
=
1
elif
prompt
is
not
None
and
isinstance
(
prompt
,
list
):
batch_size
=
len
(
prompt
)
else
:
batch_size
=
prompt_embeds
.
shape
[
0
]
device
=
self
.
_execution_device
device
=
self
.
_execution_device
# 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`
...
...
src/diffusers/pipelines/stable_diffusion/pipeline_cycle_diffusion.py
View file @
3b66cc0f
...
@@ -403,9 +403,6 @@ class CycleDiffusionPipeline(DiffusionPipeline):
...
@@ -403,9 +403,6 @@ class CycleDiffusionPipeline(DiffusionPipeline):
def
check_inputs
(
def
check_inputs
(
self
,
prompt
,
strength
,
callback_steps
,
negative_prompt
=
None
,
prompt_embeds
=
None
,
negative_prompt_embeds
=
None
self
,
prompt
,
strength
,
callback_steps
,
negative_prompt
=
None
,
prompt_embeds
=
None
,
negative_prompt_embeds
=
None
):
):
if
not
isinstance
(
prompt
,
str
)
and
not
isinstance
(
prompt
,
list
):
raise
ValueError
(
f
"`prompt` has to be of type `str` or `list` but is
{
type
(
prompt
)
}
"
)
if
strength
<
0
or
strength
>
1
:
if
strength
<
0
or
strength
>
1
:
raise
ValueError
(
f
"The value of strength should in [0.0, 1.0] but is
{
strength
}
"
)
raise
ValueError
(
f
"The value of strength should in [0.0, 1.0] but is
{
strength
}
"
)
...
...
src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_depth2img.py
View file @
3b66cc0f
...
@@ -339,9 +339,6 @@ class StableDiffusionDepth2ImgPipeline(DiffusionPipeline):
...
@@ -339,9 +339,6 @@ class StableDiffusionDepth2ImgPipeline(DiffusionPipeline):
def
check_inputs
(
def
check_inputs
(
self
,
prompt
,
strength
,
callback_steps
,
negative_prompt
=
None
,
prompt_embeds
=
None
,
negative_prompt_embeds
=
None
self
,
prompt
,
strength
,
callback_steps
,
negative_prompt
=
None
,
prompt_embeds
=
None
,
negative_prompt_embeds
=
None
):
):
if
not
isinstance
(
prompt
,
str
)
and
not
isinstance
(
prompt
,
list
):
raise
ValueError
(
f
"`prompt` has to be of type `str` or `list` but is
{
type
(
prompt
)
}
"
)
if
strength
<
0
or
strength
>
1
:
if
strength
<
0
or
strength
>
1
:
raise
ValueError
(
f
"The value of strength should in [0.0, 1.0] but is
{
strength
}
"
)
raise
ValueError
(
f
"The value of strength should in [0.0, 1.0] but is
{
strength
}
"
)
...
...
src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint_legacy.py
View file @
3b66cc0f
...
@@ -414,9 +414,6 @@ class StableDiffusionInpaintPipelineLegacy(DiffusionPipeline):
...
@@ -414,9 +414,6 @@ class StableDiffusionInpaintPipelineLegacy(DiffusionPipeline):
def
check_inputs
(
def
check_inputs
(
self
,
prompt
,
strength
,
callback_steps
,
negative_prompt
=
None
,
prompt_embeds
=
None
,
negative_prompt_embeds
=
None
self
,
prompt
,
strength
,
callback_steps
,
negative_prompt
=
None
,
prompt_embeds
=
None
,
negative_prompt_embeds
=
None
):
):
if
not
isinstance
(
prompt
,
str
)
and
not
isinstance
(
prompt
,
list
):
raise
ValueError
(
f
"`prompt` has to be of type `str` or `list` but is
{
type
(
prompt
)
}
"
)
if
strength
<
0
or
strength
>
1
:
if
strength
<
0
or
strength
>
1
:
raise
ValueError
(
f
"The value of strength should in [0.0, 1.0] but is
{
strength
}
"
)
raise
ValueError
(
f
"The value of strength should in [0.0, 1.0] but is
{
strength
}
"
)
...
...
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