add installer support for ip-adapters

This commit is contained in:
Lincoln Stein 2023-09-24 17:31:08 -04:00
parent e3de996525
commit 297f96c16b
2 changed files with 54 additions and 1 deletions

View File

@ -103,3 +103,28 @@ sd-1/lora/LowRA:
recommended: True recommended: True
sd-1/lora/Ink scenery: sd-1/lora/Ink scenery:
path: https://civitai.com/api/download/models/83390 path: https://civitai.com/api/download/models/83390
# any/clip_vision/ip_adapter_sd_image_encoder:
# repo_id: InvokeAI/ip_adapter_sd_image_encoder
# recommended: True
# description: Required model for using IP-Adapters with SD-1/2 models
# any/clip_vision/ip_adapter_sdxl_image_encoder:
# repo_id: InvokeAI/ip_adapter_sdxl_image_encoder
# recommended: True
# description: Required model for using IP-Adapters with SDXL models
sd-1/ip_adapter/ip_adapter_sd15:
repo_id: InvokeAI/ip_adapter_sd15
recommended: True
description: IP-Adapter for SD 1.5 models
sd-1/ip_adapter/ip_adapter_plus_sd15:
repo_id: InvokeAI/ip_adapter_plus_sd15
recommended: False
description: Refined IP-Adapter for SD 1.5 models
sd-1/ip_adapter/ip_adapter_plus_face_sd15:
repo_id: InvokeAI/ip_adapter_plus_face_sd15
recommended: False
description: Refined IP-Adapter for SD 1.5 models, adapted for faces
sdxl/ip_adapter/ip_adapter_sdxl:
repo_id: InvokeAI/ip_adapter_sdxl
recommended: False
description: IP-Adapter for SDXL models

View File

@ -101,11 +101,12 @@ class addModelsForm(CyclingForm, npyscreen.FormMultiPage):
"STARTER MODELS", "STARTER MODELS",
"MAIN MODELS", "MAIN MODELS",
"CONTROLNETS", "CONTROLNETS",
"IP-ADAPTERS",
"LORA/LYCORIS", "LORA/LYCORIS",
"TEXTUAL INVERSION", "TEXTUAL INVERSION",
], ],
value=[self.current_tab], value=[self.current_tab],
columns=5, columns=6,
max_height=2, max_height=2,
relx=8, relx=8,
scroll_exit=True, scroll_exit=True,
@ -130,6 +131,13 @@ class addModelsForm(CyclingForm, npyscreen.FormMultiPage):
) )
bottom_of_table = max(bottom_of_table, self.nextrely) bottom_of_table = max(bottom_of_table, self.nextrely)
self.nextrely = top_of_table
self.ipadapter_models = self.add_model_widgets(
model_type=ModelType.IPAdapter,
window_width=window_width,
)
bottom_of_table = max(bottom_of_table, self.nextrely)
self.nextrely = top_of_table self.nextrely = top_of_table
self.lora_models = self.add_model_widgets( self.lora_models = self.add_model_widgets(
model_type=ModelType.Lora, model_type=ModelType.Lora,
@ -343,6 +351,7 @@ class addModelsForm(CyclingForm, npyscreen.FormMultiPage):
self.starter_pipelines, self.starter_pipelines,
self.pipeline_models, self.pipeline_models,
self.controlnet_models, self.controlnet_models,
self.ipadapter_models,
self.lora_models, self.lora_models,
self.ti_models, self.ti_models,
] ]
@ -532,6 +541,7 @@ class addModelsForm(CyclingForm, npyscreen.FormMultiPage):
self.starter_pipelines, self.starter_pipelines,
self.pipeline_models, self.pipeline_models,
self.controlnet_models, self.controlnet_models,
self.ipadapter_models,
self.lora_models, self.lora_models,
self.ti_models, self.ti_models,
] ]
@ -553,6 +563,24 @@ class addModelsForm(CyclingForm, npyscreen.FormMultiPage):
if downloads := section.get("download_ids"): if downloads := section.get("download_ids"):
selections.install_models.extend(downloads.value.split()) selections.install_models.extend(downloads.value.split())
# special case for the ipadapter_models. If any of the adapters are
# chosen, then we add the corresponding encoder(s) to the install list.
section = self.ipadapter_models
if section.get("models_selected"):
selected_adapters = [
self.all_models[section["models"][x]].name for x in section.get("models_selected").value
]
encoders = []
if any(["sdxl" in x for x in selected_adapters]):
encoders.append("ip_adapter_sdxl_image_encoder")
if any(["sd15" in x for x in selected_adapters]):
encoders.append("ip_adapter_sd_image_encoder")
for encoder in encoders:
key = f"any/clip_vision/{encoder}"
repo_id = f"InvokeAI/{encoder}"
if key not in self.all_models:
selections.install_models.append(repo_id)
class AddModelApplication(npyscreen.NPSAppManaged): class AddModelApplication(npyscreen.NPSAppManaged):
def __init__(self, opt): def __init__(self, opt):