Skip to content

Commit 161c6e1

Browse files
Change path to posix (modeling_utils.py) (#6781)
* Change path to posix * running isort * run style and quality checks --------- Co-authored-by: Sayak Paul <[email protected]>
1 parent a6c9015 commit 161c6e1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/diffusers/models/modeling_utils.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import re
2121
from collections import OrderedDict
2222
from functools import partial
23+
from pathlib import Path
2324
from typing import Any, Callable, List, Optional, Tuple, Union
2425

2526
import safetensors
@@ -367,18 +368,18 @@ def save_pretrained(
367368
# Save the model
368369
if safe_serialization:
369370
safetensors.torch.save_file(
370-
state_dict, os.path.join(save_directory, weights_name), metadata={"format": "pt"}
371+
state_dict, Path(save_directory, weights_name).as_posix(), metadata={"format": "pt"}
371372
)
372373
else:
373-
torch.save(state_dict, os.path.join(save_directory, weights_name))
374+
torch.save(state_dict, Path(save_directory, weights_name).as_posix())
374375

375-
logger.info(f"Model weights saved in {os.path.join(save_directory, weights_name)}")
376+
logger.info(f"Model weights saved in {Path(save_directory, weights_name).as_posix()}")
376377

377378
if push_to_hub:
378379
# Create a new empty model card and eventually tag it
379380
model_card = load_or_create_model_card(repo_id, token=token)
380381
model_card = populate_model_card(model_card)
381-
model_card.save(os.path.join(save_directory, "README.md"))
382+
model_card.save(Path(save_directory, "README.md").as_posix())
382383

383384
self._upload_folder(
384385
save_directory,

0 commit comments

Comments
 (0)