Skip to content

Commit

Permalink
Fix duplicate model key addition when root directory is a relative pa…
Browse files Browse the repository at this point in the history
…th (#3607)

This fixes model directory scanning so that it works properly when the
root is a relative path (e.g. ".").
  • Loading branch information
blessedcoolant authored Jun 29, 2023
2 parents e65e635 + 5be1e71 commit 8297b7e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion invokeai/backend/model_management/model_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,13 +675,15 @@ def scan_models_directory(
base_model: Optional[BaseModelType] = None,
model_type: Optional[ModelType] = None,
):

loaded_files = set()
new_models_found = False

self.logger.info(f'scanning {self.app_config.models_path} for new models')
with Chdir(self.app_config.root_path):
for model_key, model_config in list(self.models.items()):
model_name, cur_base_model, cur_model_type = self.parse_key(model_key)
model_path = self.app_config.root_path / model_config.path
model_path = self.app_config.root_path.absolute() / model_config.path
if not model_path.exists():
model_class = MODEL_CLASSES[cur_base_model][cur_model_type]
if model_class.save_to_config:
Expand Down

0 comments on commit 8297b7e

Please sign in to comment.