Unverified Commit 161c6e14 authored by Stephen's avatar Stephen Committed by GitHub
Browse files

Change path to posix (modeling_utils.py) (#6781)



* Change path to posix

* running isort

* run style and quality checks

---------
Co-authored-by: default avatarSayak Paul <spsayakpaul@gmail.com>
parent a6c9015c
......@@ -20,6 +20,7 @@ import os
import re
from collections import OrderedDict
from functools import partial
from pathlib import Path
from typing import Any, Callable, List, Optional, Tuple, Union
import safetensors
......@@ -367,18 +368,18 @@ class ModelMixin(torch.nn.Module, PushToHubMixin):
# Save the model
if safe_serialization:
safetensors.torch.save_file(
state_dict, os.path.join(save_directory, weights_name), metadata={"format": "pt"}
state_dict, Path(save_directory, weights_name).as_posix(), metadata={"format": "pt"}
)
else:
torch.save(state_dict, os.path.join(save_directory, weights_name))
torch.save(state_dict, Path(save_directory, weights_name).as_posix())
logger.info(f"Model weights saved in {os.path.join(save_directory, weights_name)}")
logger.info(f"Model weights saved in {Path(save_directory, weights_name).as_posix()}")
if push_to_hub:
# Create a new empty model card and eventually tag it
model_card = load_or_create_model_card(repo_id, token=token)
model_card = populate_model_card(model_card)
model_card.save(os.path.join(save_directory, "README.md"))
model_card.save(Path(save_directory, "README.md").as_posix())
self._upload_folder(
save_directory,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment