Upload folder using huggingface_hub
Browse files- text_outputs_single_file/test_model_controlnet_single_file_output.txt +10 -0
- text_outputs_single_file/test_model_sd_cascade_unet_single_file_output.txt +10 -0
- text_outputs_single_file/test_model_vae_single_file_output.txt +49 -0
- text_outputs_single_file/test_stable_diffusion_controlnet_img2img_single_file_output.txt +11 -0
- text_outputs_single_file/test_stable_diffusion_controlnet_inpaint_single_file_output.txt +238 -0
- text_outputs_single_file/test_stable_diffusion_controlnet_single_file_output.txt +11 -0
- text_outputs_single_file/test_stable_diffusion_img2img_single_file_output.txt +20 -0
- text_outputs_single_file/test_stable_diffusion_inpaint_single_file_output.txt +311 -0
- text_outputs_single_file/test_stable_diffusion_single_file_output.txt +61 -0
- text_outputs_single_file/test_stable_diffusion_upscale_single_file_output.txt +307 -0
- text_outputs_single_file/test_stable_diffusion_xl_adapter_single_file_output.txt +11 -0
- text_outputs_single_file/test_stable_diffusion_xl_controlnet_single_file_output.txt +11 -0
- text_outputs_single_file/test_stable_diffusion_xl_img2img_single_file_output.txt +11 -0
- text_outputs_single_file/test_stable_diffusion_xl_instruct_pix2pix_output.txt +423 -0
- text_outputs_single_file/test_stable_diffusion_xl_single_file_output.txt +10 -0
text_outputs_single_file/test_model_controlnet_single_file_output.txt
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
============================= test session starts ==============================
|
2 |
+
platform linux -- Python 3.8.10, pytest-8.2.0, pluggy-1.5.0
|
3 |
+
rootdir: /diffusers
|
4 |
+
configfile: pyproject.toml
|
5 |
+
plugins: xdist-3.6.1, timeout-2.3.1, requests-mock-1.10.0
|
6 |
+
collected 2 items
|
7 |
+
|
8 |
+
tests/single_file/test_model_controlnet_single_file.py .. [100%]
|
9 |
+
|
10 |
+
============================== 2 passed in 5.30s ===============================
|
text_outputs_single_file/test_model_sd_cascade_unet_single_file_output.txt
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
============================= test session starts ==============================
|
2 |
+
platform linux -- Python 3.8.10, pytest-8.2.0, pluggy-1.5.0
|
3 |
+
rootdir: /diffusers
|
4 |
+
configfile: pyproject.toml
|
5 |
+
plugins: xdist-3.6.1, timeout-2.3.1, requests-mock-1.10.0
|
6 |
+
collected 4 items
|
7 |
+
|
8 |
+
tests/single_file/test_model_sd_cascade_unet_single_file.py .... [100%]
|
9 |
+
|
10 |
+
======================== 4 passed in 193.05s (0:03:13) =========================
|
text_outputs_single_file/test_model_vae_single_file_output.txt
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
============================= test session starts ==============================
|
2 |
+
platform linux -- Python 3.8.10, pytest-8.2.0, pluggy-1.5.0
|
3 |
+
rootdir: /diffusers
|
4 |
+
configfile: pyproject.toml
|
5 |
+
plugins: xdist-3.6.1, timeout-2.3.1, requests-mock-1.10.0
|
6 |
+
collected 3 items
|
7 |
+
|
8 |
+
tests/single_file/test_model_vae_single_file.py ..F [100%]
|
9 |
+
|
10 |
+
=================================== FAILURES ===================================
|
11 |
+
__ AutoencoderKLSingleFileTests.test_single_file_inference_same_as_pretrained __
|
12 |
+
|
13 |
+
self = <tests.single_file.test_model_vae_single_file.AutoencoderKLSingleFileTests testMethod=test_single_file_inference_same_as_pretrained>
|
14 |
+
|
15 |
+
def test_single_file_inference_same_as_pretrained(self):
|
16 |
+
model_1 = self.model_class.from_pretrained(self.repo_id, subfolder="vae").to(torch_device)
|
17 |
+
model_2 = self.model_class.from_single_file(self.ckpt_path).to(torch_device)
|
18 |
+
|
19 |
+
image = self.get_sd_image(33)
|
20 |
+
|
21 |
+
with torch.no_grad():
|
22 |
+
sample_1 = model_1(image).sample
|
23 |
+
sample_2 = model_2(image).sample
|
24 |
+
|
25 |
+
assert sample_1.shape == sample_2.shape
|
26 |
+
|
27 |
+
output_slice_1 = sample_1[-1, -2:, -2:, :2].flatten().float().cpu()
|
28 |
+
output_slice_2 = sample_2[-1, -2:, -2:, :2].flatten().float().cpu()
|
29 |
+
|
30 |
+
> assert torch_all_close(output_slice_1, output_slice_2, atol=3e-3)
|
31 |
+
|
32 |
+
tests/single_file/test_model_vae_single_file.py:81:
|
33 |
+
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
34 |
+
|
35 |
+
a = tensor([-0.1609, 0.9866, -0.0487, -0.0777, -0.2716, 0.8368, -0.2055, -0.0814])
|
36 |
+
b = tensor([-0.1320, -0.0016, 0.0303, 0.0990, -0.1214, -0.1188, -0.0463, -0.0008])
|
37 |
+
args = (), kwargs = {'atol': 0.003}
|
38 |
+
|
39 |
+
def torch_all_close(a, b, *args, **kwargs):
|
40 |
+
if not is_torch_available():
|
41 |
+
raise ValueError("PyTorch needs to be installed to use this function.")
|
42 |
+
if not torch.allclose(a, b, *args, **kwargs):
|
43 |
+
> assert False, f"Max diff is absolute {(a - b).abs().max()}. Diff tensor is {(a - b).abs()}."
|
44 |
+
E AssertionError: Max diff is absolute 0.9882212281227112. Diff tensor is tensor([0.0288, 0.9882, 0.0790, 0.1767, 0.1501, 0.9556, 0.1592, 0.0806]).
|
45 |
+
|
46 |
+
src/diffusers/utils/testing_utils.py:97: AssertionError
|
47 |
+
=========================== short test summary info ============================
|
48 |
+
FAILED tests/single_file/test_model_vae_single_file.py::AutoencoderKLSingleFileTests::test_single_file_inference_same_as_pretrained
|
49 |
+
========================= 1 failed, 2 passed in 17.25s =========================
|
text_outputs_single_file/test_stable_diffusion_controlnet_img2img_single_file_output.txt
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
============================= test session starts ==============================
|
2 |
+
platform linux -- Python 3.8.10, pytest-8.2.0, pluggy-1.5.0
|
3 |
+
rootdir: /diffusers
|
4 |
+
configfile: pyproject.toml
|
5 |
+
plugins: xdist-3.6.1, timeout-2.3.1, requests-mock-1.10.0
|
6 |
+
collected 7 items
|
7 |
+
|
8 |
+
tests/single_file/test_stable_diffusion_controlnet_img2img_single_file.py . [ 14%]
|
9 |
+
...... [100%]
|
10 |
+
|
11 |
+
======================== 7 passed in 182.23s (0:03:02) =========================
|
text_outputs_single_file/test_stable_diffusion_controlnet_inpaint_single_file_output.txt
ADDED
@@ -0,0 +1,238 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
============================= test session starts ==============================
|
2 |
+
platform linux -- Python 3.8.10, pytest-8.2.0, pluggy-1.5.0
|
3 |
+
rootdir: /diffusers
|
4 |
+
configfile: pyproject.toml
|
5 |
+
plugins: xdist-3.6.1, timeout-2.3.1, requests-mock-1.10.0
|
6 |
+
collected 7 items
|
7 |
+
|
8 |
+
tests/single_file/test_stable_diffusion_controlnet_inpaint_single_file.py . [ 14%]
|
9 |
+
...FF. [100%]
|
10 |
+
|
11 |
+
=================================== FAILURES ===================================
|
12 |
+
_ StableDiffusionControlNetInpaintPipelineSingleFileSlowTests.test_single_file_components_with_original_config _
|
13 |
+
|
14 |
+
self = <tests.single_file.test_stable_diffusion_controlnet_inpaint_single_file.StableDiffusionControlNetInpaintPipelineSingleFileSlowTests testMethod=test_single_file_components_with_original_config>
|
15 |
+
|
16 |
+
def test_single_file_components_with_original_config(self):
|
17 |
+
controlnet = ControlNetModel.from_pretrained("lllyasviel/control_v11p_sd15_canny", variant="fp16")
|
18 |
+
pipe = self.pipeline_class.from_pretrained(self.repo_id, controlnet=controlnet)
|
19 |
+
pipe_single_file = self.pipeline_class.from_single_file(
|
20 |
+
self.ckpt_path, controlnet=controlnet, original_config=self.original_config
|
21 |
+
)
|
22 |
+
|
23 |
+
> super()._compare_component_configs(pipe, pipe_single_file)
|
24 |
+
|
25 |
+
tests/single_file/test_stable_diffusion_controlnet_inpaint_single_file.py:122:
|
26 |
+
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
27 |
+
|
28 |
+
self = <tests.single_file.test_stable_diffusion_controlnet_inpaint_single_file.StableDiffusionControlNetInpaintPipelineSingleFileSlowTests testMethod=test_single_file_components_with_original_config>
|
29 |
+
pipe = StableDiffusionControlNetInpaintPipeline {
|
30 |
+
"_class_name": "StableDiffusionControlNetInpaintPipeline",
|
31 |
+
"_diffusers_... ],
|
32 |
+
"unet": [
|
33 |
+
"diffusers",
|
34 |
+
"UNet2DConditionModel"
|
35 |
+
],
|
36 |
+
"vae": [
|
37 |
+
"diffusers",
|
38 |
+
"AutoencoderKL"
|
39 |
+
]
|
40 |
+
}
|
41 |
+
|
42 |
+
single_file_pipe = StableDiffusionControlNetInpaintPipeline {
|
43 |
+
"_class_name": "StableDiffusionControlNetInpaintPipeline",
|
44 |
+
"_diffusers_... ],
|
45 |
+
"unet": [
|
46 |
+
"diffusers",
|
47 |
+
"UNet2DConditionModel"
|
48 |
+
],
|
49 |
+
"vae": [
|
50 |
+
"diffusers",
|
51 |
+
"AutoencoderKL"
|
52 |
+
]
|
53 |
+
}
|
54 |
+
|
55 |
+
|
56 |
+
def _compare_component_configs(self, pipe, single_file_pipe):
|
57 |
+
for param_name, param_value in single_file_pipe.text_encoder.config.to_dict().items():
|
58 |
+
if param_name in ["torch_dtype", "architectures", "_name_or_path"]:
|
59 |
+
continue
|
60 |
+
assert pipe.text_encoder.config.to_dict()[param_name] == param_value
|
61 |
+
|
62 |
+
PARAMS_TO_IGNORE = [
|
63 |
+
"torch_dtype",
|
64 |
+
"_name_or_path",
|
65 |
+
"architectures",
|
66 |
+
"_use_default_values",
|
67 |
+
"_diffusers_version",
|
68 |
+
]
|
69 |
+
for component_name, component in single_file_pipe.components.items():
|
70 |
+
if component_name in single_file_pipe._optional_components:
|
71 |
+
continue
|
72 |
+
|
73 |
+
# skip testing transformer based components here
|
74 |
+
# skip text encoders / safety checkers since they have already been tested
|
75 |
+
if component_name in ["text_encoder", "tokenizer", "safety_checker", "feature_extractor"]:
|
76 |
+
continue
|
77 |
+
|
78 |
+
assert component_name in pipe.components, f"single file {component_name} not found in pretrained pipeline"
|
79 |
+
assert isinstance(
|
80 |
+
component, pipe.components[component_name].__class__
|
81 |
+
), f"single file {component.__class__.__name__} and pretrained {pipe.components[component_name].__class__.__name__} are not the same"
|
82 |
+
|
83 |
+
for param_name, param_value in component.config.items():
|
84 |
+
if param_name in PARAMS_TO_IGNORE:
|
85 |
+
continue
|
86 |
+
|
87 |
+
# Some pretrained configs will set upcast attention to None
|
88 |
+
# In single file loading it defaults to the value in the class __init__ which is False
|
89 |
+
if param_name == "upcast_attention" and pipe.components[component_name].config[param_name] is None:
|
90 |
+
pipe.components[component_name].config[param_name] = param_value
|
91 |
+
|
92 |
+
> assert (
|
93 |
+
pipe.components[component_name].config[param_name] == param_value
|
94 |
+
), f"single file {param_name}: {param_value} differs from pretrained {pipe.components[component_name].config[param_name]}"
|
95 |
+
E AssertionError: single file sample_size: 512 differs from pretrained 256
|
96 |
+
|
97 |
+
tests/single_file/single_file_testing_utils.py:85: AssertionError
|
98 |
+
----------------------------- Captured stderr call -----------------------------
|
99 |
+
safety_checker/model.safetensors not found
|
100 |
+
|
101 |
+
Loading pipeline components...: 0%| | 0/7 [00:00<?, ?it/s]
|
102 |
+
Loading pipeline components...: 14%|█▍ | 1/7 [00:00<00:01, 3.93it/s]
|
103 |
+
Loading pipeline components...: 29%|██▊ | 2/7 [00:00<00:01, 4.50it/s]
|
104 |
+
Loading pipeline components...: 57%|█████▋ | 4/7 [00:00<00:00, 4.44it/s]
|
105 |
+
Loading pipeline components...: 71%|███████▏ | 5/7 [00:02<00:01, 1.64it/s]
|
106 |
+
Loading pipeline components...: 100%|██████████| 7/7 [00:02<00:00, 2.94it/s]
|
107 |
+
|
108 |
+
Fetching 12 files: 0%| | 0/12 [00:00<?, ?it/s]
|
109 |
+
Fetching 12 files: 100%|██████████| 12/12 [00:00<00:00, 105517.08it/s]
|
110 |
+
|
111 |
+
Loading pipeline components...: 0%| | 0/6 [00:00<?, ?it/s]Some weights of the model checkpoint were not used when initializing CLIPTextModel:
|
112 |
+
['text_model.embeddings.position_ids']
|
113 |
+
|
114 |
+
Loading pipeline components...: 50%|█████ | 3/6 [00:00<00:00, 19.29it/s]
|
115 |
+
Loading pipeline components...: 83%|████████▎ | 5/6 [00:00<00:00, 6.71it/s]
|
116 |
+
Loading pipeline components...: 100%|██████████| 6/6 [00:00<00:00, 8.21it/s]
|
117 |
+
You have disabled the safety checker for <class 'diffusers.pipelines.controlnet.pipeline_controlnet_inpaint.StableDiffusionControlNetInpaintPipeline'> by passing `safety_checker=None`. Ensure that you abide to the conditions of the Stable Diffusion license and do not expose unfiltered results in services or applications open to the public. Both the diffusers team and Hugging Face strongly recommend to keep the safety filter enabled in all public facing circumstances, disabling it only for use-cases that involve analyzing network behavior or auditing its results. For more information, please have a look at https://github.com/huggingface/diffusers/pull/254 .
|
118 |
+
_ StableDiffusionControlNetInpaintPipelineSingleFileSlowTests.test_single_file_components_with_original_config_local_files_only _
|
119 |
+
|
120 |
+
self = <tests.single_file.test_stable_diffusion_controlnet_inpaint_single_file.StableDiffusionControlNetInpaintPipelineSingleFileSlowTests testMethod=test_single_file_components_with_original_config_local_files_only>
|
121 |
+
|
122 |
+
def test_single_file_components_with_original_config_local_files_only(self):
|
123 |
+
controlnet = ControlNetModel.from_pretrained(
|
124 |
+
"lllyasviel/control_v11p_sd15_canny", torch_dtype=torch.float16, variant="fp16"
|
125 |
+
)
|
126 |
+
pipe = self.pipeline_class.from_pretrained(
|
127 |
+
self.repo_id,
|
128 |
+
controlnet=controlnet,
|
129 |
+
safety_checker=None,
|
130 |
+
)
|
131 |
+
|
132 |
+
with tempfile.TemporaryDirectory() as tmpdir:
|
133 |
+
ckpt_filename = self.ckpt_path.split("/")[-1]
|
134 |
+
local_ckpt_path = download_single_file_checkpoint(self.repo_id, ckpt_filename, tmpdir)
|
135 |
+
local_original_config = download_original_config(self.original_config, tmpdir)
|
136 |
+
|
137 |
+
pipe_single_file = self.pipeline_class.from_single_file(
|
138 |
+
local_ckpt_path,
|
139 |
+
original_config=local_original_config,
|
140 |
+
controlnet=controlnet,
|
141 |
+
safety_checker=None,
|
142 |
+
local_files_only=True,
|
143 |
+
)
|
144 |
+
> super()._compare_component_configs(pipe, pipe_single_file)
|
145 |
+
|
146 |
+
tests/single_file/test_stable_diffusion_controlnet_inpaint_single_file.py:146:
|
147 |
+
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
148 |
+
|
149 |
+
self = <tests.single_file.test_stable_diffusion_controlnet_inpaint_single_file.StableDiffusionControlNetInpaintPipelineSingleFileSlowTests testMethod=test_single_file_components_with_original_config_local_files_only>
|
150 |
+
pipe = StableDiffusionControlNetInpaintPipeline {
|
151 |
+
"_class_name": "StableDiffusionControlNetInpaintPipeline",
|
152 |
+
"_diffusers_... ],
|
153 |
+
"unet": [
|
154 |
+
"diffusers",
|
155 |
+
"UNet2DConditionModel"
|
156 |
+
],
|
157 |
+
"vae": [
|
158 |
+
"diffusers",
|
159 |
+
"AutoencoderKL"
|
160 |
+
]
|
161 |
+
}
|
162 |
+
|
163 |
+
single_file_pipe = StableDiffusionControlNetInpaintPipeline {
|
164 |
+
"_class_name": "StableDiffusionControlNetInpaintPipeline",
|
165 |
+
"_diffusers_... ],
|
166 |
+
"unet": [
|
167 |
+
"diffusers",
|
168 |
+
"UNet2DConditionModel"
|
169 |
+
],
|
170 |
+
"vae": [
|
171 |
+
"diffusers",
|
172 |
+
"AutoencoderKL"
|
173 |
+
]
|
174 |
+
}
|
175 |
+
|
176 |
+
|
177 |
+
def _compare_component_configs(self, pipe, single_file_pipe):
|
178 |
+
for param_name, param_value in single_file_pipe.text_encoder.config.to_dict().items():
|
179 |
+
if param_name in ["torch_dtype", "architectures", "_name_or_path"]:
|
180 |
+
continue
|
181 |
+
assert pipe.text_encoder.config.to_dict()[param_name] == param_value
|
182 |
+
|
183 |
+
PARAMS_TO_IGNORE = [
|
184 |
+
"torch_dtype",
|
185 |
+
"_name_or_path",
|
186 |
+
"architectures",
|
187 |
+
"_use_default_values",
|
188 |
+
"_diffusers_version",
|
189 |
+
]
|
190 |
+
for component_name, component in single_file_pipe.components.items():
|
191 |
+
if component_name in single_file_pipe._optional_components:
|
192 |
+
continue
|
193 |
+
|
194 |
+
# skip testing transformer based components here
|
195 |
+
# skip text encoders / safety checkers since they have already been tested
|
196 |
+
if component_name in ["text_encoder", "tokenizer", "safety_checker", "feature_extractor"]:
|
197 |
+
continue
|
198 |
+
|
199 |
+
assert component_name in pipe.components, f"single file {component_name} not found in pretrained pipeline"
|
200 |
+
assert isinstance(
|
201 |
+
component, pipe.components[component_name].__class__
|
202 |
+
), f"single file {component.__class__.__name__} and pretrained {pipe.components[component_name].__class__.__name__} are not the same"
|
203 |
+
|
204 |
+
for param_name, param_value in component.config.items():
|
205 |
+
if param_name in PARAMS_TO_IGNORE:
|
206 |
+
continue
|
207 |
+
|
208 |
+
# Some pretrained configs will set upcast attention to None
|
209 |
+
# In single file loading it defaults to the value in the class __init__ which is False
|
210 |
+
if param_name == "upcast_attention" and pipe.components[component_name].config[param_name] is None:
|
211 |
+
pipe.components[component_name].config[param_name] = param_value
|
212 |
+
|
213 |
+
> assert (
|
214 |
+
pipe.components[component_name].config[param_name] == param_value
|
215 |
+
), f"single file {param_name}: {param_value} differs from pretrained {pipe.components[component_name].config[param_name]}"
|
216 |
+
E AssertionError: single file sample_size: 512 differs from pretrained 256
|
217 |
+
|
218 |
+
tests/single_file/single_file_testing_utils.py:85: AssertionError
|
219 |
+
----------------------------- Captured stderr call -----------------------------
|
220 |
+
text_encoder/model.safetensors not found
|
221 |
+
|
222 |
+
Loading pipeline components...: 0%| | 0/6 [00:00<?, ?it/s]
|
223 |
+
Loading pipeline components...: 17%|█▋ | 1/6 [00:00<00:01, 4.19it/s]
|
224 |
+
Loading pipeline components...: 33%|███▎ | 2/6 [00:00<00:00, 4.67it/s]
|
225 |
+
Loading pipeline components...: 67%|██████▋ | 4/6 [00:01<00:00, 2.04it/s]
|
226 |
+
Loading pipeline components...: 100%|██████████| 6/6 [00:01<00:00, 3.43it/s]
|
227 |
+
You have disabled the safety checker for <class 'diffusers.pipelines.controlnet.pipeline_controlnet_inpaint.StableDiffusionControlNetInpaintPipeline'> by passing `safety_checker=None`. Ensure that you abide to the conditions of the Stable Diffusion license and do not expose unfiltered results in services or applications open to the public. Both the diffusers team and Hugging Face strongly recommend to keep the safety filter enabled in all public facing circumstances, disabling it only for use-cases that involve analyzing network behavior or auditing its results. For more information, please have a look at https://github.com/huggingface/diffusers/pull/254 .
|
228 |
+
|
229 |
+
Loading pipeline components...: 0%| | 0/6 [00:00<?, ?it/s]Some weights of the model checkpoint were not used when initializing CLIPTextModel:
|
230 |
+
['text_model.embeddings.position_ids']
|
231 |
+
|
232 |
+
Loading pipeline components...: 67%|██████▋ | 4/6 [00:00<00:00, 23.42it/s]
|
233 |
+
Loading pipeline components...: 100%|██████████| 6/6 [00:00<00:00, 10.34it/s]
|
234 |
+
You have disabled the safety checker for <class 'diffusers.pipelines.controlnet.pipeline_controlnet_inpaint.StableDiffusionControlNetInpaintPipeline'> by passing `safety_checker=None`. Ensure that you abide to the conditions of the Stable Diffusion license and do not expose unfiltered results in services or applications open to the public. Both the diffusers team and Hugging Face strongly recommend to keep the safety filter enabled in all public facing circumstances, disabling it only for use-cases that involve analyzing network behavior or auditing its results. For more information, please have a look at https://github.com/huggingface/diffusers/pull/254 .
|
235 |
+
=========================== short test summary info ============================
|
236 |
+
FAILED tests/single_file/test_stable_diffusion_controlnet_inpaint_single_file.py::StableDiffusionControlNetInpaintPipelineSingleFileSlowTests::test_single_file_components_with_original_config
|
237 |
+
FAILED tests/single_file/test_stable_diffusion_controlnet_inpaint_single_file.py::StableDiffusionControlNetInpaintPipelineSingleFileSlowTests::test_single_file_components_with_original_config_local_files_only
|
238 |
+
=================== 2 failed, 5 passed in 226.26s (0:03:46) ====================
|
text_outputs_single_file/test_stable_diffusion_controlnet_single_file_output.txt
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
============================= test session starts ==============================
|
2 |
+
platform linux -- Python 3.8.10, pytest-8.2.0, pluggy-1.5.0
|
3 |
+
rootdir: /diffusers
|
4 |
+
configfile: pyproject.toml
|
5 |
+
plugins: xdist-3.6.1, timeout-2.3.1, requests-mock-1.10.0
|
6 |
+
collected 7 items
|
7 |
+
|
8 |
+
tests/single_file/test_stable_diffusion_controlnet_single_file.py ...... [ 85%]
|
9 |
+
. [100%]
|
10 |
+
|
11 |
+
============================== 7 passed in 37.73s ==============================
|
text_outputs_single_file/test_stable_diffusion_img2img_single_file_output.txt
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
============================= test session starts ==============================
|
2 |
+
platform linux -- Python 3.8.10, pytest-8.2.0, pluggy-1.5.0
|
3 |
+
rootdir: /diffusers
|
4 |
+
configfile: pyproject.toml
|
5 |
+
plugins: xdist-3.6.1, timeout-2.3.1, requests-mock-1.10.0
|
6 |
+
collected 14 items
|
7 |
+
|
8 |
+
tests/single_file/test_stable_diffusion_img2img_single_file.py ......... [ 64%]
|
9 |
+
..... [100%]
|
10 |
+
|
11 |
+
=============================== warnings summary ===============================
|
12 |
+
tests/single_file/test_stable_diffusion_img2img_single_file.py::StableDiffusionImg2ImgPipelineSingleFileSlowTests::test_single_file_components_with_original_config
|
13 |
+
tests/single_file/test_stable_diffusion_img2img_single_file.py::StableDiffusionImg2ImgPipelineSingleFileSlowTests::test_single_file_components_with_original_config_local_files_only
|
14 |
+
tests/single_file/test_stable_diffusion_img2img_single_file.py::StableDiffusion21Img2ImgPipelineSingleFileSlowTests::test_single_file_components_with_original_config
|
15 |
+
tests/single_file/test_stable_diffusion_img2img_single_file.py::StableDiffusion21Img2ImgPipelineSingleFileSlowTests::test_single_file_components_with_original_config_local_files_only
|
16 |
+
/diffusers/src/diffusers/loaders/single_file_utils.py:604: FutureWarning: `image_size` is deprecated and will be removed in version 1.0.0. Configuring UNet2DConditionModel with the `upcast_attention` argument to `from_single_file`is deprecated and will be ignored in future versions.
|
17 |
+
deprecate("image_size", "1.0.0", deprecation_message)
|
18 |
+
|
19 |
+
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
|
20 |
+
================== 14 passed, 4 warnings in 149.17s (0:02:29) ==================
|
text_outputs_single_file/test_stable_diffusion_inpaint_single_file_output.txt
ADDED
@@ -0,0 +1,311 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
============================= test session starts ==============================
|
2 |
+
platform linux -- Python 3.8.10, pytest-8.2.0, pluggy-1.5.0
|
3 |
+
rootdir: /diffusers
|
4 |
+
configfile: pyproject.toml
|
5 |
+
plugins: xdist-3.6.1, timeout-2.3.1, requests-mock-1.10.0
|
6 |
+
collected 15 items
|
7 |
+
|
8 |
+
tests/single_file/test_stable_diffusion_inpaint_single_file.py ....FF... [ 60%]
|
9 |
+
...... [100%]
|
10 |
+
|
11 |
+
=================================== FAILURES ===================================
|
12 |
+
_ StableDiffusionInpaintPipelineSingleFileSlowTests.test_single_file_components_with_original_config _
|
13 |
+
|
14 |
+
self = <tests.single_file.test_stable_diffusion_inpaint_single_file.StableDiffusionInpaintPipelineSingleFileSlowTests testMethod=test_single_file_components_with_original_config>
|
15 |
+
pipe = StableDiffusionInpaintPipeline {
|
16 |
+
"_class_name": "StableDiffusionInpaintPipeline",
|
17 |
+
"_diffusers_version": "0.28.0.de... ],
|
18 |
+
"unet": [
|
19 |
+
"diffusers",
|
20 |
+
"UNet2DConditionModel"
|
21 |
+
],
|
22 |
+
"vae": [
|
23 |
+
"diffusers",
|
24 |
+
"AutoencoderKL"
|
25 |
+
]
|
26 |
+
}
|
27 |
+
|
28 |
+
single_file_pipe = StableDiffusionInpaintPipeline {
|
29 |
+
"_class_name": "StableDiffusionInpaintPipeline",
|
30 |
+
"_diffusers_version": "0.28.0.de... ],
|
31 |
+
"unet": [
|
32 |
+
"diffusers",
|
33 |
+
"UNet2DConditionModel"
|
34 |
+
],
|
35 |
+
"vae": [
|
36 |
+
"diffusers",
|
37 |
+
"AutoencoderKL"
|
38 |
+
]
|
39 |
+
}
|
40 |
+
|
41 |
+
|
42 |
+
def test_single_file_components_with_original_config(
|
43 |
+
self,
|
44 |
+
pipe=None,
|
45 |
+
single_file_pipe=None,
|
46 |
+
):
|
47 |
+
pipe = pipe or self.pipeline_class.from_pretrained(self.repo_id, safety_checker=None)
|
48 |
+
# Not possible to infer this value when original config is provided
|
49 |
+
# we just pass it in here otherwise this test will fail
|
50 |
+
upcast_attention = pipe.unet.config.upcast_attention
|
51 |
+
|
52 |
+
single_file_pipe = single_file_pipe or self.pipeline_class.from_single_file(
|
53 |
+
self.ckpt_path,
|
54 |
+
original_config=self.original_config,
|
55 |
+
safety_checker=None,
|
56 |
+
upcast_attention=upcast_attention,
|
57 |
+
)
|
58 |
+
|
59 |
+
> self._compare_component_configs(pipe, single_file_pipe)
|
60 |
+
|
61 |
+
tests/single_file/single_file_testing_utils.py:127:
|
62 |
+
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
63 |
+
|
64 |
+
self = <tests.single_file.test_stable_diffusion_inpaint_single_file.StableDiffusionInpaintPipelineSingleFileSlowTests testMethod=test_single_file_components_with_original_config>
|
65 |
+
pipe = StableDiffusionInpaintPipeline {
|
66 |
+
"_class_name": "StableDiffusionInpaintPipeline",
|
67 |
+
"_diffusers_version": "0.28.0.de... ],
|
68 |
+
"unet": [
|
69 |
+
"diffusers",
|
70 |
+
"UNet2DConditionModel"
|
71 |
+
],
|
72 |
+
"vae": [
|
73 |
+
"diffusers",
|
74 |
+
"AutoencoderKL"
|
75 |
+
]
|
76 |
+
}
|
77 |
+
|
78 |
+
single_file_pipe = StableDiffusionInpaintPipeline {
|
79 |
+
"_class_name": "StableDiffusionInpaintPipeline",
|
80 |
+
"_diffusers_version": "0.28.0.de... ],
|
81 |
+
"unet": [
|
82 |
+
"diffusers",
|
83 |
+
"UNet2DConditionModel"
|
84 |
+
],
|
85 |
+
"vae": [
|
86 |
+
"diffusers",
|
87 |
+
"AutoencoderKL"
|
88 |
+
]
|
89 |
+
}
|
90 |
+
|
91 |
+
|
92 |
+
def _compare_component_configs(self, pipe, single_file_pipe):
|
93 |
+
for param_name, param_value in single_file_pipe.text_encoder.config.to_dict().items():
|
94 |
+
if param_name in ["torch_dtype", "architectures", "_name_or_path"]:
|
95 |
+
continue
|
96 |
+
assert pipe.text_encoder.config.to_dict()[param_name] == param_value
|
97 |
+
|
98 |
+
PARAMS_TO_IGNORE = [
|
99 |
+
"torch_dtype",
|
100 |
+
"_name_or_path",
|
101 |
+
"architectures",
|
102 |
+
"_use_default_values",
|
103 |
+
"_diffusers_version",
|
104 |
+
]
|
105 |
+
for component_name, component in single_file_pipe.components.items():
|
106 |
+
if component_name in single_file_pipe._optional_components:
|
107 |
+
continue
|
108 |
+
|
109 |
+
# skip testing transformer based components here
|
110 |
+
# skip text encoders / safety checkers since they have already been tested
|
111 |
+
if component_name in ["text_encoder", "tokenizer", "safety_checker", "feature_extractor"]:
|
112 |
+
continue
|
113 |
+
|
114 |
+
assert component_name in pipe.components, f"single file {component_name} not found in pretrained pipeline"
|
115 |
+
assert isinstance(
|
116 |
+
component, pipe.components[component_name].__class__
|
117 |
+
), f"single file {component.__class__.__name__} and pretrained {pipe.components[component_name].__class__.__name__} are not the same"
|
118 |
+
|
119 |
+
for param_name, param_value in component.config.items():
|
120 |
+
if param_name in PARAMS_TO_IGNORE:
|
121 |
+
continue
|
122 |
+
|
123 |
+
# Some pretrained configs will set upcast attention to None
|
124 |
+
# In single file loading it defaults to the value in the class __init__ which is False
|
125 |
+
if param_name == "upcast_attention" and pipe.components[component_name].config[param_name] is None:
|
126 |
+
pipe.components[component_name].config[param_name] = param_value
|
127 |
+
|
128 |
+
> assert (
|
129 |
+
pipe.components[component_name].config[param_name] == param_value
|
130 |
+
), f"single file {param_name}: {param_value} differs from pretrained {pipe.components[component_name].config[param_name]}"
|
131 |
+
E AssertionError: single file sample_size: 512 differs from pretrained 256
|
132 |
+
|
133 |
+
tests/single_file/single_file_testing_utils.py:85: AssertionError
|
134 |
+
----------------------------- Captured stderr call -----------------------------
|
135 |
+
unet/diffusion_pytorch_model.safetensors not found
|
136 |
+
|
137 |
+
Loading pipeline components...: 0%| | 0/6 [00:00<?, ?it/s]
|
138 |
+
Loading pipeline components...: 17%|█▋ | 1/6 [00:00<00:01, 4.94it/s]
|
139 |
+
Loading pipeline components...: 33%|███▎ | 2/6 [00:01<00:03, 1.24it/s]
|
140 |
+
Loading pipeline components...: 50%|█████ | 3/6 [00:01<00:01, 1.81it/s]
|
141 |
+
Loading pipeline components...: 100%|██████████| 6/6 [00:01<00:00, 3.40it/s]
|
142 |
+
You have disabled the safety checker for <class 'diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_inpaint.StableDiffusionInpaintPipeline'> by passing `safety_checker=None`. Ensure that you abide to the conditions of the Stable Diffusion license and do not expose unfiltered results in services or applications open to the public. Both the diffusers team and Hugging Face strongly recommend to keep the safety filter enabled in all public facing circumstances, disabling it only for use-cases that involve analyzing network behavior or auditing its results. For more information, please have a look at https://github.com/huggingface/diffusers/pull/254 .
|
143 |
+
|
144 |
+
Fetching 12 files: 0%| | 0/12 [00:00<?, ?it/s]
|
145 |
+
Fetching 12 files: 100%|██████████| 12/12 [00:00<00:00, 103991.01it/s]
|
146 |
+
|
147 |
+
Loading pipeline components...: 0%| | 0/6 [00:00<?, ?it/s]Some weights of the model checkpoint were not used when initializing CLIPTextModel:
|
148 |
+
['text_model.embeddings.position_ids']
|
149 |
+
|
150 |
+
Loading pipeline components...: 50%|█████ | 3/6 [00:00<00:00, 19.38it/s]
|
151 |
+
Loading pipeline components...: 83%|████████▎ | 5/6 [00:00<00:00, 7.49it/s]
|
152 |
+
Loading pipeline components...: 100%|██████████| 6/6 [00:00<00:00, 9.08it/s]
|
153 |
+
You have disabled the safety checker for <class 'diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_inpaint.StableDiffusionInpaintPipeline'> by passing `safety_checker=None`. Ensure that you abide to the conditions of the Stable Diffusion license and do not expose unfiltered results in services or applications open to the public. Both the diffusers team and Hugging Face strongly recommend to keep the safety filter enabled in all public facing circumstances, disabling it only for use-cases that involve analyzing network behavior or auditing its results. For more information, please have a look at https://github.com/huggingface/diffusers/pull/254 .
|
154 |
+
_ StableDiffusionInpaintPipelineSingleFileSlowTests.test_single_file_components_with_original_config_local_files_only _
|
155 |
+
|
156 |
+
self = <tests.single_file.test_stable_diffusion_inpaint_single_file.StableDiffusionInpaintPipelineSingleFileSlowTests testMethod=test_single_file_components_with_original_config_local_files_only>
|
157 |
+
pipe = StableDiffusionInpaintPipeline {
|
158 |
+
"_class_name": "StableDiffusionInpaintPipeline",
|
159 |
+
"_diffusers_version": "0.28.0.de... ],
|
160 |
+
"unet": [
|
161 |
+
"diffusers",
|
162 |
+
"UNet2DConditionModel"
|
163 |
+
],
|
164 |
+
"vae": [
|
165 |
+
"diffusers",
|
166 |
+
"AutoencoderKL"
|
167 |
+
]
|
168 |
+
}
|
169 |
+
|
170 |
+
single_file_pipe = StableDiffusionInpaintPipeline {
|
171 |
+
"_class_name": "StableDiffusionInpaintPipeline",
|
172 |
+
"_diffusers_version": "0.28.0.de... ],
|
173 |
+
"unet": [
|
174 |
+
"diffusers",
|
175 |
+
"UNet2DConditionModel"
|
176 |
+
],
|
177 |
+
"vae": [
|
178 |
+
"diffusers",
|
179 |
+
"AutoencoderKL"
|
180 |
+
]
|
181 |
+
}
|
182 |
+
|
183 |
+
|
184 |
+
def test_single_file_components_with_original_config_local_files_only(
|
185 |
+
self,
|
186 |
+
pipe=None,
|
187 |
+
single_file_pipe=None,
|
188 |
+
):
|
189 |
+
pipe = pipe or self.pipeline_class.from_pretrained(self.repo_id, safety_checker=None)
|
190 |
+
|
191 |
+
# Not possible to infer this value when original config is provided
|
192 |
+
# we just pass it in here otherwise this test will fail
|
193 |
+
upcast_attention = pipe.unet.config.upcast_attention
|
194 |
+
|
195 |
+
with tempfile.TemporaryDirectory() as tmpdir:
|
196 |
+
ckpt_filename = self.ckpt_path.split("/")[-1]
|
197 |
+
local_ckpt_path = download_single_file_checkpoint(self.repo_id, ckpt_filename, tmpdir)
|
198 |
+
local_original_config = download_original_config(self.original_config, tmpdir)
|
199 |
+
|
200 |
+
single_file_pipe = single_file_pipe or self.pipeline_class.from_single_file(
|
201 |
+
local_ckpt_path,
|
202 |
+
original_config=local_original_config,
|
203 |
+
safety_checker=None,
|
204 |
+
upcast_attention=upcast_attention,
|
205 |
+
local_files_only=True,
|
206 |
+
)
|
207 |
+
|
208 |
+
> self._compare_component_configs(pipe, single_file_pipe)
|
209 |
+
|
210 |
+
tests/single_file/single_file_testing_utils.py:153:
|
211 |
+
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
212 |
+
|
213 |
+
self = <tests.single_file.test_stable_diffusion_inpaint_single_file.StableDiffusionInpaintPipelineSingleFileSlowTests testMethod=test_single_file_components_with_original_config_local_files_only>
|
214 |
+
pipe = StableDiffusionInpaintPipeline {
|
215 |
+
"_class_name": "StableDiffusionInpaintPipeline",
|
216 |
+
"_diffusers_version": "0.28.0.de... ],
|
217 |
+
"unet": [
|
218 |
+
"diffusers",
|
219 |
+
"UNet2DConditionModel"
|
220 |
+
],
|
221 |
+
"vae": [
|
222 |
+
"diffusers",
|
223 |
+
"AutoencoderKL"
|
224 |
+
]
|
225 |
+
}
|
226 |
+
|
227 |
+
single_file_pipe = StableDiffusionInpaintPipeline {
|
228 |
+
"_class_name": "StableDiffusionInpaintPipeline",
|
229 |
+
"_diffusers_version": "0.28.0.de... ],
|
230 |
+
"unet": [
|
231 |
+
"diffusers",
|
232 |
+
"UNet2DConditionModel"
|
233 |
+
],
|
234 |
+
"vae": [
|
235 |
+
"diffusers",
|
236 |
+
"AutoencoderKL"
|
237 |
+
]
|
238 |
+
}
|
239 |
+
|
240 |
+
|
241 |
+
def _compare_component_configs(self, pipe, single_file_pipe):
|
242 |
+
for param_name, param_value in single_file_pipe.text_encoder.config.to_dict().items():
|
243 |
+
if param_name in ["torch_dtype", "architectures", "_name_or_path"]:
|
244 |
+
continue
|
245 |
+
assert pipe.text_encoder.config.to_dict()[param_name] == param_value
|
246 |
+
|
247 |
+
PARAMS_TO_IGNORE = [
|
248 |
+
"torch_dtype",
|
249 |
+
"_name_or_path",
|
250 |
+
"architectures",
|
251 |
+
"_use_default_values",
|
252 |
+
"_diffusers_version",
|
253 |
+
]
|
254 |
+
for component_name, component in single_file_pipe.components.items():
|
255 |
+
if component_name in single_file_pipe._optional_components:
|
256 |
+
continue
|
257 |
+
|
258 |
+
# skip testing transformer based components here
|
259 |
+
# skip text encoders / safety checkers since they have already been tested
|
260 |
+
if component_name in ["text_encoder", "tokenizer", "safety_checker", "feature_extractor"]:
|
261 |
+
continue
|
262 |
+
|
263 |
+
assert component_name in pipe.components, f"single file {component_name} not found in pretrained pipeline"
|
264 |
+
assert isinstance(
|
265 |
+
component, pipe.components[component_name].__class__
|
266 |
+
), f"single file {component.__class__.__name__} and pretrained {pipe.components[component_name].__class__.__name__} are not the same"
|
267 |
+
|
268 |
+
for param_name, param_value in component.config.items():
|
269 |
+
if param_name in PARAMS_TO_IGNORE:
|
270 |
+
continue
|
271 |
+
|
272 |
+
# Some pretrained configs will set upcast attention to None
|
273 |
+
# In single file loading it defaults to the value in the class __init__ which is False
|
274 |
+
if param_name == "upcast_attention" and pipe.components[component_name].config[param_name] is None:
|
275 |
+
pipe.components[component_name].config[param_name] = param_value
|
276 |
+
|
277 |
+
> assert (
|
278 |
+
pipe.components[component_name].config[param_name] == param_value
|
279 |
+
), f"single file {param_name}: {param_value} differs from pretrained {pipe.components[component_name].config[param_name]}"
|
280 |
+
E AssertionError: single file sample_size: 512 differs from pretrained 256
|
281 |
+
|
282 |
+
tests/single_file/single_file_testing_utils.py:85: AssertionError
|
283 |
+
----------------------------- Captured stderr call -----------------------------
|
284 |
+
unet/diffusion_pytorch_model.safetensors not found
|
285 |
+
|
286 |
+
Loading pipeline components...: 0%| | 0/6 [00:00<?, ?it/s]
|
287 |
+
Loading pipeline components...: 17%|█▋ | 1/6 [00:00<00:00, 5.11it/s]
|
288 |
+
Loading pipeline components...: 33%|███▎ | 2/6 [00:01<00:03, 1.27it/s]
|
289 |
+
Loading pipeline components...: 50%|█████ | 3/6 [00:01<00:01, 1.84it/s]
|
290 |
+
Loading pipeline components...: 100%|██████████| 6/6 [00:01<00:00, 3.47it/s]
|
291 |
+
You have disabled the safety checker for <class 'diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_inpaint.StableDiffusionInpaintPipeline'> by passing `safety_checker=None`. Ensure that you abide to the conditions of the Stable Diffusion license and do not expose unfiltered results in services or applications open to the public. Both the diffusers team and Hugging Face strongly recommend to keep the safety filter enabled in all public facing circumstances, disabling it only for use-cases that involve analyzing network behavior or auditing its results. For more information, please have a look at https://github.com/huggingface/diffusers/pull/254 .
|
292 |
+
|
293 |
+
Loading pipeline components...: 0%| | 0/6 [00:00<?, ?it/s]Some weights of the model checkpoint were not used when initializing CLIPTextModel:
|
294 |
+
['text_model.embeddings.position_ids']
|
295 |
+
|
296 |
+
Loading pipeline components...: 67%|██████▋ | 4/6 [00:00<00:00, 23.56it/s]
|
297 |
+
Loading pipeline components...: 100%|██████████| 6/6 [00:00<00:00, 10.16it/s]
|
298 |
+
You have disabled the safety checker for <class 'diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_inpaint.StableDiffusionInpaintPipeline'> by passing `safety_checker=None`. Ensure that you abide to the conditions of the Stable Diffusion license and do not expose unfiltered results in services or applications open to the public. Both the diffusers team and Hugging Face strongly recommend to keep the safety filter enabled in all public facing circumstances, disabling it only for use-cases that involve analyzing network behavior or auditing its results. For more information, please have a look at https://github.com/huggingface/diffusers/pull/254 .
|
299 |
+
=============================== warnings summary ===============================
|
300 |
+
tests/single_file/test_stable_diffusion_inpaint_single_file.py::StableDiffusionInpaintPipelineSingleFileSlowTests::test_single_file_components_with_original_config
|
301 |
+
tests/single_file/test_stable_diffusion_inpaint_single_file.py::StableDiffusionInpaintPipelineSingleFileSlowTests::test_single_file_components_with_original_config_local_files_only
|
302 |
+
tests/single_file/test_stable_diffusion_inpaint_single_file.py::StableDiffusion21InpaintPipelineSingleFileSlowTests::test_single_file_components_with_original_config
|
303 |
+
tests/single_file/test_stable_diffusion_inpaint_single_file.py::StableDiffusion21InpaintPipelineSingleFileSlowTests::test_single_file_components_with_original_config_local_files_only
|
304 |
+
/diffusers/src/diffusers/loaders/single_file_utils.py:604: FutureWarning: `image_size` is deprecated and will be removed in version 1.0.0. Configuring UNet2DConditionModel with the `upcast_attention` argument to `from_single_file`is deprecated and will be ignored in future versions.
|
305 |
+
deprecate("image_size", "1.0.0", deprecation_message)
|
306 |
+
|
307 |
+
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
|
308 |
+
=========================== short test summary info ============================
|
309 |
+
FAILED tests/single_file/test_stable_diffusion_inpaint_single_file.py::StableDiffusionInpaintPipelineSingleFileSlowTests::test_single_file_components_with_original_config
|
310 |
+
FAILED tests/single_file/test_stable_diffusion_inpaint_single_file.py::StableDiffusionInpaintPipelineSingleFileSlowTests::test_single_file_components_with_original_config_local_files_only
|
311 |
+
============= 2 failed, 13 passed, 4 warnings in 133.82s (0:02:13) =============
|
text_outputs_single_file/test_stable_diffusion_single_file_output.txt
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
============================= test session starts ==============================
|
2 |
+
platform linux -- Python 3.8.10, pytest-8.2.0, pluggy-1.5.0
|
3 |
+
rootdir: /diffusers
|
4 |
+
configfile: pyproject.toml
|
5 |
+
plugins: xdist-3.6.1, timeout-2.3.1, requests-mock-1.10.0
|
6 |
+
collected 16 items
|
7 |
+
|
8 |
+
tests/single_file/test_stable_diffusion_single_file.py ........F....... [100%]
|
9 |
+
|
10 |
+
=================================== FAILURES ===================================
|
11 |
+
_ StableDiffusionPipelineSingleFileSlowTests.test_single_file_legacy_scheduler_loading _
|
12 |
+
|
13 |
+
self = <tests.single_file.test_stable_diffusion_single_file.StableDiffusionPipelineSingleFileSlowTests testMethod=test_single_file_legacy_scheduler_loading>
|
14 |
+
|
15 |
+
def test_single_file_legacy_scheduler_loading(self):
|
16 |
+
# Default is PNDM for this checkpoint
|
17 |
+
> pipe = self.pipeline_class.from_single_file(
|
18 |
+
self.ckpt_path, original_config=self.original_config, local_files_only=True, scheduler_type="ddim"
|
19 |
+
)
|
20 |
+
|
21 |
+
tests/single_file/test_stable_diffusion_single_file.py:56:
|
22 |
+
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
23 |
+
/opt/venv/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py:119: in _inner_fn
|
24 |
+
return fn(*args, **kwargs)
|
25 |
+
src/diffusers/loaders/single_file.py:380: in from_single_file
|
26 |
+
original_config = fetch_original_config(original_config, local_files_only=local_files_only)
|
27 |
+
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
28 |
+
|
29 |
+
original_config_file = 'https://raw.githubusercontent.com/CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml'
|
30 |
+
local_files_only = True
|
31 |
+
|
32 |
+
def fetch_original_config(original_config_file, local_files_only=False):
|
33 |
+
if os.path.isfile(original_config_file):
|
34 |
+
with open(original_config_file, "r") as fp:
|
35 |
+
original_config_file = fp.read()
|
36 |
+
|
37 |
+
elif is_valid_url(original_config_file):
|
38 |
+
if local_files_only:
|
39 |
+
> raise ValueError(
|
40 |
+
"`local_files_only` is set to True, but a URL was provided as `original_config_file`. "
|
41 |
+
"Please provide a valid local file path."
|
42 |
+
)
|
43 |
+
E ValueError: `local_files_only` is set to True, but a URL was provided as `original_config_file`. Please provide a valid local file path.
|
44 |
+
|
45 |
+
src/diffusers/loaders/single_file_utils.py:338: ValueError
|
46 |
+
=============================== warnings summary ===============================
|
47 |
+
tests/single_file/test_stable_diffusion_single_file.py::StableDiffusionPipelineSingleFileSlowTests::test_single_file_components_with_original_config
|
48 |
+
tests/single_file/test_stable_diffusion_single_file.py::StableDiffusionPipelineSingleFileSlowTests::test_single_file_components_with_original_config_local_files_only
|
49 |
+
tests/single_file/test_stable_diffusion_single_file.py::StableDiffusion21PipelineSingleFileSlowTests::test_single_file_components_with_original_config
|
50 |
+
tests/single_file/test_stable_diffusion_single_file.py::StableDiffusion21PipelineSingleFileSlowTests::test_single_file_components_with_original_config_local_files_only
|
51 |
+
/diffusers/src/diffusers/loaders/single_file_utils.py:604: FutureWarning: `image_size` is deprecated and will be removed in version 1.0.0. Configuring UNet2DConditionModel with the `upcast_attention` argument to `from_single_file`is deprecated and will be ignored in future versions.
|
52 |
+
deprecate("image_size", "1.0.0", deprecation_message)
|
53 |
+
|
54 |
+
tests/single_file/test_stable_diffusion_single_file.py::StableDiffusionPipelineSingleFileSlowTests::test_single_file_legacy_scaling_factor
|
55 |
+
/diffusers/src/diffusers/loaders/single_file.py:377: FutureWarning: `scaling_factor` is deprecated and will be removed in version 1.0.0. Passing the `scaling_factor` argument to `from_single_file is deprecated and will be ignored in future versions.
|
56 |
+
deprecate("scaling_factor", "1.0.0", deprecation_message)
|
57 |
+
|
58 |
+
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
|
59 |
+
=========================== short test summary info ============================
|
60 |
+
FAILED tests/single_file/test_stable_diffusion_single_file.py::StableDiffusionPipelineSingleFileSlowTests::test_single_file_legacy_scheduler_loading
|
61 |
+
============= 1 failed, 15 passed, 5 warnings in 225.98s (0:03:45) =============
|
text_outputs_single_file/test_stable_diffusion_upscale_single_file_output.txt
ADDED
@@ -0,0 +1,307 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
============================= test session starts ==============================
|
2 |
+
platform linux -- Python 3.8.10, pytest-8.2.0, pluggy-1.5.0
|
3 |
+
rootdir: /diffusers
|
4 |
+
configfile: pyproject.toml
|
5 |
+
plugins: xdist-3.6.1, timeout-2.3.1, requests-mock-1.10.0
|
6 |
+
collected 7 items
|
7 |
+
|
8 |
+
tests/single_file/test_stable_diffusion_upscale_single_file.py ....FF. [100%]
|
9 |
+
|
10 |
+
=================================== FAILURES ===================================
|
11 |
+
_ StableDiffusionUpscalePipelineSingleFileSlowTests.test_single_file_components_with_original_config _
|
12 |
+
|
13 |
+
self = <tests.single_file.test_stable_diffusion_upscale_single_file.StableDiffusionUpscalePipelineSingleFileSlowTests testMethod=test_single_file_components_with_original_config>
|
14 |
+
pipe = StableDiffusionUpscalePipeline {
|
15 |
+
"_class_name": "StableDiffusionUpscalePipeline",
|
16 |
+
"_diffusers_version": "0.28.0.de...DConditionModel"
|
17 |
+
],
|
18 |
+
"vae": [
|
19 |
+
"diffusers",
|
20 |
+
"AutoencoderKL"
|
21 |
+
],
|
22 |
+
"watermarker": [
|
23 |
+
null,
|
24 |
+
null
|
25 |
+
]
|
26 |
+
}
|
27 |
+
|
28 |
+
single_file_pipe = StableDiffusionUpscalePipeline {
|
29 |
+
"_class_name": "StableDiffusionUpscalePipeline",
|
30 |
+
"_diffusers_version": "0.28.0.de...DConditionModel"
|
31 |
+
],
|
32 |
+
"vae": [
|
33 |
+
"diffusers",
|
34 |
+
"AutoencoderKL"
|
35 |
+
],
|
36 |
+
"watermarker": [
|
37 |
+
null,
|
38 |
+
null
|
39 |
+
]
|
40 |
+
}
|
41 |
+
|
42 |
+
|
43 |
+
def test_single_file_components_with_original_config(
|
44 |
+
self,
|
45 |
+
pipe=None,
|
46 |
+
single_file_pipe=None,
|
47 |
+
):
|
48 |
+
pipe = pipe or self.pipeline_class.from_pretrained(self.repo_id, safety_checker=None)
|
49 |
+
# Not possible to infer this value when original config is provided
|
50 |
+
# we just pass it in here otherwise this test will fail
|
51 |
+
upcast_attention = pipe.unet.config.upcast_attention
|
52 |
+
|
53 |
+
single_file_pipe = single_file_pipe or self.pipeline_class.from_single_file(
|
54 |
+
self.ckpt_path,
|
55 |
+
original_config=self.original_config,
|
56 |
+
safety_checker=None,
|
57 |
+
upcast_attention=upcast_attention,
|
58 |
+
)
|
59 |
+
|
60 |
+
> self._compare_component_configs(pipe, single_file_pipe)
|
61 |
+
|
62 |
+
tests/single_file/single_file_testing_utils.py:127:
|
63 |
+
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
64 |
+
|
65 |
+
self = <tests.single_file.test_stable_diffusion_upscale_single_file.StableDiffusionUpscalePipelineSingleFileSlowTests testMethod=test_single_file_components_with_original_config>
|
66 |
+
pipe = StableDiffusionUpscalePipeline {
|
67 |
+
"_class_name": "StableDiffusionUpscalePipeline",
|
68 |
+
"_diffusers_version": "0.28.0.de...DConditionModel"
|
69 |
+
],
|
70 |
+
"vae": [
|
71 |
+
"diffusers",
|
72 |
+
"AutoencoderKL"
|
73 |
+
],
|
74 |
+
"watermarker": [
|
75 |
+
null,
|
76 |
+
null
|
77 |
+
]
|
78 |
+
}
|
79 |
+
|
80 |
+
single_file_pipe = StableDiffusionUpscalePipeline {
|
81 |
+
"_class_name": "StableDiffusionUpscalePipeline",
|
82 |
+
"_diffusers_version": "0.28.0.de...DConditionModel"
|
83 |
+
],
|
84 |
+
"vae": [
|
85 |
+
"diffusers",
|
86 |
+
"AutoencoderKL"
|
87 |
+
],
|
88 |
+
"watermarker": [
|
89 |
+
null,
|
90 |
+
null
|
91 |
+
]
|
92 |
+
}
|
93 |
+
|
94 |
+
|
95 |
+
def _compare_component_configs(self, pipe, single_file_pipe):
|
96 |
+
for param_name, param_value in single_file_pipe.text_encoder.config.to_dict().items():
|
97 |
+
if param_name in ["torch_dtype", "architectures", "_name_or_path"]:
|
98 |
+
continue
|
99 |
+
assert pipe.text_encoder.config.to_dict()[param_name] == param_value
|
100 |
+
|
101 |
+
PARAMS_TO_IGNORE = [
|
102 |
+
"torch_dtype",
|
103 |
+
"_name_or_path",
|
104 |
+
"architectures",
|
105 |
+
"_use_default_values",
|
106 |
+
"_diffusers_version",
|
107 |
+
]
|
108 |
+
for component_name, component in single_file_pipe.components.items():
|
109 |
+
if component_name in single_file_pipe._optional_components:
|
110 |
+
continue
|
111 |
+
|
112 |
+
# skip testing transformer based components here
|
113 |
+
# skip text encoders / safety checkers since they have already been tested
|
114 |
+
if component_name in ["text_encoder", "tokenizer", "safety_checker", "feature_extractor"]:
|
115 |
+
continue
|
116 |
+
|
117 |
+
assert component_name in pipe.components, f"single file {component_name} not found in pretrained pipeline"
|
118 |
+
assert isinstance(
|
119 |
+
component, pipe.components[component_name].__class__
|
120 |
+
), f"single file {component.__class__.__name__} and pretrained {pipe.components[component_name].__class__.__name__} are not the same"
|
121 |
+
|
122 |
+
for param_name, param_value in component.config.items():
|
123 |
+
if param_name in PARAMS_TO_IGNORE:
|
124 |
+
continue
|
125 |
+
|
126 |
+
# Some pretrained configs will set upcast attention to None
|
127 |
+
# In single file loading it defaults to the value in the class __init__ which is False
|
128 |
+
if param_name == "upcast_attention" and pipe.components[component_name].config[param_name] is None:
|
129 |
+
pipe.components[component_name].config[param_name] = param_value
|
130 |
+
|
131 |
+
> assert (
|
132 |
+
pipe.components[component_name].config[param_name] == param_value
|
133 |
+
), f"single file {param_name}: {param_value} differs from pretrained {pipe.components[component_name].config[param_name]}"
|
134 |
+
E AssertionError: single file sample_size: 512 differs from pretrained 256
|
135 |
+
|
136 |
+
tests/single_file/single_file_testing_utils.py:85: AssertionError
|
137 |
+
----------------------------- Captured stderr call -----------------------------
|
138 |
+
|
139 |
+
Loading pipeline components...: 0%| | 0/6 [00:00<?, ?it/s]
|
140 |
+
Loading pipeline components...: 17%|█▋ | 1/6 [00:00<00:01, 3.44it/s]
|
141 |
+
Loading pipeline components...: 67%|██████▋ | 4/6 [00:00<00:00, 10.92it/s]
|
142 |
+
Loading pipeline components...: 100%|██████████| 6/6 [00:00<00:00, 9.23it/s]
|
143 |
+
Loading pipeline components...: 100%|██████████| 6/6 [00:00<00:00, 8.74it/s]
|
144 |
+
|
145 |
+
Fetching 11 files: 0%| | 0/11 [00:00<?, ?it/s]
|
146 |
+
Fetching 11 files: 100%|██████████| 11/11 [00:00<00:00, 97748.61it/s]
|
147 |
+
|
148 |
+
Loading pipeline components...: 0%| | 0/6 [00:00<?, ?it/s]
|
149 |
+
Loading pipeline components...: 50%|█████ | 3/6 [00:00<00:00, 12.40it/s]
|
150 |
+
Loading pipeline components...: 83%|████████▎ | 5/6 [00:00<00:00, 8.28it/s]
|
151 |
+
Loading pipeline components...: 100%|██████████| 6/6 [00:00<00:00, 9.69it/s]
|
152 |
+
_ StableDiffusionUpscalePipelineSingleFileSlowTests.test_single_file_components_with_original_config_local_files_only _
|
153 |
+
|
154 |
+
self = <tests.single_file.test_stable_diffusion_upscale_single_file.StableDiffusionUpscalePipelineSingleFileSlowTests testMethod=test_single_file_components_with_original_config_local_files_only>
|
155 |
+
pipe = StableDiffusionUpscalePipeline {
|
156 |
+
"_class_name": "StableDiffusionUpscalePipeline",
|
157 |
+
"_diffusers_version": "0.28.0.de...DConditionModel"
|
158 |
+
],
|
159 |
+
"vae": [
|
160 |
+
"diffusers",
|
161 |
+
"AutoencoderKL"
|
162 |
+
],
|
163 |
+
"watermarker": [
|
164 |
+
null,
|
165 |
+
null
|
166 |
+
]
|
167 |
+
}
|
168 |
+
|
169 |
+
single_file_pipe = StableDiffusionUpscalePipeline {
|
170 |
+
"_class_name": "StableDiffusionUpscalePipeline",
|
171 |
+
"_diffusers_version": "0.28.0.de...DConditionModel"
|
172 |
+
],
|
173 |
+
"vae": [
|
174 |
+
"diffusers",
|
175 |
+
"AutoencoderKL"
|
176 |
+
],
|
177 |
+
"watermarker": [
|
178 |
+
null,
|
179 |
+
null
|
180 |
+
]
|
181 |
+
}
|
182 |
+
|
183 |
+
|
184 |
+
def test_single_file_components_with_original_config_local_files_only(
|
185 |
+
self,
|
186 |
+
pipe=None,
|
187 |
+
single_file_pipe=None,
|
188 |
+
):
|
189 |
+
pipe = pipe or self.pipeline_class.from_pretrained(self.repo_id, safety_checker=None)
|
190 |
+
|
191 |
+
# Not possible to infer this value when original config is provided
|
192 |
+
# we just pass it in here otherwise this test will fail
|
193 |
+
upcast_attention = pipe.unet.config.upcast_attention
|
194 |
+
|
195 |
+
with tempfile.TemporaryDirectory() as tmpdir:
|
196 |
+
ckpt_filename = self.ckpt_path.split("/")[-1]
|
197 |
+
local_ckpt_path = download_single_file_checkpoint(self.repo_id, ckpt_filename, tmpdir)
|
198 |
+
local_original_config = download_original_config(self.original_config, tmpdir)
|
199 |
+
|
200 |
+
single_file_pipe = single_file_pipe or self.pipeline_class.from_single_file(
|
201 |
+
local_ckpt_path,
|
202 |
+
original_config=local_original_config,
|
203 |
+
safety_checker=None,
|
204 |
+
upcast_attention=upcast_attention,
|
205 |
+
local_files_only=True,
|
206 |
+
)
|
207 |
+
|
208 |
+
> self._compare_component_configs(pipe, single_file_pipe)
|
209 |
+
|
210 |
+
tests/single_file/single_file_testing_utils.py:153:
|
211 |
+
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
212 |
+
|
213 |
+
self = <tests.single_file.test_stable_diffusion_upscale_single_file.StableDiffusionUpscalePipelineSingleFileSlowTests testMethod=test_single_file_components_with_original_config_local_files_only>
|
214 |
+
pipe = StableDiffusionUpscalePipeline {
|
215 |
+
"_class_name": "StableDiffusionUpscalePipeline",
|
216 |
+
"_diffusers_version": "0.28.0.de...DConditionModel"
|
217 |
+
],
|
218 |
+
"vae": [
|
219 |
+
"diffusers",
|
220 |
+
"AutoencoderKL"
|
221 |
+
],
|
222 |
+
"watermarker": [
|
223 |
+
null,
|
224 |
+
null
|
225 |
+
]
|
226 |
+
}
|
227 |
+
|
228 |
+
single_file_pipe = StableDiffusionUpscalePipeline {
|
229 |
+
"_class_name": "StableDiffusionUpscalePipeline",
|
230 |
+
"_diffusers_version": "0.28.0.de...DConditionModel"
|
231 |
+
],
|
232 |
+
"vae": [
|
233 |
+
"diffusers",
|
234 |
+
"AutoencoderKL"
|
235 |
+
],
|
236 |
+
"watermarker": [
|
237 |
+
null,
|
238 |
+
null
|
239 |
+
]
|
240 |
+
}
|
241 |
+
|
242 |
+
|
243 |
+
def _compare_component_configs(self, pipe, single_file_pipe):
|
244 |
+
for param_name, param_value in single_file_pipe.text_encoder.config.to_dict().items():
|
245 |
+
if param_name in ["torch_dtype", "architectures", "_name_or_path"]:
|
246 |
+
continue
|
247 |
+
assert pipe.text_encoder.config.to_dict()[param_name] == param_value
|
248 |
+
|
249 |
+
PARAMS_TO_IGNORE = [
|
250 |
+
"torch_dtype",
|
251 |
+
"_name_or_path",
|
252 |
+
"architectures",
|
253 |
+
"_use_default_values",
|
254 |
+
"_diffusers_version",
|
255 |
+
]
|
256 |
+
for component_name, component in single_file_pipe.components.items():
|
257 |
+
if component_name in single_file_pipe._optional_components:
|
258 |
+
continue
|
259 |
+
|
260 |
+
# skip testing transformer based components here
|
261 |
+
# skip text encoders / safety checkers since they have already been tested
|
262 |
+
if component_name in ["text_encoder", "tokenizer", "safety_checker", "feature_extractor"]:
|
263 |
+
continue
|
264 |
+
|
265 |
+
assert component_name in pipe.components, f"single file {component_name} not found in pretrained pipeline"
|
266 |
+
assert isinstance(
|
267 |
+
component, pipe.components[component_name].__class__
|
268 |
+
), f"single file {component.__class__.__name__} and pretrained {pipe.components[component_name].__class__.__name__} are not the same"
|
269 |
+
|
270 |
+
for param_name, param_value in component.config.items():
|
271 |
+
if param_name in PARAMS_TO_IGNORE:
|
272 |
+
continue
|
273 |
+
|
274 |
+
# Some pretrained configs will set upcast attention to None
|
275 |
+
# In single file loading it defaults to the value in the class __init__ which is False
|
276 |
+
if param_name == "upcast_attention" and pipe.components[component_name].config[param_name] is None:
|
277 |
+
pipe.components[component_name].config[param_name] = param_value
|
278 |
+
|
279 |
+
> assert (
|
280 |
+
pipe.components[component_name].config[param_name] == param_value
|
281 |
+
), f"single file {param_name}: {param_value} differs from pretrained {pipe.components[component_name].config[param_name]}"
|
282 |
+
E AssertionError: single file sample_size: 512 differs from pretrained 256
|
283 |
+
|
284 |
+
tests/single_file/single_file_testing_utils.py:85: AssertionError
|
285 |
+
----------------------------- Captured stderr call -----------------------------
|
286 |
+
|
287 |
+
Loading pipeline components...: 0%| | 0/6 [00:00<?, ?it/s]
|
288 |
+
Loading pipeline components...: 17%|█▋ | 1/6 [00:00<00:01, 3.42it/s]
|
289 |
+
Loading pipeline components...: 67%|██████▋ | 4/6 [00:00<00:00, 10.65it/s]
|
290 |
+
Loading pipeline components...: 100%|██████████| 6/6 [00:00<00:00, 8.83it/s]
|
291 |
+
Loading pipeline components...: 100%|██████████| 6/6 [00:00<00:00, 8.43it/s]
|
292 |
+
|
293 |
+
Loading pipeline components...: 0%| | 0/6 [00:00<?, ?it/s]
|
294 |
+
Loading pipeline components...: 50%|█████ | 3/6 [00:00<00:00, 15.78it/s]
|
295 |
+
Loading pipeline components...: 83%|████████▎ | 5/6 [00:00<00:00, 8.86it/s]
|
296 |
+
Loading pipeline components...: 100%|██████████| 6/6 [00:00<00:00, 10.50it/s]
|
297 |
+
=============================== warnings summary ===============================
|
298 |
+
tests/single_file/test_stable_diffusion_upscale_single_file.py::StableDiffusionUpscalePipelineSingleFileSlowTests::test_single_file_components_with_original_config
|
299 |
+
tests/single_file/test_stable_diffusion_upscale_single_file.py::StableDiffusionUpscalePipelineSingleFileSlowTests::test_single_file_components_with_original_config_local_files_only
|
300 |
+
/diffusers/src/diffusers/loaders/single_file_utils.py:604: FutureWarning: `image_size` is deprecated and will be removed in version 1.0.0. Configuring UNet2DConditionModel with the `upcast_attention` argument to `from_single_file`is deprecated and will be ignored in future versions.
|
301 |
+
deprecate("image_size", "1.0.0", deprecation_message)
|
302 |
+
|
303 |
+
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
|
304 |
+
=========================== short test summary info ============================
|
305 |
+
FAILED tests/single_file/test_stable_diffusion_upscale_single_file.py::StableDiffusionUpscalePipelineSingleFileSlowTests::test_single_file_components_with_original_config
|
306 |
+
FAILED tests/single_file/test_stable_diffusion_upscale_single_file.py::StableDiffusionUpscalePipelineSingleFileSlowTests::test_single_file_components_with_original_config_local_files_only
|
307 |
+
============== 2 failed, 5 passed, 2 warnings in 65.46s (0:01:05) ==============
|
text_outputs_single_file/test_stable_diffusion_xl_adapter_single_file_output.txt
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
============================= test session starts ==============================
|
2 |
+
platform linux -- Python 3.8.10, pytest-8.2.0, pluggy-1.5.0
|
3 |
+
rootdir: /diffusers
|
4 |
+
configfile: pyproject.toml
|
5 |
+
plugins: xdist-3.6.1, timeout-2.3.1, requests-mock-1.10.0
|
6 |
+
collected 7 items
|
7 |
+
|
8 |
+
tests/single_file/test_stable_diffusion_xl_adapter_single_file.py ...... [ 85%]
|
9 |
+
. [100%]
|
10 |
+
|
11 |
+
======================== 7 passed in 200.15s (0:03:20) =========================
|
text_outputs_single_file/test_stable_diffusion_xl_controlnet_single_file_output.txt
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
============================= test session starts ==============================
|
2 |
+
platform linux -- Python 3.8.10, pytest-8.2.0, pluggy-1.5.0
|
3 |
+
rootdir: /diffusers
|
4 |
+
configfile: pyproject.toml
|
5 |
+
plugins: xdist-3.6.1, timeout-2.3.1, requests-mock-1.10.0
|
6 |
+
collected 7 items
|
7 |
+
|
8 |
+
tests/single_file/test_stable_diffusion_xl_controlnet_single_file.py ... [ 42%]
|
9 |
+
.... [100%]
|
10 |
+
|
11 |
+
======================== 7 passed in 365.43s (0:06:05) =========================
|
text_outputs_single_file/test_stable_diffusion_xl_img2img_single_file_output.txt
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
============================= test session starts ==============================
|
2 |
+
platform linux -- Python 3.8.10, pytest-8.2.0, pluggy-1.5.0
|
3 |
+
rootdir: /diffusers
|
4 |
+
configfile: pyproject.toml
|
5 |
+
plugins: xdist-3.6.1, timeout-2.3.1, requests-mock-1.10.0
|
6 |
+
collected 8 items
|
7 |
+
|
8 |
+
tests/single_file/test_stable_diffusion_xl_img2img_single_file.py ...... [ 75%]
|
9 |
+
.. [100%]
|
10 |
+
|
11 |
+
======================== 8 passed in 283.12s (0:04:43) =========================
|
text_outputs_single_file/test_stable_diffusion_xl_instruct_pix2pix_output.txt
ADDED
@@ -0,0 +1,423 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
============================= test session starts ==============================
|
2 |
+
platform linux -- Python 3.8.10, pytest-8.2.0, pluggy-1.5.0
|
3 |
+
rootdir: /diffusers
|
4 |
+
configfile: pyproject.toml
|
5 |
+
plugins: xdist-3.6.1, timeout-2.3.1, requests-mock-1.10.0
|
6 |
+
collected 1 item
|
7 |
+
|
8 |
+
tests/single_file/test_stable_diffusion_xl_instruct_pix2pix.py F [100%]
|
9 |
+
|
10 |
+
=================================== FAILURES ===================================
|
11 |
+
_ StableDiffusionXLInstructPix2PixPipeline.test_single_file_setting_cosxl_edit _
|
12 |
+
|
13 |
+
response = <Response [401]>, endpoint_name = None
|
14 |
+
|
15 |
+
def hf_raise_for_status(response: Response, endpoint_name: Optional[str] = None) -> None:
|
16 |
+
"""
|
17 |
+
Internal version of `response.raise_for_status()` that will refine a
|
18 |
+
potential HTTPError. Raised exception will be an instance of `HfHubHTTPError`.
|
19 |
+
|
20 |
+
This helper is meant to be the unique method to raise_for_status when making a call
|
21 |
+
to the Hugging Face Hub.
|
22 |
+
|
23 |
+
Example:
|
24 |
+
```py
|
25 |
+
import requests
|
26 |
+
from huggingface_hub.utils import get_session, hf_raise_for_status, HfHubHTTPError
|
27 |
+
|
28 |
+
response = get_session().post(...)
|
29 |
+
try:
|
30 |
+
hf_raise_for_status(response)
|
31 |
+
except HfHubHTTPError as e:
|
32 |
+
print(str(e)) # formatted message
|
33 |
+
e.request_id, e.server_message # details returned by server
|
34 |
+
|
35 |
+
# Complete the error message with additional information once it's raised
|
36 |
+
e.append_to_message("\n`create_commit` expects the repository to exist.")
|
37 |
+
raise
|
38 |
+
```
|
39 |
+
|
40 |
+
Args:
|
41 |
+
response (`Response`):
|
42 |
+
Response from the server.
|
43 |
+
endpoint_name (`str`, *optional*):
|
44 |
+
Name of the endpoint that has been called. If provided, the error message
|
45 |
+
will be more complete.
|
46 |
+
|
47 |
+
<Tip warning={true}>
|
48 |
+
|
49 |
+
Raises when the request has failed:
|
50 |
+
|
51 |
+
- [`~utils.RepositoryNotFoundError`]
|
52 |
+
If the repository to download from cannot be found. This may be because it
|
53 |
+
doesn't exist, because `repo_type` is not set correctly, or because the repo
|
54 |
+
is `private` and you do not have access.
|
55 |
+
- [`~utils.GatedRepoError`]
|
56 |
+
If the repository exists but is gated and the user is not on the authorized
|
57 |
+
list.
|
58 |
+
- [`~utils.RevisionNotFoundError`]
|
59 |
+
If the repository exists but the revision couldn't be find.
|
60 |
+
- [`~utils.EntryNotFoundError`]
|
61 |
+
If the repository exists but the entry (e.g. the requested file) couldn't be
|
62 |
+
find.
|
63 |
+
- [`~utils.BadRequestError`]
|
64 |
+
If request failed with a HTTP 400 BadRequest error.
|
65 |
+
- [`~utils.HfHubHTTPError`]
|
66 |
+
If request failed for a reason not listed above.
|
67 |
+
|
68 |
+
</Tip>
|
69 |
+
"""
|
70 |
+
try:
|
71 |
+
> response.raise_for_status()
|
72 |
+
|
73 |
+
/opt/venv/lib/python3.8/site-packages/huggingface_hub/utils/_errors.py:304:
|
74 |
+
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
75 |
+
|
76 |
+
self = <Response [401]>
|
77 |
+
|
78 |
+
def raise_for_status(self):
|
79 |
+
"""Raises :class:`HTTPError`, if one occurred."""
|
80 |
+
|
81 |
+
http_error_msg = ""
|
82 |
+
if isinstance(self.reason, bytes):
|
83 |
+
# We attempt to decode utf-8 first because some servers
|
84 |
+
# choose to localize their reason strings. If the string
|
85 |
+
# isn't utf-8, we fall back to iso-8859-1 for all other
|
86 |
+
# encodings. (See PR #3538)
|
87 |
+
try:
|
88 |
+
reason = self.reason.decode("utf-8")
|
89 |
+
except UnicodeDecodeError:
|
90 |
+
reason = self.reason.decode("iso-8859-1")
|
91 |
+
else:
|
92 |
+
reason = self.reason
|
93 |
+
|
94 |
+
if 400 <= self.status_code < 500:
|
95 |
+
http_error_msg = (
|
96 |
+
f"{self.status_code} Client Error: {reason} for url: {self.url}"
|
97 |
+
)
|
98 |
+
|
99 |
+
elif 500 <= self.status_code < 600:
|
100 |
+
http_error_msg = (
|
101 |
+
f"{self.status_code} Server Error: {reason} for url: {self.url}"
|
102 |
+
)
|
103 |
+
|
104 |
+
if http_error_msg:
|
105 |
+
> raise HTTPError(http_error_msg, response=self)
|
106 |
+
E requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://huggingface.co/stabilityai/cosxl/resolve/main/cosxl_edit.safetensors
|
107 |
+
|
108 |
+
/opt/venv/lib/python3.8/site-packages/requests/models.py:1021: HTTPError
|
109 |
+
|
110 |
+
The above exception was the direct cause of the following exception:
|
111 |
+
|
112 |
+
pretrained_model_name_or_path = 'stabilityai/cosxl'
|
113 |
+
|
114 |
+
@validate_hf_hub_args
|
115 |
+
def _get_model_file(
|
116 |
+
pretrained_model_name_or_path: Union[str, Path],
|
117 |
+
*,
|
118 |
+
weights_name: str,
|
119 |
+
subfolder: Optional[str] = None,
|
120 |
+
cache_dir: Optional[str] = None,
|
121 |
+
force_download: bool = False,
|
122 |
+
proxies: Optional[Dict] = None,
|
123 |
+
resume_download: bool = False,
|
124 |
+
local_files_only: bool = False,
|
125 |
+
token: Optional[str] = None,
|
126 |
+
user_agent: Optional[Union[Dict, str]] = None,
|
127 |
+
revision: Optional[str] = None,
|
128 |
+
commit_hash: Optional[str] = None,
|
129 |
+
local_dir: Optional[str] = None,
|
130 |
+
local_dir_use_symlinks: Optional[str] = "auto",
|
131 |
+
):
|
132 |
+
pretrained_model_name_or_path = str(pretrained_model_name_or_path)
|
133 |
+
if os.path.isfile(pretrained_model_name_or_path):
|
134 |
+
return pretrained_model_name_or_path
|
135 |
+
elif os.path.isdir(pretrained_model_name_or_path):
|
136 |
+
if os.path.isfile(os.path.join(pretrained_model_name_or_path, weights_name)):
|
137 |
+
# Load from a PyTorch checkpoint
|
138 |
+
model_file = os.path.join(pretrained_model_name_or_path, weights_name)
|
139 |
+
return model_file
|
140 |
+
elif subfolder is not None and os.path.isfile(
|
141 |
+
os.path.join(pretrained_model_name_or_path, subfolder, weights_name)
|
142 |
+
):
|
143 |
+
model_file = os.path.join(pretrained_model_name_or_path, subfolder, weights_name)
|
144 |
+
return model_file
|
145 |
+
else:
|
146 |
+
raise EnvironmentError(
|
147 |
+
f"Error no file named {weights_name} found in directory {pretrained_model_name_or_path}."
|
148 |
+
)
|
149 |
+
else:
|
150 |
+
# 1. First check if deprecated way of loading from branches is used
|
151 |
+
if (
|
152 |
+
revision in DEPRECATED_REVISION_ARGS
|
153 |
+
and (weights_name == WEIGHTS_NAME or weights_name == SAFETENSORS_WEIGHTS_NAME)
|
154 |
+
and version.parse(version.parse(__version__).base_version) >= version.parse("0.22.0")
|
155 |
+
):
|
156 |
+
try:
|
157 |
+
model_file = hf_hub_download(
|
158 |
+
pretrained_model_name_or_path,
|
159 |
+
filename=_add_variant(weights_name, revision),
|
160 |
+
cache_dir=cache_dir,
|
161 |
+
force_download=force_download,
|
162 |
+
proxies=proxies,
|
163 |
+
resume_download=resume_download,
|
164 |
+
local_files_only=local_files_only,
|
165 |
+
token=token,
|
166 |
+
user_agent=user_agent,
|
167 |
+
subfolder=subfolder,
|
168 |
+
revision=revision or commit_hash,
|
169 |
+
local_dir=local_dir,
|
170 |
+
local_dir_use_symlinks=local_dir_use_symlinks,
|
171 |
+
)
|
172 |
+
warnings.warn(
|
173 |
+
f"Loading the variant {revision} from {pretrained_model_name_or_path} via `revision='{revision}'` is deprecated. Loading instead from `revision='main'` with `variant={revision}`. Loading model variants via `revision='{revision}'` will be removed in diffusers v1. Please use `variant='{revision}'` instead.",
|
174 |
+
FutureWarning,
|
175 |
+
)
|
176 |
+
return model_file
|
177 |
+
except: # noqa: E722
|
178 |
+
warnings.warn(
|
179 |
+
f"You are loading the variant {revision} from {pretrained_model_name_or_path} via `revision='{revision}'`. This behavior is deprecated and will be removed in diffusers v1. One should use `variant='{revision}'` instead. However, it appears that {pretrained_model_name_or_path} currently does not have a {_add_variant(weights_name, revision)} file in the 'main' branch of {pretrained_model_name_or_path}. \n The Diffusers team and community would be very grateful if you could open an issue: https://github.com/huggingface/diffusers/issues/new with the title '{pretrained_model_name_or_path} is missing {_add_variant(weights_name, revision)}' so that the correct variant file can be added.",
|
180 |
+
FutureWarning,
|
181 |
+
)
|
182 |
+
try:
|
183 |
+
# 2. Load model file as usual
|
184 |
+
> model_file = hf_hub_download(
|
185 |
+
pretrained_model_name_or_path,
|
186 |
+
filename=weights_name,
|
187 |
+
cache_dir=cache_dir,
|
188 |
+
force_download=force_download,
|
189 |
+
proxies=proxies,
|
190 |
+
resume_download=resume_download,
|
191 |
+
local_files_only=local_files_only,
|
192 |
+
token=token,
|
193 |
+
user_agent=user_agent,
|
194 |
+
subfolder=subfolder,
|
195 |
+
revision=revision or commit_hash,
|
196 |
+
local_dir=local_dir,
|
197 |
+
local_dir_use_symlinks=local_dir_use_symlinks,
|
198 |
+
)
|
199 |
+
|
200 |
+
src/diffusers/utils/hub_utils.py:347:
|
201 |
+
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
202 |
+
/opt/venv/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py:119: in _inner_fn
|
203 |
+
return fn(*args, **kwargs)
|
204 |
+
/opt/venv/lib/python3.8/site-packages/huggingface_hub/file_download.py:1403: in hf_hub_download
|
205 |
+
raise head_call_error
|
206 |
+
/opt/venv/lib/python3.8/site-packages/huggingface_hub/file_download.py:1261: in hf_hub_download
|
207 |
+
metadata = get_hf_file_metadata(
|
208 |
+
/opt/venv/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py:119: in _inner_fn
|
209 |
+
return fn(*args, **kwargs)
|
210 |
+
/opt/venv/lib/python3.8/site-packages/huggingface_hub/file_download.py:1674: in get_hf_file_metadata
|
211 |
+
r = _request_wrapper(
|
212 |
+
/opt/venv/lib/python3.8/site-packages/huggingface_hub/file_download.py:369: in _request_wrapper
|
213 |
+
response = _request_wrapper(
|
214 |
+
/opt/venv/lib/python3.8/site-packages/huggingface_hub/file_download.py:393: in _request_wrapper
|
215 |
+
hf_raise_for_status(response)
|
216 |
+
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
217 |
+
|
218 |
+
response = <Response [401]>, endpoint_name = None
|
219 |
+
|
220 |
+
def hf_raise_for_status(response: Response, endpoint_name: Optional[str] = None) -> None:
|
221 |
+
"""
|
222 |
+
Internal version of `response.raise_for_status()` that will refine a
|
223 |
+
potential HTTPError. Raised exception will be an instance of `HfHubHTTPError`.
|
224 |
+
|
225 |
+
This helper is meant to be the unique method to raise_for_status when making a call
|
226 |
+
to the Hugging Face Hub.
|
227 |
+
|
228 |
+
Example:
|
229 |
+
```py
|
230 |
+
import requests
|
231 |
+
from huggingface_hub.utils import get_session, hf_raise_for_status, HfHubHTTPError
|
232 |
+
|
233 |
+
response = get_session().post(...)
|
234 |
+
try:
|
235 |
+
hf_raise_for_status(response)
|
236 |
+
except HfHubHTTPError as e:
|
237 |
+
print(str(e)) # formatted message
|
238 |
+
e.request_id, e.server_message # details returned by server
|
239 |
+
|
240 |
+
# Complete the error message with additional information once it's raised
|
241 |
+
e.append_to_message("\n`create_commit` expects the repository to exist.")
|
242 |
+
raise
|
243 |
+
```
|
244 |
+
|
245 |
+
Args:
|
246 |
+
response (`Response`):
|
247 |
+
Response from the server.
|
248 |
+
endpoint_name (`str`, *optional*):
|
249 |
+
Name of the endpoint that has been called. If provided, the error message
|
250 |
+
will be more complete.
|
251 |
+
|
252 |
+
<Tip warning={true}>
|
253 |
+
|
254 |
+
Raises when the request has failed:
|
255 |
+
|
256 |
+
- [`~utils.RepositoryNotFoundError`]
|
257 |
+
If the repository to download from cannot be found. This may be because it
|
258 |
+
doesn't exist, because `repo_type` is not set correctly, or because the repo
|
259 |
+
is `private` and you do not have access.
|
260 |
+
- [`~utils.GatedRepoError`]
|
261 |
+
If the repository exists but is gated and the user is not on the authorized
|
262 |
+
list.
|
263 |
+
- [`~utils.RevisionNotFoundError`]
|
264 |
+
If the repository exists but the revision couldn't be find.
|
265 |
+
- [`~utils.EntryNotFoundError`]
|
266 |
+
If the repository exists but the entry (e.g. the requested file) couldn't be
|
267 |
+
find.
|
268 |
+
- [`~utils.BadRequestError`]
|
269 |
+
If request failed with a HTTP 400 BadRequest error.
|
270 |
+
- [`~utils.HfHubHTTPError`]
|
271 |
+
If request failed for a reason not listed above.
|
272 |
+
|
273 |
+
</Tip>
|
274 |
+
"""
|
275 |
+
try:
|
276 |
+
response.raise_for_status()
|
277 |
+
except HTTPError as e:
|
278 |
+
error_code = response.headers.get("X-Error-Code")
|
279 |
+
error_message = response.headers.get("X-Error-Message")
|
280 |
+
|
281 |
+
if error_code == "RevisionNotFound":
|
282 |
+
message = f"{response.status_code} Client Error." + "\n\n" + f"Revision Not Found for url: {response.url}."
|
283 |
+
raise RevisionNotFoundError(message, response) from e
|
284 |
+
|
285 |
+
elif error_code == "EntryNotFound":
|
286 |
+
message = f"{response.status_code} Client Error." + "\n\n" + f"Entry Not Found for url: {response.url}."
|
287 |
+
raise EntryNotFoundError(message, response) from e
|
288 |
+
|
289 |
+
elif error_code == "GatedRepo":
|
290 |
+
message = (
|
291 |
+
f"{response.status_code} Client Error." + "\n\n" + f"Cannot access gated repo for url {response.url}."
|
292 |
+
)
|
293 |
+
> raise GatedRepoError(message, response) from e
|
294 |
+
E huggingface_hub.utils._errors.GatedRepoError: 401 Client Error. (Request ID: Root=1-6632f450-0c41a9502036e0320ec1517e;011ed4b7-adfa-4b7c-b58e-3f6e8a4eb44c)
|
295 |
+
E
|
296 |
+
E Cannot access gated repo for url https://huggingface.co/stabilityai/cosxl/resolve/main/cosxl_edit.safetensors.
|
297 |
+
E Access to model stabilityai/cosxl is restricted. You must be authenticated to access it.
|
298 |
+
|
299 |
+
/opt/venv/lib/python3.8/site-packages/huggingface_hub/utils/_errors.py:321: GatedRepoError
|
300 |
+
|
301 |
+
During handling of the above exception, another exception occurred:
|
302 |
+
|
303 |
+
self = <tests.single_file.test_stable_diffusion_xl_instruct_pix2pix.StableDiffusionXLInstructPix2PixPipeline testMethod=test_single_file_setting_cosxl_edit>
|
304 |
+
|
305 |
+
def test_single_file_setting_cosxl_edit(self):
|
306 |
+
# Default is PNDM for this checkpoint
|
307 |
+
> pipe = self.pipeline_class.from_single_file(self.ckpt_path, config=self.repo_id, is_cosxl_edit=True)
|
308 |
+
|
309 |
+
tests/single_file/test_stable_diffusion_xl_instruct_pix2pix.py:49:
|
310 |
+
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
311 |
+
/opt/venv/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py:119: in _inner_fn
|
312 |
+
return fn(*args, **kwargs)
|
313 |
+
src/diffusers/loaders/single_file.py:386: in from_single_file
|
314 |
+
checkpoint = load_single_file_checkpoint(
|
315 |
+
src/diffusers/loaders/single_file_utils.py:308: in load_single_file_checkpoint
|
316 |
+
pretrained_model_link_or_path = _get_model_file(
|
317 |
+
/opt/venv/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py:119: in _inner_fn
|
318 |
+
return fn(*args, **kwargs)
|
319 |
+
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
|
320 |
+
|
321 |
+
pretrained_model_name_or_path = 'stabilityai/cosxl'
|
322 |
+
|
323 |
+
@validate_hf_hub_args
|
324 |
+
def _get_model_file(
|
325 |
+
pretrained_model_name_or_path: Union[str, Path],
|
326 |
+
*,
|
327 |
+
weights_name: str,
|
328 |
+
subfolder: Optional[str] = None,
|
329 |
+
cache_dir: Optional[str] = None,
|
330 |
+
force_download: bool = False,
|
331 |
+
proxies: Optional[Dict] = None,
|
332 |
+
resume_download: bool = False,
|
333 |
+
local_files_only: bool = False,
|
334 |
+
token: Optional[str] = None,
|
335 |
+
user_agent: Optional[Union[Dict, str]] = None,
|
336 |
+
revision: Optional[str] = None,
|
337 |
+
commit_hash: Optional[str] = None,
|
338 |
+
local_dir: Optional[str] = None,
|
339 |
+
local_dir_use_symlinks: Optional[str] = "auto",
|
340 |
+
):
|
341 |
+
pretrained_model_name_or_path = str(pretrained_model_name_or_path)
|
342 |
+
if os.path.isfile(pretrained_model_name_or_path):
|
343 |
+
return pretrained_model_name_or_path
|
344 |
+
elif os.path.isdir(pretrained_model_name_or_path):
|
345 |
+
if os.path.isfile(os.path.join(pretrained_model_name_or_path, weights_name)):
|
346 |
+
# Load from a PyTorch checkpoint
|
347 |
+
model_file = os.path.join(pretrained_model_name_or_path, weights_name)
|
348 |
+
return model_file
|
349 |
+
elif subfolder is not None and os.path.isfile(
|
350 |
+
os.path.join(pretrained_model_name_or_path, subfolder, weights_name)
|
351 |
+
):
|
352 |
+
model_file = os.path.join(pretrained_model_name_or_path, subfolder, weights_name)
|
353 |
+
return model_file
|
354 |
+
else:
|
355 |
+
raise EnvironmentError(
|
356 |
+
f"Error no file named {weights_name} found in directory {pretrained_model_name_or_path}."
|
357 |
+
)
|
358 |
+
else:
|
359 |
+
# 1. First check if deprecated way of loading from branches is used
|
360 |
+
if (
|
361 |
+
revision in DEPRECATED_REVISION_ARGS
|
362 |
+
and (weights_name == WEIGHTS_NAME or weights_name == SAFETENSORS_WEIGHTS_NAME)
|
363 |
+
and version.parse(version.parse(__version__).base_version) >= version.parse("0.22.0")
|
364 |
+
):
|
365 |
+
try:
|
366 |
+
model_file = hf_hub_download(
|
367 |
+
pretrained_model_name_or_path,
|
368 |
+
filename=_add_variant(weights_name, revision),
|
369 |
+
cache_dir=cache_dir,
|
370 |
+
force_download=force_download,
|
371 |
+
proxies=proxies,
|
372 |
+
resume_download=resume_download,
|
373 |
+
local_files_only=local_files_only,
|
374 |
+
token=token,
|
375 |
+
user_agent=user_agent,
|
376 |
+
subfolder=subfolder,
|
377 |
+
revision=revision or commit_hash,
|
378 |
+
local_dir=local_dir,
|
379 |
+
local_dir_use_symlinks=local_dir_use_symlinks,
|
380 |
+
)
|
381 |
+
warnings.warn(
|
382 |
+
f"Loading the variant {revision} from {pretrained_model_name_or_path} via `revision='{revision}'` is deprecated. Loading instead from `revision='main'` with `variant={revision}`. Loading model variants via `revision='{revision}'` will be removed in diffusers v1. Please use `variant='{revision}'` instead.",
|
383 |
+
FutureWarning,
|
384 |
+
)
|
385 |
+
return model_file
|
386 |
+
except: # noqa: E722
|
387 |
+
warnings.warn(
|
388 |
+
f"You are loading the variant {revision} from {pretrained_model_name_or_path} via `revision='{revision}'`. This behavior is deprecated and will be removed in diffusers v1. One should use `variant='{revision}'` instead. However, it appears that {pretrained_model_name_or_path} currently does not have a {_add_variant(weights_name, revision)} file in the 'main' branch of {pretrained_model_name_or_path}. \n The Diffusers team and community would be very grateful if you could open an issue: https://github.com/huggingface/diffusers/issues/new with the title '{pretrained_model_name_or_path} is missing {_add_variant(weights_name, revision)}' so that the correct variant file can be added.",
|
389 |
+
FutureWarning,
|
390 |
+
)
|
391 |
+
try:
|
392 |
+
# 2. Load model file as usual
|
393 |
+
model_file = hf_hub_download(
|
394 |
+
pretrained_model_name_or_path,
|
395 |
+
filename=weights_name,
|
396 |
+
cache_dir=cache_dir,
|
397 |
+
force_download=force_download,
|
398 |
+
proxies=proxies,
|
399 |
+
resume_download=resume_download,
|
400 |
+
local_files_only=local_files_only,
|
401 |
+
token=token,
|
402 |
+
user_agent=user_agent,
|
403 |
+
subfolder=subfolder,
|
404 |
+
revision=revision or commit_hash,
|
405 |
+
local_dir=local_dir,
|
406 |
+
local_dir_use_symlinks=local_dir_use_symlinks,
|
407 |
+
)
|
408 |
+
return model_file
|
409 |
+
|
410 |
+
except RepositoryNotFoundError:
|
411 |
+
> raise EnvironmentError(
|
412 |
+
f"{pretrained_model_name_or_path} is not a local folder and is not a valid model identifier "
|
413 |
+
"listed on 'https://huggingface.co/models'\nIf this is a private repository, make sure to pass a "
|
414 |
+
"token having permission to this repo with `token` or log in with `huggingface-cli "
|
415 |
+
"login`."
|
416 |
+
)
|
417 |
+
E OSError: stabilityai/cosxl is not a local folder and is not a valid model identifier listed on 'https://huggingface.co/models'
|
418 |
+
E If this is a private repository, make sure to pass a token having permission to this repo with `token` or log in with `huggingface-cli login`.
|
419 |
+
|
420 |
+
src/diffusers/utils/hub_utils.py:365: OSError
|
421 |
+
=========================== short test summary info ============================
|
422 |
+
FAILED tests/single_file/test_stable_diffusion_xl_instruct_pix2pix.py::StableDiffusionXLInstructPix2PixPipeline::test_single_file_setting_cosxl_edit
|
423 |
+
============================== 1 failed in 16.23s ==============================
|
text_outputs_single_file/test_stable_diffusion_xl_single_file_output.txt
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
============================= test session starts ==============================
|
2 |
+
platform linux -- Python 3.8.10, pytest-8.2.0, pluggy-1.5.0
|
3 |
+
rootdir: /diffusers
|
4 |
+
configfile: pyproject.toml
|
5 |
+
plugins: xdist-3.6.1, timeout-2.3.1, requests-mock-1.10.0
|
6 |
+
collected 7 items
|
7 |
+
|
8 |
+
tests/single_file/test_stable_diffusion_xl_single_file.py ....... [100%]
|
9 |
+
|
10 |
+
========================= 7 passed in 62.63s (0:01:02) =========================
|