fix "unknown model type" error when rebasing a model with API

- Add command-line model probing script for dev use
- Minor documentation tweak
This commit is contained in:
Lincoln Stein 2023-07-25 08:36:57 -04:00
parent 8c449c4756
commit 2aefa921fe
4 changed files with 27 additions and 6 deletions

View File

@ -40,10 +40,8 @@ experimental versions later.
this, open up a command-line window ("Terminal" on Linux and
Macintosh, "Command" or "Powershell" on Windows) and type `python
--version`. If Python is installed, it will print out the version
number. If it is version `3.9.*` or `3.10.*`, you meet
requirements. We do not recommend using Python 3.11 or higher,
as not all the libraries that InvokeAI depends on work properly
with this version.
number. If it is version `3.9.*`, `3.10.*` or `3.11.*` you meet
requirements.
!!! warning "What to do if you have an unsupported version"

View File

@ -87,7 +87,7 @@ async def update_model(
new_name = info.model_name,
new_base = info.base_model,
)
logger.info(f'Successfully renamed {base_model}/{model_name}=>{info.base_model}/{info.model_name}')
logger.info(f'Successfully renamed {base_model.value}/{model_name}=>{info.base_model}/{info.model_name}')
# update information to support an update of attributes
model_name = info.model_name
base_model = info.base_model
@ -98,7 +98,7 @@ async def update_model(
)
if new_info.get('path') != previous_info.get('path'): # model manager moved model path during rename - don't overwrite it
info.path = new_info.get('path')
ApiDependencies.invoker.services.model_manager.update_model(
model_name=model_name,
base_model=base_model,

View File

@ -391,6 +391,10 @@ class ModelManager(object):
base_model: BaseModelType,
model_type: ModelType,
) -> str:
# In 3.11, the behavior of (str,enum) when interpolated into a
# string has changed. The next two lines are defensive.
base_model = BaseModelType(base_model)
model_type = ModelType(model_type)
return f"{base_model.value}/{model_type.value}/{model_name}"
@classmethod

19
scripts/probe-model.py Executable file
View File

@ -0,0 +1,19 @@
#!/bin/env python
import argparse
import sys
from pathlib import Path
from invokeai.backend.model_management.model_probe import ModelProbe
parser = argparse.ArgumentParser(description="Probe model type")
parser.add_argument(
'model_path',
type=Path,
)
args=parser.parse_args()
info = ModelProbe().probe(args.model_path)
print(info)