Skip to content

Commit d876d29

Browse files
PhilLabJimmy
authored and
Jimmy
committedApr 26, 2024
Fixed is_safetensors_compatible() handling of windows path separators (huggingface#5650)
Closes huggingface#4665
1 parent 8fb648f commit d876d29

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed
 

‎src/diffusers/pipelines/pipeline_utils.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ def is_safetensors_compatible(filenames, variant=None, passed_components=None) -
158158
continue
159159

160160
if extension == ".bin":
161-
pt_filenames.append(filename)
161+
pt_filenames.append(os.path.normpath(filename))
162162
elif extension == ".safetensors":
163-
sf_filenames.add(filename)
163+
sf_filenames.add(os.path.normpath(filename))
164164

165165
for filename in pt_filenames:
166166
# filename = 'foo/bar/baz.bam' -> path = 'foo/bar', filename = 'baz', extention = '.bam'
@@ -172,9 +172,8 @@ def is_safetensors_compatible(filenames, variant=None, passed_components=None) -
172172
else:
173173
filename = filename
174174

175-
expected_sf_filename = os.path.join(path, filename)
175+
expected_sf_filename = os.path.normpath(os.path.join(path, filename))
176176
expected_sf_filename = f"{expected_sf_filename}.safetensors"
177-
178177
if expected_sf_filename not in sf_filenames:
179178
logger.warning(f"{expected_sf_filename} not found")
180179
return False
@@ -1774,7 +1773,7 @@ def download(cls, pretrained_model_name, **kwargs) -> Union[str, os.PathLike]:
17741773
)
17751774
):
17761775
raise EnvironmentError(
1777-
f"Could not found the necessary `safetensors` weights in {model_filenames} (variant={variant})"
1776+
f"Could not find the necessary `safetensors` weights in {model_filenames} (variant={variant})"
17781777
)
17791778
if from_flax:
17801779
ignore_patterns = ["*.bin", "*.safetensors", "*.onnx", "*.pb"]

0 commit comments

Comments
 (0)