mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
add support for downloading and installing LCM lora diffusers models
This commit is contained in:
parent
d7f0a7919f
commit
8702a63197
@ -254,7 +254,13 @@ class ModelInstall(object):
|
|||||||
elif path.is_dir() and any(
|
elif path.is_dir() and any(
|
||||||
[
|
[
|
||||||
(path / x).exists()
|
(path / x).exists()
|
||||||
for x in {"config.json", "model_index.json", "learned_embeds.bin", "pytorch_lora_weights.bin"}
|
for x in {
|
||||||
|
"config.json",
|
||||||
|
"model_index.json",
|
||||||
|
"learned_embeds.bin",
|
||||||
|
"pytorch_lora_weights.bin",
|
||||||
|
"pytorch_lora_weights.safetensors",
|
||||||
|
}
|
||||||
]
|
]
|
||||||
):
|
):
|
||||||
models_installed.update({str(model_path_id_or_url): self._install_path(path)})
|
models_installed.update({str(model_path_id_or_url): self._install_path(path)})
|
||||||
@ -357,7 +363,7 @@ class ModelInstall(object):
|
|||||||
for suffix in ["safetensors", "bin"]:
|
for suffix in ["safetensors", "bin"]:
|
||||||
if f"{prefix}pytorch_lora_weights.{suffix}" in files:
|
if f"{prefix}pytorch_lora_weights.{suffix}" in files:
|
||||||
location = self._download_hf_model(
|
location = self._download_hf_model(
|
||||||
repo_id, ["pytorch_lora_weights.bin"], staging, subfolder=subfolder
|
repo_id, [f"pytorch_lora_weights.{suffix}"], staging, subfolder=subfolder
|
||||||
) # LoRA
|
) # LoRA
|
||||||
break
|
break
|
||||||
elif (
|
elif (
|
||||||
|
@ -183,12 +183,13 @@ class ModelProbe(object):
|
|||||||
if model:
|
if model:
|
||||||
class_name = model.__class__.__name__
|
class_name = model.__class__.__name__
|
||||||
else:
|
else:
|
||||||
|
for suffix in ["bin", "safetensors"]:
|
||||||
|
if (folder_path / f"learned_embeds.{suffix}").exists():
|
||||||
|
return ModelType.TextualInversion
|
||||||
|
if (folder_path / f"pytorch_lora_weights.{suffix}").exists():
|
||||||
|
return ModelType.Lora
|
||||||
if (folder_path / "unet/model.onnx").exists():
|
if (folder_path / "unet/model.onnx").exists():
|
||||||
return ModelType.ONNX
|
return ModelType.ONNX
|
||||||
if (folder_path / "learned_embeds.bin").exists():
|
|
||||||
return ModelType.TextualInversion
|
|
||||||
if (folder_path / "pytorch_lora_weights.bin").exists():
|
|
||||||
return ModelType.Lora
|
|
||||||
if (folder_path / "image_encoder.txt").exists():
|
if (folder_path / "image_encoder.txt").exists():
|
||||||
return ModelType.IPAdapter
|
return ModelType.IPAdapter
|
||||||
|
|
||||||
|
@ -68,7 +68,8 @@ class LoRAModel(ModelBase):
|
|||||||
raise ModelNotFoundException()
|
raise ModelNotFoundException()
|
||||||
|
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
if os.path.exists(os.path.join(path, "pytorch_lora_weights.bin")):
|
for ext in ["safetensors", "bin"]:
|
||||||
|
if os.path.exists(os.path.join(path, f"pytorch_lora_weights.{ext}")):
|
||||||
return LoRAModelFormat.Diffusers
|
return LoRAModelFormat.Diffusers
|
||||||
|
|
||||||
if os.path.isfile(path):
|
if os.path.isfile(path):
|
||||||
@ -86,8 +87,10 @@ class LoRAModel(ModelBase):
|
|||||||
base_model: BaseModelType,
|
base_model: BaseModelType,
|
||||||
) -> str:
|
) -> str:
|
||||||
if cls.detect_format(model_path) == LoRAModelFormat.Diffusers:
|
if cls.detect_format(model_path) == LoRAModelFormat.Diffusers:
|
||||||
# TODO: add diffusers lora when it stabilizes a bit
|
for ext in ["safetensors", "bin"]: # return path to the safetensors file inside the folder
|
||||||
raise NotImplementedError("Diffusers lora not supported")
|
path = Path(model_path, f"pytorch_lora_weights.{ext}")
|
||||||
|
if path.exists():
|
||||||
|
return path
|
||||||
else:
|
else:
|
||||||
return model_path
|
return model_path
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user