Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions invokeai/app/invocations/anima_lora_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,18 @@ def invoke(self, context: InvocationContext) -> AnimaLoRALoaderOutput:
title="Apply LoRA Collection - Anima",
tags=["lora", "model", "anima"],
category="model",
version="1.0.0",
version="1.0.1",
classification=Classification.Prototype,
)
class AnimaLoRACollectionLoader(BaseInvocation):
"""Applies a collection of LoRAs to an Anima transformer."""

loras: Optional[LoRAField | list[LoRAField]] = InputField(
default=None, description="LoRA models and weights. May be a single LoRA or collection.", title="LoRAs"
default=None,
description="LoRA models and weights. May be a single LoRA or collection.",
title="LoRAs",
ui_model_base=[BaseModelType.Anima],
ui_model_type=ModelType.LoRA,
)

transformer: Optional[TransformerField] = InputField(
Expand Down
14 changes: 11 additions & 3 deletions invokeai/app/invocations/flux2_klein_lora_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,18 @@ def invoke(self, context: InvocationContext) -> Flux2KleinLoRALoaderOutput:
title="Apply LoRA Collection - Flux2 Klein",
tags=["lora", "model", "flux", "klein", "flux2"],
category="model",
version="1.0.0",
version="1.0.1",
classification=Classification.Prototype,
)
class Flux2KleinLoRACollectionLoader(BaseInvocation):
"""Applies a collection of LoRAs to a FLUX.2 Klein transformer and/or Qwen3 text encoder."""

loras: Optional[LoRAField | list[LoRAField]] = InputField(
default=None, description="LoRA models and weights. May be a single LoRA or collection.", title="LoRAs"
default=None,
description="LoRA models and weights. May be a single LoRA or collection.",
title="LoRAs",
ui_model_base=[BaseModelType.Flux2],
ui_model_type=ModelType.LoRA,
)

transformer: Optional[TransformerField] = InputField(
Expand Down Expand Up @@ -157,7 +161,11 @@ def invoke(self, context: InvocationContext) -> Flux2KleinLoRALoaderOutput:
if not context.models.exists(lora.lora.key):
raise Exception(f"Unknown lora: {lora.lora.key}!")

assert lora.lora.base in (BaseModelType.Flux, BaseModelType.Flux2)
if lora.lora.base is not BaseModelType.Flux2:
raise ValueError(
f"LoRA '{lora.lora.key}' is for {lora.lora.base.value if lora.lora.base else 'unknown'} models, "
"not FLUX.2 Klein models. Ensure you are using a FLUX.2 compatible LoRA."
)

# Warn if LoRA variant doesn't match transformer variant
lora_config = context.models.get_config(lora.lora.key)
Expand Down
14 changes: 11 additions & 3 deletions invokeai/app/invocations/flux_lora_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,17 @@ def invoke(self, context: InvocationContext) -> FluxLoRALoaderOutput:
title="Apply LoRA Collection - FLUX",
tags=["lora", "model", "flux"],
category="model",
version="1.3.1",
version="1.3.2",
)
class FLUXLoRACollectionLoader(BaseInvocation):
"""Applies a collection of LoRAs to a FLUX transformer."""

loras: Optional[LoRAField | list[LoRAField]] = InputField(
default=None, description="LoRA models and weights. May be a single LoRA or collection.", title="LoRAs"
default=None,
description="LoRA models and weights. May be a single LoRA or collection.",
title="LoRAs",
ui_model_base=[BaseModelType.Flux],
ui_model_type=ModelType.LoRA,
)

transformer: Optional[TransformerField] = InputField(
Expand Down Expand Up @@ -162,7 +166,11 @@ def invoke(self, context: InvocationContext) -> FluxLoRALoaderOutput:
if not context.models.exists(lora.lora.key):
raise Exception(f"Unknown lora: {lora.lora.key}!")

assert lora.lora.base in (BaseModelType.Flux, BaseModelType.Flux2)
if lora.lora.base is not BaseModelType.Flux:
raise ValueError(
f"LoRA '{lora.lora.key}' is for {lora.lora.base.value if lora.lora.base else 'unknown'} models, "
"not FLUX models. Ensure you are using a FLUX compatible LoRA."
)

added_loras.append(lora.lora.key)

Expand Down
16 changes: 12 additions & 4 deletions invokeai/app/invocations/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,17 @@ def invoke(self, context: InvocationContext) -> LoRASelectorOutput:


@invocation(
"lora_collection_loader", title="Apply LoRA Collection - SD1.5", tags=["model"], category="model", version="1.1.2"
"lora_collection_loader", title="Apply LoRA Collection - SD1.5", tags=["model"], category="model", version="1.1.3"
)
class LoRACollectionLoader(BaseInvocation):
"""Applies a collection of LoRAs to the provided UNet and CLIP models."""

loras: Optional[LoRAField | list[LoRAField]] = InputField(
default=None, description="LoRA models and weights. May be a single LoRA or collection.", title="LoRAs"
default=None,
description="LoRA models and weights. May be a single LoRA or collection.",
title="LoRAs",
ui_model_base=[BaseModelType.StableDiffusion1, BaseModelType.StableDiffusion2],
ui_model_type=ModelType.LoRA,
)
unet: Optional[UNetField] = InputField(
default=None,
Expand Down Expand Up @@ -432,13 +436,17 @@ def invoke(self, context: InvocationContext) -> SDXLLoRALoaderOutput:
title="Apply LoRA Collection - SDXL",
tags=["model"],
category="model",
version="1.1.2",
version="1.1.3",
)
class SDXLLoRACollectionLoader(BaseInvocation):
"""Applies a collection of SDXL LoRAs to the provided UNet and CLIP models."""

loras: Optional[LoRAField | list[LoRAField]] = InputField(
default=None, description="LoRA models and weights. May be a single LoRA or collection.", title="LoRAs"
default=None,
description="LoRA models and weights. May be a single LoRA or collection.",
title="LoRAs",
ui_model_base=[BaseModelType.StableDiffusionXL],
ui_model_type=ModelType.LoRA,
)
unet: Optional[UNetField] = InputField(
default=None,
Expand Down
8 changes: 6 additions & 2 deletions invokeai/app/invocations/qwen_image_lora_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,18 @@ def invoke(self, context: InvocationContext) -> QwenImageLoRALoaderOutput:
title="Apply LoRA Collection - Qwen Image",
tags=["lora", "model", "qwen_image"],
category="model",
version="1.0.0",
version="1.0.1",
classification=Classification.Prototype,
)
class QwenImageLoRACollectionLoader(BaseInvocation):
"""Applies a collection of LoRAs to a Qwen Image transformer."""

loras: Optional[LoRAField | list[LoRAField]] = InputField(
default=None, description="LoRA models and weights. May be a single LoRA or collection.", title="LoRAs"
default=None,
description="LoRA models and weights. May be a single LoRA or collection.",
title="LoRAs",
ui_model_base=[BaseModelType.QwenImage],
ui_model_type=ModelType.LoRA,
)
transformer: Optional[TransformerField] = InputField(
default=None,
Expand Down
8 changes: 6 additions & 2 deletions invokeai/app/invocations/z_image_lora_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,17 @@ def invoke(self, context: InvocationContext) -> ZImageLoRALoaderOutput:
title="Apply LoRA Collection - Z-Image",
tags=["lora", "model", "z-image"],
category="model",
version="1.0.0",
version="1.0.1",
)
class ZImageLoRACollectionLoader(BaseInvocation):
"""Applies a collection of LoRAs to a Z-Image transformer."""

loras: Optional[LoRAField | list[LoRAField]] = InputField(
default=None, description="LoRA models and weights. May be a single LoRA or collection.", title="LoRAs"
default=None,
description="LoRA models and weights. May be a single LoRA or collection.",
title="LoRAs",
ui_model_base=[BaseModelType.ZImage],
ui_model_type=ModelType.LoRA,
)

transformer: Optional[TransformerField] = InputField(
Expand Down
42 changes: 28 additions & 14 deletions invokeai/frontend/web/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -10917,7 +10917,9 @@
"input": "any",
"orig_default": null,
"orig_required": false,
"title": "LoRAs"
"title": "LoRAs",
"ui_model_base": ["anima"],
"ui_model_type": ["lora"]
},
"transformer": {
"anyOf": [
Expand Down Expand Up @@ -10965,7 +10967,7 @@
"tags": ["lora", "model", "anima"],
"title": "Apply LoRA Collection - Anima",
"type": "object",
"version": "1.0.0",
"version": "1.0.1",
"output": {
"$ref": "#/components/schemas/AnimaLoRALoaderOutput"
}
Expand Down Expand Up @@ -22892,7 +22894,9 @@
"input": "any",
"orig_default": null,
"orig_required": false,
"title": "LoRAs"
"title": "LoRAs",
"ui_model_base": ["flux"],
"ui_model_type": ["lora"]
},
"transformer": {
"anyOf": [
Expand Down Expand Up @@ -22957,7 +22961,7 @@
"tags": ["lora", "model", "flux"],
"title": "Apply LoRA Collection - FLUX",
"type": "object",
"version": "1.3.1",
"version": "1.3.2",
"output": {
"$ref": "#/components/schemas/FluxLoRALoaderOutput"
}
Expand Down Expand Up @@ -24524,7 +24528,9 @@
"input": "any",
"orig_default": null,
"orig_required": false,
"title": "LoRAs"
"title": "LoRAs",
"ui_model_base": ["flux2"],
"ui_model_type": ["lora"]
},
"transformer": {
"anyOf": [
Expand Down Expand Up @@ -24572,7 +24578,7 @@
"tags": ["lora", "model", "flux", "klein", "flux2"],
"title": "Apply LoRA Collection - Flux2 Klein",
"type": "object",
"version": "1.0.0",
"version": "1.0.1",
"output": {
"$ref": "#/components/schemas/Flux2KleinLoRALoaderOutput"
}
Expand Down Expand Up @@ -43603,7 +43609,9 @@
"input": "any",
"orig_default": null,
"orig_required": false,
"title": "LoRAs"
"title": "LoRAs",
"ui_model_base": ["sd-1", "sd-2"],
"ui_model_type": ["lora"]
},
"unet": {
"anyOf": [
Expand Down Expand Up @@ -43651,7 +43659,7 @@
"tags": ["model"],
"title": "Apply LoRA Collection - SD1.5",
"type": "object",
"version": "1.1.2",
"version": "1.1.3",
"output": {
"$ref": "#/components/schemas/LoRALoaderOutput"
}
Expand Down Expand Up @@ -60174,7 +60182,9 @@
"input": "any",
"orig_default": null,
"orig_required": false,
"title": "LoRAs"
"title": "LoRAs",
"ui_model_base": ["qwen-image"],
"ui_model_type": ["lora"]
},
"transformer": {
"anyOf": [
Expand Down Expand Up @@ -60205,7 +60215,7 @@
"tags": ["lora", "model", "qwen_image"],
"title": "Apply LoRA Collection - Qwen Image",
"type": "object",
"version": "1.0.0",
"version": "1.0.1",
"output": {
"$ref": "#/components/schemas/QwenImageLoRALoaderOutput"
}
Expand Down Expand Up @@ -62880,7 +62890,9 @@
"input": "any",
"orig_default": null,
"orig_required": false,
"title": "LoRAs"
"title": "LoRAs",
"ui_model_base": ["sdxl"],
"ui_model_type": ["lora"]
},
"unet": {
"anyOf": [
Expand Down Expand Up @@ -62945,7 +62957,7 @@
"tags": ["model"],
"title": "Apply LoRA Collection - SDXL",
"type": "object",
"version": "1.1.2",
"version": "1.1.3",
"output": {
"$ref": "#/components/schemas/SDXLLoRALoaderOutput"
}
Expand Down Expand Up @@ -73404,7 +73416,9 @@
"input": "any",
"orig_default": null,
"orig_required": false,
"title": "LoRAs"
"title": "LoRAs",
"ui_model_base": ["z-image"],
"ui_model_type": ["lora"]
},
"transformer": {
"anyOf": [
Expand Down Expand Up @@ -73452,7 +73466,7 @@
"tags": ["lora", "model", "z-image"],
"title": "Apply LoRA Collection - Z-Image",
"type": "object",
"version": "1.0.0",
"version": "1.0.1",
"output": {
"$ref": "#/components/schemas/ZImageLoRALoaderOutput"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ImageFieldCollectionInputComponent } from 'features/nodes/components/fl
import { ImageGeneratorFieldInputComponent } from 'features/nodes/components/flow/nodes/Invocation/fields/inputs/ImageGeneratorFieldComponent';
import { IntegerFieldCollectionInputComponent } from 'features/nodes/components/flow/nodes/Invocation/fields/inputs/IntegerFieldCollectionInputComponent';
import { IntegerGeneratorFieldInputComponent } from 'features/nodes/components/flow/nodes/Invocation/fields/inputs/IntegerGeneratorFieldComponent';
import { LoRAFieldCollectionInputComponent } from 'features/nodes/components/flow/nodes/Invocation/fields/inputs/LoRAFieldCollectionInputComponent';
import ModelIdentifierFieldInputComponent from 'features/nodes/components/flow/nodes/Invocation/fields/inputs/ModelIdentifierFieldInputComponent';
import { StringFieldCollectionInputComponent } from 'features/nodes/components/flow/nodes/Invocation/fields/inputs/StringFieldCollectionInputComponent';
import { StringGeneratorFieldInputComponent } from 'features/nodes/components/flow/nodes/Invocation/fields/inputs/StringGeneratorFieldComponent';
Expand Down Expand Up @@ -45,6 +46,8 @@ import {
isIntegerFieldInputTemplate,
isIntegerGeneratorFieldInputInstance,
isIntegerGeneratorFieldInputTemplate,
isLoRAFieldCollectionInputInstance,
isLoRAFieldCollectionInputTemplate,
isModelIdentifierFieldInputInstance,
isModelIdentifierFieldInputTemplate,
isSchedulerFieldInputInstance,
Expand Down Expand Up @@ -91,6 +94,13 @@ export const InputFieldRenderer = memo(({ nodeId, fieldName, settings }: Props)
return <StringFieldCollectionInputComponent nodeId={nodeId} field={field} fieldTemplate={template} />;
}

if (isLoRAFieldCollectionInputTemplate(template)) {
if (!isLoRAFieldCollectionInputInstance(field)) {
return null;
}
return <LoRAFieldCollectionInputComponent nodeId={nodeId} field={field} fieldTemplate={template} />;
}

if (isStringFieldInputTemplate(template)) {
if (!isStringFieldInputInstance(field)) {
return null;
Expand Down
Loading
Loading