Skip to content

Commit a9f3f1a

Browse files
fix(app): handle model files with periods in their name
Previously, we used pathlib's `with_suffix()` method to change add a suffix (e.g. ".safetensors") to a model when installing it. The intention is to add a suffix to the model's name - but that method actually replaces everything after the first period. This can cause different models to be installed under the same name! For example, the FLUX models all end up with the same name: - "FLUX.1 schnell.safetensors" -> "FLUX.safetensors" - "FLUX.1 dev.safetensors" -> "FLUX.safetensors" The fix is easy - append the suffix using string formatting instead of using pathlib. This issue has existed for a long time, but was exacerbated in 075345b in which I updated the names of our starter models, adding ".1" to the FLUX model names. Whoops!
1 parent 8a73df4 commit a9f3f1a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

invokeai/app/services/model_install/model_install_default.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ def install_path(
186186
info: AnyModelConfig = self._probe(Path(model_path), config) # type: ignore
187187

188188
if preferred_name := config.name:
189-
preferred_name = Path(preferred_name).with_suffix(model_path.suffix)
189+
# Careful! Don't use pathlib.Path(...).with_suffix - it can will strip everything after the first dot.
190+
preferred_name = f"{preferred_name}{model_path.suffix}"
190191

191192
dest_path = (
192193
self.app_config.models_path / info.base.value / info.type.value / (preferred_name or model_path.name)

0 commit comments

Comments
 (0)