Retain suffix (.safetensors, .bin) when renaming a checkpoint file or LoRA

- closes #5518
This commit is contained in:
Lincoln Stein 2024-01-16 17:04:27 -05:00 committed by Kent Keirsey
parent 2953dea4a0
commit bd31b5606c

View File

@ -759,7 +759,7 @@ class ModelManager(object):
model_type: ModelType,
new_name: Optional[str] = None,
new_base: Optional[BaseModelType] = None,
):
) -> None:
"""
Rename or rebase a model.
"""
@ -781,6 +781,9 @@ class ModelManager(object):
# if this is a model file/directory that we manage ourselves, we need to move it
if old_path.is_relative_to(self.app_config.models_path):
# keep the suffix!
if old_path.is_file():
new_name = Path(new_name).with_suffix(old_path.suffix).as_posix()
new_path = self.resolve_model_path(
Path(
BaseModelType(new_base).value,