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
53051cf2
Unverified
Commit
53051cf2
authored
Sep 05, 2024
by
Dhruv Nair
Committed by
GitHub
Sep 05, 2024
Browse files
[CI] Update Single file Nightly Tests (#9357)
* update * update
parent
30005517
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
77 additions
and
58 deletions
+77
-58
tests/single_file/single_file_testing_utils.py
tests/single_file/single_file_testing_utils.py
+13
-12
tests/single_file/test_stable_diffusion_controlnet_img2img_single_file.py
...e/test_stable_diffusion_controlnet_img2img_single_file.py
+11
-8
tests/single_file/test_stable_diffusion_controlnet_inpaint_single_file.py
...e/test_stable_diffusion_controlnet_inpaint_single_file.py
+12
-9
tests/single_file/test_stable_diffusion_controlnet_single_file.py
...ngle_file/test_stable_diffusion_controlnet_single_file.py
+9
-8
tests/single_file/test_stable_diffusion_img2img_single_file.py
.../single_file/test_stable_diffusion_img2img_single_file.py
+2
-2
tests/single_file/test_stable_diffusion_inpaint_single_file.py
.../single_file/test_stable_diffusion_inpaint_single_file.py
+11
-3
tests/single_file/test_stable_diffusion_single_file.py
tests/single_file/test_stable_diffusion_single_file.py
+5
-4
tests/single_file/test_stable_diffusion_xl_adapter_single_file.py
...ngle_file/test_stable_diffusion_xl_adapter_single_file.py
+7
-6
tests/single_file/test_stable_diffusion_xl_controlnet_single_file.py
...e_file/test_stable_diffusion_xl_controlnet_single_file.py
+7
-6
No files found.
tests/single_file/single_file_testing_utils.py
View file @
53051cf2
...
...
@@ -5,6 +5,7 @@ import requests
import
torch
from
huggingface_hub
import
hf_hub_download
,
snapshot_download
from
diffusers.loaders.single_file_utils
import
_extract_repo_id_and_weights_name
from
diffusers.models.attention_processor
import
AttnProcessor
from
diffusers.utils.testing_utils
import
(
numpy_cosine_similarity_distance
,
...
...
@@ -98,8 +99,8 @@ class SDSingleFileTesterMixin:
pipe
=
pipe
or
self
.
pipeline_class
.
from_pretrained
(
self
.
repo_id
,
safety_checker
=
None
)
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
ckpt_filename
=
self
.
ckpt_path
.
split
(
"/"
)[
-
1
]
local_ckpt_path
=
download_single_file_checkpoint
(
self
.
repo_id
,
ckpt_file
name
,
tmpdir
)
repo_id
,
weight_name
=
_extract_repo_id_and_weights_name
(
self
.
ckpt_path
)
local_ckpt_path
=
download_single_file_checkpoint
(
repo_id
,
weight_
name
,
tmpdir
)
single_file_pipe
=
single_file_pipe
or
self
.
pipeline_class
.
from_single_file
(
local_ckpt_path
,
safety_checker
=
None
,
local_files_only
=
True
...
...
@@ -138,8 +139,8 @@ class SDSingleFileTesterMixin:
upcast_attention
=
pipe
.
unet
.
config
.
upcast_attention
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
ckpt_filename
=
self
.
ckpt_path
.
split
(
"/"
)[
-
1
]
local_ckpt_path
=
download_single_file_checkpoint
(
self
.
repo_id
,
ckpt_file
name
,
tmpdir
)
repo_id
,
weight_name
=
_extract_repo_id_and_weights_name
(
self
.
ckpt_path
)
local_ckpt_path
=
download_single_file_checkpoint
(
repo_id
,
weight_
name
,
tmpdir
)
local_original_config
=
download_original_config
(
self
.
original_config
,
tmpdir
)
single_file_pipe
=
single_file_pipe
or
self
.
pipeline_class
.
from_single_file
(
...
...
@@ -191,8 +192,8 @@ class SDSingleFileTesterMixin:
pipe
=
pipe
or
self
.
pipeline_class
.
from_pretrained
(
self
.
repo_id
,
safety_checker
=
None
)
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
ckpt_filename
=
self
.
ckpt_path
.
split
(
"/"
)[
-
1
]
local_ckpt_path
=
download_single_file_checkpoint
(
self
.
repo_id
,
ckpt_file
name
,
tmpdir
)
repo_id
,
weight_name
=
_extract_repo_id_and_weights_name
(
self
.
ckpt_path
)
local_ckpt_path
=
download_single_file_checkpoint
(
repo_id
,
weight_
name
,
tmpdir
)
local_diffusers_config
=
download_diffusers_config
(
self
.
repo_id
,
tmpdir
)
single_file_pipe
=
single_file_pipe
or
self
.
pipeline_class
.
from_single_file
(
...
...
@@ -286,8 +287,8 @@ class SDXLSingleFileTesterMixin:
pipe
=
pipe
or
self
.
pipeline_class
.
from_pretrained
(
self
.
repo_id
,
safety_checker
=
None
)
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
ckpt_filename
=
self
.
ckpt_path
.
split
(
"/"
)[
-
1
]
local_ckpt_path
=
download_single_file_checkpoint
(
self
.
repo_id
,
ckpt_file
name
,
tmpdir
)
repo_id
,
weight_name
=
_extract_repo_id_and_weights_name
(
self
.
ckpt_path
)
local_ckpt_path
=
download_single_file_checkpoint
(
repo_id
,
weight_
name
,
tmpdir
)
single_file_pipe
=
single_file_pipe
or
self
.
pipeline_class
.
from_single_file
(
local_ckpt_path
,
safety_checker
=
None
,
local_files_only
=
True
...
...
@@ -327,8 +328,8 @@ class SDXLSingleFileTesterMixin:
upcast_attention
=
pipe
.
unet
.
config
.
upcast_attention
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
ckpt_filename
=
self
.
ckpt_path
.
split
(
"/"
)[
-
1
]
local_ckpt_path
=
download_single_file_checkpoint
(
self
.
repo_id
,
ckpt_file
name
,
tmpdir
)
repo_id
,
weight_name
=
_extract_repo_id_and_weights_name
(
self
.
ckpt_path
)
local_ckpt_path
=
download_single_file_checkpoint
(
repo_id
,
weight_
name
,
tmpdir
)
local_original_config
=
download_original_config
(
self
.
original_config
,
tmpdir
)
single_file_pipe
=
single_file_pipe
or
self
.
pipeline_class
.
from_single_file
(
...
...
@@ -364,8 +365,8 @@ class SDXLSingleFileTesterMixin:
pipe
=
pipe
or
self
.
pipeline_class
.
from_pretrained
(
self
.
repo_id
,
safety_checker
=
None
)
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
ckpt_filename
=
self
.
ckpt_path
.
split
(
"/"
)[
-
1
]
local_ckpt_path
=
download_single_file_checkpoint
(
self
.
repo_id
,
ckpt_file
name
,
tmpdir
)
repo_id
,
weight_name
=
_extract_repo_id_and_weights_name
(
self
.
ckpt_path
)
local_ckpt_path
=
download_single_file_checkpoint
(
repo_id
,
weight_
name
,
tmpdir
)
local_diffusers_config
=
download_diffusers_config
(
self
.
repo_id
,
tmpdir
)
single_file_pipe
=
single_file_pipe
or
self
.
pipeline_class
.
from_single_file
(
...
...
tests/single_file/test_stable_diffusion_controlnet_img2img_single_file.py
View file @
53051cf2
...
...
@@ -5,6 +5,7 @@ import unittest
import
torch
from
diffusers
import
ControlNetModel
,
StableDiffusionControlNetPipeline
from
diffusers.loaders.single_file_utils
import
_extract_repo_id_and_weights_name
from
diffusers.utils
import
load_image
from
diffusers.utils.testing_utils
import
(
enable_full_determinism
,
...
...
@@ -29,11 +30,11 @@ enable_full_determinism()
@
require_torch_gpu
class
StableDiffusionControlNetPipelineSingleFileSlowTests
(
unittest
.
TestCase
,
SDSingleFileTesterMixin
):
pipeline_class
=
StableDiffusionControlNetPipeline
ckpt_path
=
"https://huggingface.co/
runwayml/stable-diffusion-v1-5/blob/main/v1-5-pruned-emaonly
.safetensors"
ckpt_path
=
"https://huggingface.co/
Lykon/DreamShaper/blob/main/DreamShaper_8_pruned
.safetensors"
original_config
=
(
"https://raw.githubusercontent.com/CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml"
)
repo_id
=
"
runwayml/stable-diffusion-v1-5
"
repo_id
=
"
Lykon/dreamshaper-8
"
def
setUp
(
self
):
super
().
setUp
()
...
...
@@ -108,8 +109,8 @@ class StableDiffusionControlNetPipelineSingleFileSlowTests(unittest.TestCase, SD
pipe
=
self
.
pipeline_class
.
from_pretrained
(
self
.
repo_id
,
controlnet
=
controlnet
)
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
ckpt_filename
=
self
.
ckpt_path
.
split
(
"/"
)[
-
1
]
local_ckpt_path
=
download_single_file_checkpoint
(
self
.
repo_id
,
ckpt_file
name
,
tmpdir
)
repo_id
,
weights_name
=
_extract_repo_id_and_weights_name
(
self
.
ckpt_path
)
local_ckpt_path
=
download_single_file_checkpoint
(
repo_id
,
weights_
name
,
tmpdir
)
pipe_single_file
=
self
.
pipeline_class
.
from_single_file
(
local_ckpt_path
,
controlnet
=
controlnet
,
safety_checker
=
None
,
local_files_only
=
True
...
...
@@ -136,8 +137,9 @@ class StableDiffusionControlNetPipelineSingleFileSlowTests(unittest.TestCase, SD
)
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
ckpt_filename
=
self
.
ckpt_path
.
split
(
"/"
)[
-
1
]
local_ckpt_path
=
download_single_file_checkpoint
(
self
.
repo_id
,
ckpt_filename
,
tmpdir
)
repo_id
,
weights_name
=
_extract_repo_id_and_weights_name
(
self
.
ckpt_path
)
local_ckpt_path
=
download_single_file_checkpoint
(
repo_id
,
weights_name
,
tmpdir
)
local_original_config
=
download_original_config
(
self
.
original_config
,
tmpdir
)
pipe_single_file
=
self
.
pipeline_class
.
from_single_file
(
...
...
@@ -168,8 +170,9 @@ class StableDiffusionControlNetPipelineSingleFileSlowTests(unittest.TestCase, SD
)
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
ckpt_filename
=
self
.
ckpt_path
.
split
(
"/"
)[
-
1
]
local_ckpt_path
=
download_single_file_checkpoint
(
self
.
repo_id
,
ckpt_filename
,
tmpdir
)
repo_id
,
weights_name
=
_extract_repo_id_and_weights_name
(
self
.
ckpt_path
)
local_ckpt_path
=
download_single_file_checkpoint
(
repo_id
,
weights_name
,
tmpdir
)
local_diffusers_config
=
download_diffusers_config
(
self
.
repo_id
,
tmpdir
)
pipe_single_file
=
self
.
pipeline_class
.
from_single_file
(
...
...
tests/single_file/test_stable_diffusion_controlnet_inpaint_single_file.py
View file @
53051cf2
...
...
@@ -5,6 +5,7 @@ import unittest
import
torch
from
diffusers
import
ControlNetModel
,
StableDiffusionControlNetInpaintPipeline
from
diffusers.loaders.single_file_utils
import
_extract_repo_id_and_weights_name
from
diffusers.utils
import
load_image
from
diffusers.utils.testing_utils
import
(
enable_full_determinism
,
...
...
@@ -28,9 +29,9 @@ enable_full_determinism()
@
require_torch_gpu
class
StableDiffusionControlNetInpaintPipelineSingleFileSlowTests
(
unittest
.
TestCase
,
SDSingleFileTesterMixin
):
pipeline_class
=
StableDiffusionControlNetInpaintPipeline
ckpt_path
=
"https://huggingface.co/
runwayml/stable-diffusion-inpainting/blob/main/sd-v1-5-inpainting.ckpt
"
ckpt_path
=
"https://huggingface.co/
Lykon/DreamShaper/blob/main/DreamShaper_8_INPAINTING.inpainting.safetensors
"
original_config
=
"https://raw.githubusercontent.com/runwayml/stable-diffusion/main/configs/stable-diffusion/v1-inpainting-inference.yaml"
repo_id
=
"
runwayml/stable-diffusion
-inpainting"
repo_id
=
"
Lykon/dreamshaper-8
-inpainting"
def
setUp
(
self
):
super
().
setUp
()
...
...
@@ -83,7 +84,7 @@ class StableDiffusionControlNetInpaintPipelineSingleFileSlowTests(unittest.TestC
output_sf
=
pipe_sf
(
**
inputs
).
images
[
0
]
max_diff
=
numpy_cosine_similarity_distance
(
output_sf
.
flatten
(),
output
.
flatten
())
assert
max_diff
<
1
e-3
assert
max_diff
<
2
e-3
def
test_single_file_components
(
self
):
controlnet
=
ControlNetModel
.
from_pretrained
(
"lllyasviel/control_v11p_sd15_canny"
)
...
...
@@ -103,8 +104,8 @@ class StableDiffusionControlNetInpaintPipelineSingleFileSlowTests(unittest.TestC
pipe
=
self
.
pipeline_class
.
from_pretrained
(
self
.
repo_id
,
safety_checker
=
None
,
controlnet
=
controlnet
)
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
ckpt_filename
=
self
.
ckpt_path
.
split
(
"/"
)[
-
1
]
local_ckpt_path
=
download_single_file_checkpoint
(
self
.
repo_id
,
ckpt_file
name
,
tmpdir
)
repo_id
,
weight_name
=
_extract_repo_id_and_weights_name
(
self
.
ckpt_path
)
local_ckpt_path
=
download_single_file_checkpoint
(
repo_id
,
weight_
name
,
tmpdir
)
pipe_single_file
=
self
.
pipeline_class
.
from_single_file
(
local_ckpt_path
,
controlnet
=
controlnet
,
safety_checker
=
None
,
local_files_only
=
True
...
...
@@ -112,6 +113,7 @@ class StableDiffusionControlNetInpaintPipelineSingleFileSlowTests(unittest.TestC
super
().
_compare_component_configs
(
pipe
,
pipe_single_file
)
@
unittest
.
skip
(
"runwayml original config repo does not exist"
)
def
test_single_file_components_with_original_config
(
self
):
controlnet
=
ControlNetModel
.
from_pretrained
(
"lllyasviel/control_v11p_sd15_canny"
,
variant
=
"fp16"
)
pipe
=
self
.
pipeline_class
.
from_pretrained
(
self
.
repo_id
,
controlnet
=
controlnet
)
...
...
@@ -121,6 +123,7 @@ class StableDiffusionControlNetInpaintPipelineSingleFileSlowTests(unittest.TestC
super
().
_compare_component_configs
(
pipe
,
pipe_single_file
)
@
unittest
.
skip
(
"runwayml original config repo does not exist"
)
def
test_single_file_components_with_original_config_local_files_only
(
self
):
controlnet
=
ControlNetModel
.
from_pretrained
(
"lllyasviel/control_v11p_sd15_canny"
,
torch_dtype
=
torch
.
float16
,
variant
=
"fp16"
...
...
@@ -132,8 +135,8 @@ class StableDiffusionControlNetInpaintPipelineSingleFileSlowTests(unittest.TestC
)
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
ckpt_filename
=
self
.
ckpt_path
.
split
(
"/"
)[
-
1
]
local_ckpt_path
=
download_single_file_checkpoint
(
self
.
repo_id
,
ckpt_file
name
,
tmpdir
)
repo_id
,
weight_name
=
_extract_repo_id_and_weights_name
(
self
.
ckpt_path
)
local_ckpt_path
=
download_single_file_checkpoint
(
repo_id
,
weight_
name
,
tmpdir
)
local_original_config
=
download_original_config
(
self
.
original_config
,
tmpdir
)
pipe_single_file
=
self
.
pipeline_class
.
from_single_file
(
...
...
@@ -169,8 +172,8 @@ class StableDiffusionControlNetInpaintPipelineSingleFileSlowTests(unittest.TestC
)
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
ckpt_filename
=
self
.
ckpt_path
.
split
(
"/"
)[
-
1
]
local_ckpt_path
=
download_single_file_checkpoint
(
self
.
repo_id
,
ckpt_file
name
,
tmpdir
)
repo_id
,
weight_name
=
_extract_repo_id_and_weights_name
(
self
.
ckpt_path
)
local_ckpt_path
=
download_single_file_checkpoint
(
repo_id
,
weight_
name
,
tmpdir
)
local_diffusers_config
=
download_diffusers_config
(
self
.
repo_id
,
tmpdir
)
pipe_single_file
=
self
.
pipeline_class
.
from_single_file
(
...
...
tests/single_file/test_stable_diffusion_controlnet_single_file.py
View file @
53051cf2
...
...
@@ -5,6 +5,7 @@ import unittest
import
torch
from
diffusers
import
ControlNetModel
,
StableDiffusionControlNetPipeline
from
diffusers.loaders.single_file_utils
import
_extract_repo_id_and_weights_name
from
diffusers.utils
import
load_image
from
diffusers.utils.testing_utils
import
(
enable_full_determinism
,
...
...
@@ -28,11 +29,11 @@ enable_full_determinism()
@
require_torch_gpu
class
StableDiffusionControlNetPipelineSingleFileSlowTests
(
unittest
.
TestCase
,
SDSingleFileTesterMixin
):
pipeline_class
=
StableDiffusionControlNetPipeline
ckpt_path
=
"https://huggingface.co/
runwayml/stable-diffusion-v1-5/blob/main/v1-5-pruned-emaonly
.safetensors"
ckpt_path
=
"https://huggingface.co/
Lykon/DreamShaper/blob/main/DreamShaper_8_pruned
.safetensors"
original_config
=
(
"https://raw.githubusercontent.com/CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml"
)
repo_id
=
"
runwayml/stable-diffusion-v1-5
"
repo_id
=
"
Lykon/dreamshaper-8
"
def
setUp
(
self
):
super
().
setUp
()
...
...
@@ -98,8 +99,8 @@ class StableDiffusionControlNetPipelineSingleFileSlowTests(unittest.TestCase, SD
pipe
=
self
.
pipeline_class
.
from_pretrained
(
self
.
repo_id
,
controlnet
=
controlnet
)
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
ckpt_filename
=
self
.
ckpt_path
.
split
(
"/"
)[
-
1
]
local_ckpt_path
=
download_single_file_checkpoint
(
self
.
repo_id
,
ckpt_file
name
,
tmpdir
)
repo_id
,
weight_name
=
_extract_repo_id_and_weights_name
(
self
.
ckpt_path
)
local_ckpt_path
=
download_single_file_checkpoint
(
repo_id
,
weight_
name
,
tmpdir
)
pipe_single_file
=
self
.
pipeline_class
.
from_single_file
(
local_ckpt_path
,
controlnet
=
controlnet
,
local_files_only
=
True
...
...
@@ -126,8 +127,8 @@ class StableDiffusionControlNetPipelineSingleFileSlowTests(unittest.TestCase, SD
)
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
ckpt_filename
=
self
.
ckpt_path
.
split
(
"/"
)[
-
1
]
local_ckpt_path
=
download_single_file_checkpoint
(
self
.
repo_id
,
ckpt_file
name
,
tmpdir
)
repo_id
,
weight_name
=
_extract_repo_id_and_weights_name
(
self
.
ckpt_path
)
local_ckpt_path
=
download_single_file_checkpoint
(
repo_id
,
weight_
name
,
tmpdir
)
local_original_config
=
download_original_config
(
self
.
original_config
,
tmpdir
)
pipe_single_file
=
self
.
pipeline_class
.
from_single_file
(
...
...
@@ -157,8 +158,8 @@ class StableDiffusionControlNetPipelineSingleFileSlowTests(unittest.TestCase, SD
)
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
ckpt_filename
=
self
.
ckpt_path
.
split
(
"/"
)[
-
1
]
local_ckpt_path
=
download_single_file_checkpoint
(
self
.
repo_id
,
ckpt_file
name
,
tmpdir
)
repo_id
,
weight_name
=
_extract_repo_id_and_weights_name
(
self
.
ckpt_path
)
local_ckpt_path
=
download_single_file_checkpoint
(
repo_id
,
weight_
name
,
tmpdir
)
local_diffusers_config
=
download_diffusers_config
(
self
.
repo_id
,
tmpdir
)
pipe_single_file
=
self
.
pipeline_class
.
from_single_file
(
...
...
tests/single_file/test_stable_diffusion_img2img_single_file.py
View file @
53051cf2
...
...
@@ -23,11 +23,11 @@ enable_full_determinism()
@
require_torch_gpu
class
StableDiffusionImg2ImgPipelineSingleFileSlowTests
(
unittest
.
TestCase
,
SDSingleFileTesterMixin
):
pipeline_class
=
StableDiffusionImg2ImgPipeline
ckpt_path
=
"https://huggingface.co/
runwayml/stable-diffusion-v1-5/blob/main/v1-5-pruned-emaonly
.safetensors"
ckpt_path
=
"https://huggingface.co/
Lykon/DreamShaper/blob/main/DreamShaper_8_pruned
.safetensors"
original_config
=
(
"https://raw.githubusercontent.com/CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml"
)
repo_id
=
"
runwayml/stable-diffusion-v1-5
"
repo_id
=
"
Lykon/dreamshaper-8
"
def
setUp
(
self
):
super
().
setUp
()
...
...
tests/single_file/test_stable_diffusion_inpaint_single_file.py
View file @
53051cf2
...
...
@@ -23,9 +23,9 @@ enable_full_determinism()
@
require_torch_gpu
class
StableDiffusionInpaintPipelineSingleFileSlowTests
(
unittest
.
TestCase
,
SDSingleFileTesterMixin
):
pipeline_class
=
StableDiffusionInpaintPipeline
ckpt_path
=
"https://huggingface.co/
runwayml/stable-diffusion-inpainting/blob/main/sd-v1-5-inpainting.ckpt
"
ckpt_path
=
"https://huggingface.co/
Lykon/DreamShaper/blob/main/DreamShaper_8_INPAINTING.inpainting.safetensors
"
original_config
=
"https://raw.githubusercontent.com/runwayml/stable-diffusion/main/configs/stable-diffusion/v1-inpainting-inference.yaml"
repo_id
=
"
runwayml/stable-diffusion
-inpainting"
repo_id
=
"
Lykon/dreamshaper-8
-inpainting"
def
setUp
(
self
):
super
().
setUp
()
...
...
@@ -63,11 +63,19 @@ class StableDiffusionInpaintPipelineSingleFileSlowTests(unittest.TestCase, SDSin
def
test_single_file_loading_4_channel_unet
(
self
):
# Test loading single file inpaint with a 4 channel UNet
ckpt_path
=
"https://huggingface.co/
runwayml/stable-diffusion-v1-5/blob/main/v1-5-pruned-emaonly
.safetensors"
ckpt_path
=
"https://huggingface.co/
Lykon/DreamShaper/blob/main/DreamShaper_8_pruned
.safetensors"
pipe
=
self
.
pipeline_class
.
from_single_file
(
ckpt_path
)
assert
pipe
.
unet
.
config
.
in_channels
==
4
@
unittest
.
skip
(
"runwayml original config has been removed"
)
def
test_single_file_components_with_original_config
(
self
):
return
@
unittest
.
skip
(
"runwayml original config has been removed"
)
def
test_single_file_components_with_original_config_local_files_only
(
self
):
return
@
slow
@
require_torch_gpu
...
...
tests/single_file/test_stable_diffusion_single_file.py
View file @
53051cf2
...
...
@@ -5,6 +5,7 @@ import unittest
import
torch
from
diffusers
import
EulerDiscreteScheduler
,
StableDiffusionPipeline
from
diffusers.loaders.single_file_utils
import
_extract_repo_id_and_weights_name
from
diffusers.utils.testing_utils
import
(
enable_full_determinism
,
require_torch_gpu
,
...
...
@@ -25,11 +26,11 @@ enable_full_determinism()
@
require_torch_gpu
class
StableDiffusionPipelineSingleFileSlowTests
(
unittest
.
TestCase
,
SDSingleFileTesterMixin
):
pipeline_class
=
StableDiffusionPipeline
ckpt_path
=
"https://huggingface.co/
runwayml/stable-diffusion-v1-5/blob/main/v1-5-pruned-emaonly
.safetensors"
ckpt_path
=
"https://huggingface.co/
Lykon/DreamShaper/blob/main/DreamShaper_8_pruned
.safetensors"
original_config
=
(
"https://raw.githubusercontent.com/CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml"
)
repo_id
=
"
runwayml/stable-diffusion-v1-5
"
repo_id
=
"
Lykon/dreamshaper-8
"
def
setUp
(
self
):
super
().
setUp
()
...
...
@@ -58,8 +59,8 @@ class StableDiffusionPipelineSingleFileSlowTests(unittest.TestCase, SDSingleFile
def
test_single_file_legacy_scheduler_loading
(
self
):
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
ckpt_filename
=
self
.
ckpt_path
.
split
(
"/"
)[
-
1
]
local_ckpt_path
=
download_single_file_checkpoint
(
self
.
repo_id
,
ckpt_file
name
,
tmpdir
)
repo_id
,
weight_name
=
_extract_repo_id_and_weights_name
(
self
.
ckpt_path
)
local_ckpt_path
=
download_single_file_checkpoint
(
repo_id
,
weight_
name
,
tmpdir
)
local_original_config
=
download_original_config
(
self
.
original_config
,
tmpdir
)
pipe
=
self
.
pipeline_class
.
from_single_file
(
...
...
tests/single_file/test_stable_diffusion_xl_adapter_single_file.py
View file @
53051cf2
...
...
@@ -8,6 +8,7 @@ from diffusers import (
StableDiffusionXLAdapterPipeline
,
T2IAdapter
,
)
from
diffusers.loaders.single_file_utils
import
_extract_repo_id_and_weights_name
from
diffusers.utils
import
load_image
from
diffusers.utils.testing_utils
import
(
enable_full_determinism
,
...
...
@@ -118,8 +119,8 @@ class StableDiffusionXLAdapterPipelineSingleFileSlowTests(unittest.TestCase, SDX
)
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
ckpt_filename
=
self
.
ckpt_path
.
split
(
"/"
)[
-
1
]
local_ckpt_path
=
download_single_file_checkpoint
(
self
.
repo_id
,
ckpt_file
name
,
tmpdir
)
repo_id
,
weight_name
=
_extract_repo_id_and_weights_name
(
self
.
ckpt_path
)
local_ckpt_path
=
download_single_file_checkpoint
(
repo_id
,
weight_
name
,
tmpdir
)
single_file_pipe
=
self
.
pipeline_class
.
from_single_file
(
local_ckpt_path
,
adapter
=
adapter
,
safety_checker
=
None
,
local_files_only
=
True
...
...
@@ -150,8 +151,8 @@ class StableDiffusionXLAdapterPipelineSingleFileSlowTests(unittest.TestCase, SDX
)
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
ckpt_filename
=
self
.
ckpt_path
.
split
(
"/"
)[
-
1
]
local_ckpt_path
=
download_single_file_checkpoint
(
self
.
repo_id
,
ckpt_file
name
,
tmpdir
)
repo_id
,
weight_name
=
_extract_repo_id_and_weights_name
(
self
.
ckpt_path
)
local_ckpt_path
=
download_single_file_checkpoint
(
repo_id
,
weight_
name
,
tmpdir
)
local_diffusers_config
=
download_diffusers_config
(
self
.
repo_id
,
tmpdir
)
pipe_single_file
=
self
.
pipeline_class
.
from_single_file
(
...
...
@@ -188,8 +189,8 @@ class StableDiffusionXLAdapterPipelineSingleFileSlowTests(unittest.TestCase, SDX
)
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
ckpt_filename
=
self
.
ckpt_path
.
split
(
"/"
)[
-
1
]
local_ckpt_path
=
download_single_file_checkpoint
(
self
.
repo_id
,
ckpt_file
name
,
tmpdir
)
repo_id
,
weight_name
=
_extract_repo_id_and_weights_name
(
self
.
ckpt_path
)
local_ckpt_path
=
download_single_file_checkpoint
(
repo_id
,
weight_
name
,
tmpdir
)
local_original_config
=
download_original_config
(
self
.
original_config
,
tmpdir
)
pipe_single_file
=
self
.
pipeline_class
.
from_single_file
(
...
...
tests/single_file/test_stable_diffusion_xl_controlnet_single_file.py
View file @
53051cf2
...
...
@@ -5,6 +5,7 @@ import unittest
import
torch
from
diffusers
import
ControlNetModel
,
StableDiffusionXLControlNetPipeline
from
diffusers.loaders.single_file_utils
import
_extract_repo_id_and_weights_name
from
diffusers.utils
import
load_image
from
diffusers.utils.testing_utils
import
(
enable_full_determinism
,
...
...
@@ -112,8 +113,8 @@ class StableDiffusionXLControlNetPipelineSingleFileSlowTests(unittest.TestCase,
)
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
ckpt_filename
=
self
.
ckpt_path
.
split
(
"/"
)[
-
1
]
local_ckpt_path
=
download_single_file_checkpoint
(
self
.
repo_id
,
ckpt_file
name
,
tmpdir
)
repo_id
,
weight_name
=
_extract_repo_id_and_weights_name
(
self
.
ckpt_path
)
local_ckpt_path
=
download_single_file_checkpoint
(
repo_id
,
weight_
name
,
tmpdir
)
single_file_pipe
=
self
.
pipeline_class
.
from_single_file
(
local_ckpt_path
,
controlnet
=
controlnet
,
safety_checker
=
None
,
local_files_only
=
True
...
...
@@ -151,8 +152,8 @@ class StableDiffusionXLControlNetPipelineSingleFileSlowTests(unittest.TestCase,
)
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
ckpt_filename
=
self
.
ckpt_path
.
split
(
"/"
)[
-
1
]
local_ckpt_path
=
download_single_file_checkpoint
(
self
.
repo_id
,
ckpt_file
name
,
tmpdir
)
repo_id
,
weight_name
=
_extract_repo_id_and_weights_name
(
self
.
ckpt_path
)
local_ckpt_path
=
download_single_file_checkpoint
(
repo_id
,
weight_
name
,
tmpdir
)
pipe_single_file
=
self
.
pipeline_class
.
from_single_file
(
local_ckpt_path
,
...
...
@@ -183,8 +184,8 @@ class StableDiffusionXLControlNetPipelineSingleFileSlowTests(unittest.TestCase,
)
with
tempfile
.
TemporaryDirectory
()
as
tmpdir
:
ckpt_filename
=
self
.
ckpt_path
.
split
(
"/"
)[
-
1
]
local_ckpt_path
=
download_single_file_checkpoint
(
self
.
repo_id
,
ckpt_file
name
,
tmpdir
)
repo_id
,
weight_name
=
_extract_repo_id_and_weights_name
(
self
.
ckpt_path
)
local_ckpt_path
=
download_single_file_checkpoint
(
repo_id
,
weight_
name
,
tmpdir
)
local_diffusers_config
=
download_diffusers_config
(
self
.
repo_id
,
tmpdir
)
pipe_single_file
=
self
.
pipeline_class
.
from_single_file
(
...
...
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