Skip to content

Commit

Permalink
restore original model_index.json after save_pretrained call (#961)
Browse files Browse the repository at this point in the history
  • Loading branch information
eaidova authored Oct 24, 2024
1 parent b1f8d1d commit a432102
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions optimum/intel/openvino/modeling_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,26 @@ def _save_pretrained(self, save_directory: Union[str, Path]):

self._save_openvino_config(save_directory)

def _save_config(self, save_directory):
"""
Saves a model configuration into a directory, so that it can be re-loaded using the
[`from_pretrained`] class method.
"""
model_dir = (
self.model_save_dir
if not isinstance(self.model_save_dir, TemporaryDirectory)
else self.model_save_dir.name
)
save_dir = Path(save_directory)
original_config = Path(model_dir) / self.config_name
if original_config.exists():
if not save_dir.exists():
save_dir.mkdir(parents=True)

shutil.copy(original_config, save_dir)
else:
self.config.save_pretrained(save_dir)

@classmethod
def _from_pretrained(
cls,
Expand Down

0 comments on commit a432102

Please sign in to comment.