Skip to content

Commit 53f498d

Browse files
authored
Use of Posix to better support Windows compatibility in testing_utils (#6587)
* changes in utils * removed loc
1 parent 9908609 commit 53f498d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/diffusers/utils/testing_utils.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def get_tests_dir(append_path=None):
137137
tests_dir = os.path.dirname(tests_dir)
138138

139139
if append_path:
140-
return os.path.join(tests_dir, append_path)
140+
return Path(tests_dir, append_path).as_posix()
141141
else:
142142
return tests_dir
143143

@@ -335,10 +335,9 @@ def python39_available():
335335

336336
def load_numpy(arry: Union[str, np.ndarray], local_path: Optional[str] = None) -> np.ndarray:
337337
if isinstance(arry, str):
338-
# local_path = "/home/patrick_huggingface_co/"
339338
if local_path is not None:
340339
# local_path can be passed to correct images of tests
341-
return os.path.join(local_path, "/".join([arry.split("/")[-5], arry.split("/")[-2], arry.split("/")[-1]]))
340+
return Path(local_path, arry.split("/")[-5], arry.split("/")[-2], arry.split("/")[-1]).as_posix()
342341
elif arry.startswith("http://") or arry.startswith("https://"):
343342
response = requests.get(arry)
344343
response.raise_for_status()
@@ -521,9 +520,9 @@ def export_to_video(video_frames: List[np.ndarray], output_video_path: str = Non
521520

522521
def load_hf_numpy(path) -> np.ndarray:
523522
if not path.startswith("http://") or path.startswith("https://"):
524-
path = os.path.join(
523+
path = Path(
525524
"https://huggingface.co/datasets/fusing/diffusers-testing/resolve/main", urllib.parse.quote(path)
526-
)
525+
).as_posix()
527526

528527
return load_numpy(path)
529528

0 commit comments

Comments
 (0)