mirror of
https://github.com/huggingface/diffusers.git
synced 2026-01-27 17:22:53 +03:00
Change path to posix (modeling_utils.py) (#6781)
* Change path to posix * running isort * run style and quality checks --------- Co-authored-by: Sayak Paul <spsayakpaul@gmail.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user