2024-01-13 04:23:06 +00:00
|
|
|
from invokeai.app.invocations.fields import FieldDescriptions, Input, InputField, OutputField, UIType
|
2024-02-05 06:16:35 +00:00
|
|
|
from invokeai.app.services.shared.invocation_context import InvocationContext
|
2024-02-06 03:56:32 +00:00
|
|
|
from invokeai.backend.model_manager import SubModelType
|
2023-11-08 23:43:38 +00:00
|
|
|
|
2023-08-14 03:23:09 +00:00
|
|
|
from .baseinvocation import (
|
|
|
|
BaseInvocation,
|
|
|
|
BaseInvocationOutput,
|
feat(nodes): move all invocation metadata (type, title, tags, category) to decorator
All invocation metadata (type, title, tags and category) are now defined in decorators.
The decorators add the `type: Literal["invocation_type"]: "invocation_type"` field to the invocation.
Category is a new invocation metadata, but it is not used by the frontend just yet.
- `@invocation()` decorator for invocations
```py
@invocation(
"sdxl_compel_prompt",
title="SDXL Prompt",
tags=["sdxl", "compel", "prompt"],
category="conditioning",
)
class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
...
```
- `@invocation_output()` decorator for invocation outputs
```py
@invocation_output("clip_skip_output")
class ClipSkipInvocationOutput(BaseInvocationOutput):
...
```
- update invocation docs
- add category to decorator
- regen frontend types
2023-08-30 08:35:12 +00:00
|
|
|
invocation,
|
|
|
|
invocation_output,
|
2023-08-14 03:23:09 +00:00
|
|
|
)
|
2024-03-06 08:42:47 +00:00
|
|
|
from .model import CLIPField, ModelField, UNetField, VAEField
|
2023-07-11 15:19:36 +00:00
|
|
|
|
2023-07-27 14:54:01 +00:00
|
|
|
|
feat(nodes): move all invocation metadata (type, title, tags, category) to decorator
All invocation metadata (type, title, tags and category) are now defined in decorators.
The decorators add the `type: Literal["invocation_type"]: "invocation_type"` field to the invocation.
Category is a new invocation metadata, but it is not used by the frontend just yet.
- `@invocation()` decorator for invocations
```py
@invocation(
"sdxl_compel_prompt",
title="SDXL Prompt",
tags=["sdxl", "compel", "prompt"],
category="conditioning",
)
class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
...
```
- `@invocation_output()` decorator for invocation outputs
```py
@invocation_output("clip_skip_output")
class ClipSkipInvocationOutput(BaseInvocationOutput):
...
```
- update invocation docs
- add category to decorator
- regen frontend types
2023-08-30 08:35:12 +00:00
|
|
|
@invocation_output("sdxl_model_loader_output")
|
2023-07-16 16:17:56 +00:00
|
|
|
class SDXLModelLoaderOutput(BaseInvocationOutput):
|
|
|
|
"""SDXL base model loader output"""
|
|
|
|
|
2023-08-14 03:23:09 +00:00
|
|
|
unet: UNetField = OutputField(description=FieldDescriptions.unet, title="UNet")
|
2024-03-06 08:42:47 +00:00
|
|
|
clip: CLIPField = OutputField(description=FieldDescriptions.clip, title="CLIP 1")
|
|
|
|
clip2: CLIPField = OutputField(description=FieldDescriptions.clip, title="CLIP 2")
|
|
|
|
vae: VAEField = OutputField(description=FieldDescriptions.vae, title="VAE")
|
2023-07-16 16:17:56 +00:00
|
|
|
|
2023-07-27 14:54:01 +00:00
|
|
|
|
feat(nodes): move all invocation metadata (type, title, tags, category) to decorator
All invocation metadata (type, title, tags and category) are now defined in decorators.
The decorators add the `type: Literal["invocation_type"]: "invocation_type"` field to the invocation.
Category is a new invocation metadata, but it is not used by the frontend just yet.
- `@invocation()` decorator for invocations
```py
@invocation(
"sdxl_compel_prompt",
title="SDXL Prompt",
tags=["sdxl", "compel", "prompt"],
category="conditioning",
)
class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
...
```
- `@invocation_output()` decorator for invocation outputs
```py
@invocation_output("clip_skip_output")
class ClipSkipInvocationOutput(BaseInvocationOutput):
...
```
- update invocation docs
- add category to decorator
- regen frontend types
2023-08-30 08:35:12 +00:00
|
|
|
@invocation_output("sdxl_refiner_model_loader_output")
|
2023-07-16 16:36:38 +00:00
|
|
|
class SDXLRefinerModelLoaderOutput(BaseInvocationOutput):
|
2023-07-16 16:17:56 +00:00
|
|
|
"""SDXL refiner model loader output"""
|
2023-07-27 14:54:01 +00:00
|
|
|
|
2023-08-14 03:23:09 +00:00
|
|
|
unet: UNetField = OutputField(description=FieldDescriptions.unet, title="UNet")
|
2024-03-06 08:42:47 +00:00
|
|
|
clip2: CLIPField = OutputField(description=FieldDescriptions.clip, title="CLIP 2")
|
|
|
|
vae: VAEField = OutputField(description=FieldDescriptions.vae, title="VAE")
|
2023-07-27 14:54:01 +00:00
|
|
|
|
2023-08-14 03:23:09 +00:00
|
|
|
|
2024-01-13 12:23:16 +00:00
|
|
|
@invocation("sdxl_model_loader", title="SDXL Main Model", tags=["model", "sdxl"], category="model", version="1.0.1")
|
2023-07-16 16:17:56 +00:00
|
|
|
class SDXLModelLoaderInvocation(BaseInvocation):
|
|
|
|
"""Loads an sdxl base model, outputting its submodels."""
|
|
|
|
|
2024-03-06 08:37:15 +00:00
|
|
|
model: ModelField = InputField(
|
2023-08-15 11:45:40 +00:00
|
|
|
description=FieldDescriptions.sdxl_main_model, input=Input.Direct, ui_type=UIType.SDXLMainModel
|
2023-08-14 03:23:09 +00:00
|
|
|
)
|
2023-07-16 16:17:56 +00:00
|
|
|
# TODO: precision?
|
|
|
|
|
2024-02-05 06:16:35 +00:00
|
|
|
def invoke(self, context: InvocationContext) -> SDXLModelLoaderOutput:
|
2024-02-06 03:56:32 +00:00
|
|
|
model_key = self.model.key
|
2023-07-16 16:17:56 +00:00
|
|
|
|
|
|
|
# TODO: not found exceptions
|
2024-02-15 09:43:41 +00:00
|
|
|
if not context.models.exists(model_key):
|
2024-02-06 03:56:32 +00:00
|
|
|
raise Exception(f"Unknown model: {model_key}")
|
2023-07-16 16:17:56 +00:00
|
|
|
|
2024-03-06 08:37:15 +00:00
|
|
|
unet = self.model.model_copy(update={"submodel_type": SubModelType.UNet})
|
|
|
|
scheduler = self.model.model_copy(update={"submodel_type": SubModelType.Scheduler})
|
|
|
|
tokenizer = self.model.model_copy(update={"submodel_type": SubModelType.Tokenizer})
|
|
|
|
text_encoder = self.model.model_copy(update={"submodel_type": SubModelType.TextEncoder})
|
|
|
|
tokenizer2 = self.model.model_copy(update={"submodel_type": SubModelType.Tokenizer2})
|
|
|
|
text_encoder2 = self.model.model_copy(update={"submodel_type": SubModelType.TextEncoder2})
|
|
|
|
vae = self.model.model_copy(update={"submodel_type": SubModelType.VAE})
|
|
|
|
|
2023-07-16 16:36:38 +00:00
|
|
|
return SDXLModelLoaderOutput(
|
2024-03-06 08:37:15 +00:00
|
|
|
unet=UNetField(unet=unet, scheduler=scheduler, loras=[]),
|
2024-03-06 08:42:47 +00:00
|
|
|
clip=CLIPField(tokenizer=tokenizer, text_encoder=text_encoder, loras=[], skipped_layers=0),
|
|
|
|
clip2=CLIPField(tokenizer=tokenizer2, text_encoder=text_encoder2, loras=[], skipped_layers=0),
|
|
|
|
vae=VAEField(vae=vae),
|
2023-07-16 16:17:56 +00:00
|
|
|
)
|
|
|
|
|
2023-07-27 14:54:01 +00:00
|
|
|
|
feat(nodes): move all invocation metadata (type, title, tags, category) to decorator
All invocation metadata (type, title, tags and category) are now defined in decorators.
The decorators add the `type: Literal["invocation_type"]: "invocation_type"` field to the invocation.
Category is a new invocation metadata, but it is not used by the frontend just yet.
- `@invocation()` decorator for invocations
```py
@invocation(
"sdxl_compel_prompt",
title="SDXL Prompt",
tags=["sdxl", "compel", "prompt"],
category="conditioning",
)
class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
...
```
- `@invocation_output()` decorator for invocation outputs
```py
@invocation_output("clip_skip_output")
class ClipSkipInvocationOutput(BaseInvocationOutput):
...
```
- update invocation docs
- add category to decorator
- regen frontend types
2023-08-30 08:35:12 +00:00
|
|
|
@invocation(
|
|
|
|
"sdxl_refiner_model_loader",
|
|
|
|
title="SDXL Refiner Model",
|
|
|
|
tags=["model", "sdxl", "refiner"],
|
|
|
|
category="model",
|
2024-01-13 12:23:16 +00:00
|
|
|
version="1.0.1",
|
feat(nodes): move all invocation metadata (type, title, tags, category) to decorator
All invocation metadata (type, title, tags and category) are now defined in decorators.
The decorators add the `type: Literal["invocation_type"]: "invocation_type"` field to the invocation.
Category is a new invocation metadata, but it is not used by the frontend just yet.
- `@invocation()` decorator for invocations
```py
@invocation(
"sdxl_compel_prompt",
title="SDXL Prompt",
tags=["sdxl", "compel", "prompt"],
category="conditioning",
)
class SDXLCompelPromptInvocation(BaseInvocation, SDXLPromptInvocationBase):
...
```
- `@invocation_output()` decorator for invocation outputs
```py
@invocation_output("clip_skip_output")
class ClipSkipInvocationOutput(BaseInvocationOutput):
...
```
- update invocation docs
- add category to decorator
- regen frontend types
2023-08-30 08:35:12 +00:00
|
|
|
)
|
2023-07-16 16:36:38 +00:00
|
|
|
class SDXLRefinerModelLoaderInvocation(BaseInvocation):
|
2023-07-16 16:17:56 +00:00
|
|
|
"""Loads an sdxl refiner model, outputting its submodels."""
|
2023-07-27 14:54:01 +00:00
|
|
|
|
2024-03-06 08:37:15 +00:00
|
|
|
model: ModelField = InputField(
|
|
|
|
description=FieldDescriptions.sdxl_refiner_model, input=Input.Direct, ui_type=UIType.SDXLRefinerModel
|
2023-08-14 03:23:09 +00:00
|
|
|
)
|
2023-07-16 16:38:04 +00:00
|
|
|
# TODO: precision?
|
|
|
|
|
2024-02-05 06:16:35 +00:00
|
|
|
def invoke(self, context: InvocationContext) -> SDXLRefinerModelLoaderOutput:
|
2024-02-06 03:56:32 +00:00
|
|
|
model_key = self.model.key
|
2023-07-16 16:17:56 +00:00
|
|
|
|
2023-07-16 16:36:38 +00:00
|
|
|
# TODO: not found exceptions
|
2024-02-15 09:43:41 +00:00
|
|
|
if not context.models.exists(model_key):
|
2024-02-06 03:56:32 +00:00
|
|
|
raise Exception(f"Unknown model: {model_key}")
|
2023-07-16 16:36:38 +00:00
|
|
|
|
2024-03-06 08:37:15 +00:00
|
|
|
unet = self.model.model_copy(update={"submodel_type": SubModelType.UNet})
|
|
|
|
scheduler = self.model.model_copy(update={"submodel_type": SubModelType.Scheduler})
|
|
|
|
tokenizer2 = self.model.model_copy(update={"submodel_type": SubModelType.Tokenizer2})
|
|
|
|
text_encoder2 = self.model.model_copy(update={"submodel_type": SubModelType.TextEncoder2})
|
|
|
|
vae = self.model.model_copy(update={"submodel_type": SubModelType.VAE})
|
|
|
|
|
2023-07-16 16:36:38 +00:00
|
|
|
return SDXLRefinerModelLoaderOutput(
|
2024-03-06 08:37:15 +00:00
|
|
|
unet=UNetField(unet=unet, scheduler=scheduler, loras=[]),
|
2024-03-06 08:42:47 +00:00
|
|
|
clip2=CLIPField(tokenizer=tokenizer2, text_encoder=text_encoder2, loras=[], skipped_layers=0),
|
|
|
|
vae=VAEField(vae=vae),
|
2023-07-16 16:36:38 +00:00
|
|
|
)
|