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
50c81df4
Unverified
Commit
50c81df4
authored
Jan 13, 2025
by
hlky
Committed by
GitHub
Jan 13, 2025
Browse files
Fix StableDiffusionInstructPix2PixPipelineSingleFileSlowTests (#10557)
parent
e1c72697
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
2 deletions
+6
-2
src/diffusers/loaders/single_file_utils.py
src/diffusers/loaders/single_file_utils.py
+1
-0
tests/single_file/single_file_testing_utils.py
tests/single_file/single_file_testing_utils.py
+4
-2
tests/single_file/test_stable_diffusion_single_file.py
tests/single_file/test_stable_diffusion_single_file.py
+1
-0
No files found.
src/diffusers/loaders/single_file_utils.py
View file @
50c81df4
...
@@ -186,6 +186,7 @@ DIFFUSERS_TO_LDM_DEFAULT_IMAGE_SIZE_MAP = {
...
@@ -186,6 +186,7 @@ DIFFUSERS_TO_LDM_DEFAULT_IMAGE_SIZE_MAP = {
"inpainting"
:
512
,
"inpainting"
:
512
,
"inpainting_v2"
:
512
,
"inpainting_v2"
:
512
,
"controlnet"
:
512
,
"controlnet"
:
512
,
"instruct-pix2pix"
:
512
,
"v2"
:
768
,
"v2"
:
768
,
"v1"
:
512
,
"v1"
:
512
,
}
}
...
...
tests/single_file/single_file_testing_utils.py
View file @
50c81df4
...
@@ -47,6 +47,8 @@ def download_diffusers_config(repo_id, tmpdir):
...
@@ -47,6 +47,8 @@ def download_diffusers_config(repo_id, tmpdir):
class
SDSingleFileTesterMixin
:
class
SDSingleFileTesterMixin
:
single_file_kwargs
=
{}
def
_compare_component_configs
(
self
,
pipe
,
single_file_pipe
):
def
_compare_component_configs
(
self
,
pipe
,
single_file_pipe
):
for
param_name
,
param_value
in
single_file_pipe
.
text_encoder
.
config
.
to_dict
().
items
():
for
param_name
,
param_value
in
single_file_pipe
.
text_encoder
.
config
.
to_dict
().
items
():
if
param_name
in
[
"torch_dtype"
,
"architectures"
,
"_name_or_path"
]:
if
param_name
in
[
"torch_dtype"
,
"architectures"
,
"_name_or_path"
]:
...
@@ -154,7 +156,7 @@ class SDSingleFileTesterMixin:
...
@@ -154,7 +156,7 @@ class SDSingleFileTesterMixin:
self
.
_compare_component_configs
(
pipe
,
single_file_pipe
)
self
.
_compare_component_configs
(
pipe
,
single_file_pipe
)
def
test_single_file_format_inference_is_same_as_pretrained
(
self
,
expected_max_diff
=
1e-4
):
def
test_single_file_format_inference_is_same_as_pretrained
(
self
,
expected_max_diff
=
1e-4
):
sf_pipe
=
self
.
pipeline_class
.
from_single_file
(
self
.
ckpt_path
,
safety_checker
=
None
)
sf_pipe
=
self
.
pipeline_class
.
from_single_file
(
self
.
ckpt_path
,
safety_checker
=
None
,
**
self
.
single_file_kwargs
)
sf_pipe
.
unet
.
set_attn_processor
(
AttnProcessor
())
sf_pipe
.
unet
.
set_attn_processor
(
AttnProcessor
())
sf_pipe
.
enable_model_cpu_offload
(
device
=
torch_device
)
sf_pipe
.
enable_model_cpu_offload
(
device
=
torch_device
)
...
@@ -170,7 +172,7 @@ class SDSingleFileTesterMixin:
...
@@ -170,7 +172,7 @@ class SDSingleFileTesterMixin:
max_diff
=
numpy_cosine_similarity_distance
(
image
.
flatten
(),
image_single_file
.
flatten
())
max_diff
=
numpy_cosine_similarity_distance
(
image
.
flatten
(),
image_single_file
.
flatten
())
assert
max_diff
<
expected_max_diff
assert
max_diff
<
expected_max_diff
,
f
"
{
image
.
flatten
()
}
!=
{
image_single_file
.
flatten
()
}
"
def
test_single_file_components_with_diffusers_config
(
def
test_single_file_components_with_diffusers_config
(
self
,
self
,
...
...
tests/single_file/test_stable_diffusion_single_file.py
View file @
50c81df4
...
@@ -132,6 +132,7 @@ class StableDiffusionInstructPix2PixPipelineSingleFileSlowTests(unittest.TestCas
...
@@ -132,6 +132,7 @@ class StableDiffusionInstructPix2PixPipelineSingleFileSlowTests(unittest.TestCas
"https://raw.githubusercontent.com/timothybrooks/instruct-pix2pix/refs/heads/main/configs/generate.yaml"
"https://raw.githubusercontent.com/timothybrooks/instruct-pix2pix/refs/heads/main/configs/generate.yaml"
)
)
repo_id
=
"timbrooks/instruct-pix2pix"
repo_id
=
"timbrooks/instruct-pix2pix"
single_file_kwargs
=
{
"extract_ema"
:
True
}
def
setUp
(
self
):
def
setUp
(
self
):
super
().
setUp
()
super
().
setUp
()
...
...
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