mirror of
https://github.com/huggingface/diffusers.git
synced 2026-01-27 17:22:53 +03:00
Use of Posix to better support Windows compatibility in testing_utils (#6587)
* changes in utils * removed loc
This commit is contained in:
@@ -137,7 +137,7 @@ def get_tests_dir(append_path=None):
|
||||
tests_dir = os.path.dirname(tests_dir)
|
||||
|
||||
if append_path:
|
||||
return os.path.join(tests_dir, append_path)
|
||||
return Path(tests_dir, append_path).as_posix()
|
||||
else:
|
||||
return tests_dir
|
||||
|
||||
@@ -335,10 +335,9 @@ def require_python39_or_higher(test_case):
|
||||
|
||||
def load_numpy(arry: Union[str, np.ndarray], local_path: Optional[str] = None) -> np.ndarray:
|
||||
if isinstance(arry, str):
|
||||
# local_path = "/home/patrick_huggingface_co/"
|
||||
if local_path is not None:
|
||||
# local_path can be passed to correct images of tests
|
||||
return os.path.join(local_path, "/".join([arry.split("/")[-5], arry.split("/")[-2], arry.split("/")[-1]]))
|
||||
return Path(local_path, arry.split("/")[-5], arry.split("/")[-2], arry.split("/")[-1]).as_posix()
|
||||
elif arry.startswith("http://") or arry.startswith("https://"):
|
||||
response = requests.get(arry)
|
||||
response.raise_for_status()
|
||||
@@ -521,9 +520,9 @@ def export_to_video(video_frames: List[np.ndarray], output_video_path: str = Non
|
||||
|
||||
def load_hf_numpy(path) -> np.ndarray:
|
||||
if not path.startswith("http://") or path.startswith("https://"):
|
||||
path = os.path.join(
|
||||
path = Path(
|
||||
"https://huggingface.co/datasets/fusing/diffusers-testing/resolve/main", urllib.parse.quote(path)
|
||||
)
|
||||
).as_posix()
|
||||
|
||||
return load_numpy(path)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user