From 161c6e14b6d48aa830832fc180a51ee03e4411be Mon Sep 17 00:00:00 2001 From: Stephen Date: Tue, 19 Mar 2024 17:50:34 -0400 Subject: [PATCH] Change path to posix (modeling_utils.py) (#6781) * Change path to posix * running isort * run style and quality checks --------- Co-authored-by: Sayak Paul --- src/diffusers/models/modeling_utils.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/diffusers/models/modeling_utils.py b/src/diffusers/models/modeling_utils.py index 73ea5fb07e..bc5dfaee04 100644 --- a/src/diffusers/models/modeling_utils.py +++ b/src/diffusers/models/modeling_utils.py @@ -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,