2023-08-14 09:41:29 +00:00
|
|
|
# Copyright (c) 2023 Kyle Schouviller (https://github.com/kyle0654)
|
|
|
|
|
2023-08-17 22:45:25 +00:00
|
|
|
from typing import Literal, Optional, Tuple
|
2023-08-14 09:41:29 +00:00
|
|
|
|
|
|
|
import torch
|
2023-08-17 16:54:23 +00:00
|
|
|
from pydantic import BaseModel, Field
|
2023-08-14 09:41:29 +00:00
|
|
|
|
|
|
|
from .baseinvocation import (
|
|
|
|
BaseInvocation,
|
|
|
|
BaseInvocationOutput,
|
|
|
|
FieldDescriptions,
|
|
|
|
Input,
|
|
|
|
InputField,
|
|
|
|
InvocationContext,
|
|
|
|
OutputField,
|
|
|
|
UIComponent,
|
2023-08-15 11:45:40 +00:00
|
|
|
UIType,
|
2023-08-14 09:41:29 +00:00
|
|
|
tags,
|
|
|
|
title,
|
|
|
|
)
|
|
|
|
|
|
|
|
"""
|
|
|
|
Primitives: Boolean, Integer, Float, String, Image, Latents, Conditioning, Color
|
|
|
|
- primitive nodes
|
|
|
|
- primitive outputs
|
|
|
|
- primitive collection outputs
|
|
|
|
"""
|
|
|
|
|
|
|
|
# region Boolean
|
|
|
|
|
|
|
|
|
|
|
|
class BooleanOutput(BaseInvocationOutput):
|
|
|
|
"""Base class for nodes that output a single boolean"""
|
|
|
|
|
|
|
|
type: Literal["boolean_output"] = "boolean_output"
|
2023-08-18 10:17:21 +00:00
|
|
|
value: bool = OutputField(description="The output boolean")
|
2023-08-14 09:41:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
class BooleanCollectionOutput(BaseInvocationOutput):
|
|
|
|
"""Base class for nodes that output a collection of booleans"""
|
|
|
|
|
|
|
|
type: Literal["boolean_collection_output"] = "boolean_collection_output"
|
|
|
|
|
|
|
|
# Outputs
|
2023-08-20 10:22:23 +00:00
|
|
|
collection: list[bool] = OutputField(description="The output boolean collection", ui_type=UIType.BooleanCollection)
|
2023-08-14 09:41:29 +00:00
|
|
|
|
|
|
|
|
2023-08-16 07:18:58 +00:00
|
|
|
@title("Boolean Primitive")
|
2023-08-15 12:18:37 +00:00
|
|
|
@tags("primitives", "boolean")
|
2023-08-14 09:41:29 +00:00
|
|
|
class BooleanInvocation(BaseInvocation):
|
|
|
|
"""A boolean primitive value"""
|
|
|
|
|
|
|
|
type: Literal["boolean"] = "boolean"
|
|
|
|
|
|
|
|
# Inputs
|
2023-08-18 10:17:21 +00:00
|
|
|
value: bool = InputField(default=False, description="The boolean value")
|
2023-08-14 09:41:29 +00:00
|
|
|
|
|
|
|
def invoke(self, context: InvocationContext) -> BooleanOutput:
|
2023-08-18 10:17:21 +00:00
|
|
|
return BooleanOutput(value=self.value)
|
2023-08-14 09:41:29 +00:00
|
|
|
|
|
|
|
|
2023-08-16 07:18:58 +00:00
|
|
|
@title("Boolean Primitive Collection")
|
2023-08-15 12:18:37 +00:00
|
|
|
@tags("primitives", "boolean", "collection")
|
|
|
|
class BooleanCollectionInvocation(BaseInvocation):
|
|
|
|
"""A collection of boolean primitive values"""
|
|
|
|
|
|
|
|
type: Literal["boolean_collection"] = "boolean_collection"
|
|
|
|
|
|
|
|
# Inputs
|
|
|
|
collection: list[bool] = InputField(
|
2023-08-20 10:22:23 +00:00
|
|
|
default_factory=list, description="The collection of boolean values", ui_type=UIType.BooleanCollection
|
2023-08-15 12:18:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def invoke(self, context: InvocationContext) -> BooleanCollectionOutput:
|
|
|
|
return BooleanCollectionOutput(collection=self.collection)
|
|
|
|
|
|
|
|
|
2023-08-14 09:41:29 +00:00
|
|
|
# endregion
|
|
|
|
|
|
|
|
# region Integer
|
|
|
|
|
|
|
|
|
|
|
|
class IntegerOutput(BaseInvocationOutput):
|
|
|
|
"""Base class for nodes that output a single integer"""
|
|
|
|
|
|
|
|
type: Literal["integer_output"] = "integer_output"
|
2023-08-18 10:17:21 +00:00
|
|
|
value: int = OutputField(description="The output integer")
|
2023-08-14 09:41:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
class IntegerCollectionOutput(BaseInvocationOutput):
|
|
|
|
"""Base class for nodes that output a collection of integers"""
|
|
|
|
|
|
|
|
type: Literal["integer_collection_output"] = "integer_collection_output"
|
|
|
|
|
|
|
|
# Outputs
|
2023-08-20 10:22:23 +00:00
|
|
|
collection: list[int] = OutputField(description="The int collection", ui_type=UIType.IntegerCollection)
|
2023-08-14 09:41:29 +00:00
|
|
|
|
|
|
|
|
2023-08-16 07:18:58 +00:00
|
|
|
@title("Integer Primitive")
|
2023-08-15 12:18:37 +00:00
|
|
|
@tags("primitives", "integer")
|
2023-08-14 09:41:29 +00:00
|
|
|
class IntegerInvocation(BaseInvocation):
|
|
|
|
"""An integer primitive value"""
|
|
|
|
|
|
|
|
type: Literal["integer"] = "integer"
|
|
|
|
|
|
|
|
# Inputs
|
2023-08-18 10:17:21 +00:00
|
|
|
value: int = InputField(default=0, description="The integer value")
|
2023-08-14 09:41:29 +00:00
|
|
|
|
|
|
|
def invoke(self, context: InvocationContext) -> IntegerOutput:
|
2023-08-18 10:17:21 +00:00
|
|
|
return IntegerOutput(value=self.value)
|
2023-08-14 09:41:29 +00:00
|
|
|
|
|
|
|
|
2023-08-16 07:18:58 +00:00
|
|
|
@title("Integer Primitive Collection")
|
2023-08-15 12:18:37 +00:00
|
|
|
@tags("primitives", "integer", "collection")
|
|
|
|
class IntegerCollectionInvocation(BaseInvocation):
|
|
|
|
"""A collection of integer primitive values"""
|
|
|
|
|
|
|
|
type: Literal["integer_collection"] = "integer_collection"
|
|
|
|
|
|
|
|
# Inputs
|
|
|
|
collection: list[int] = InputField(
|
|
|
|
default=0, description="The collection of integer values", ui_type=UIType.IntegerCollection
|
|
|
|
)
|
|
|
|
|
|
|
|
def invoke(self, context: InvocationContext) -> IntegerCollectionOutput:
|
|
|
|
return IntegerCollectionOutput(collection=self.collection)
|
|
|
|
|
|
|
|
|
2023-08-14 09:41:29 +00:00
|
|
|
# endregion
|
|
|
|
|
|
|
|
# region Float
|
|
|
|
|
|
|
|
|
|
|
|
class FloatOutput(BaseInvocationOutput):
|
|
|
|
"""Base class for nodes that output a single float"""
|
|
|
|
|
|
|
|
type: Literal["float_output"] = "float_output"
|
2023-08-18 10:17:21 +00:00
|
|
|
value: float = OutputField(description="The output float")
|
2023-08-14 09:41:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
class FloatCollectionOutput(BaseInvocationOutput):
|
|
|
|
"""Base class for nodes that output a collection of floats"""
|
|
|
|
|
|
|
|
type: Literal["float_collection_output"] = "float_collection_output"
|
|
|
|
|
|
|
|
# Outputs
|
2023-08-20 10:22:23 +00:00
|
|
|
collection: list[float] = OutputField(description="The float collection", ui_type=UIType.FloatCollection)
|
2023-08-14 09:41:29 +00:00
|
|
|
|
|
|
|
|
2023-08-16 07:18:58 +00:00
|
|
|
@title("Float Primitive")
|
2023-08-15 12:18:37 +00:00
|
|
|
@tags("primitives", "float")
|
2023-08-14 09:41:29 +00:00
|
|
|
class FloatInvocation(BaseInvocation):
|
|
|
|
"""A float primitive value"""
|
|
|
|
|
|
|
|
type: Literal["float"] = "float"
|
|
|
|
|
|
|
|
# Inputs
|
2023-08-18 10:17:21 +00:00
|
|
|
value: float = InputField(default=0.0, description="The float value")
|
2023-08-14 09:41:29 +00:00
|
|
|
|
|
|
|
def invoke(self, context: InvocationContext) -> FloatOutput:
|
2023-08-18 10:17:21 +00:00
|
|
|
return FloatOutput(value=self.value)
|
2023-08-14 09:41:29 +00:00
|
|
|
|
|
|
|
|
2023-08-16 07:18:58 +00:00
|
|
|
@title("Float Primitive Collection")
|
2023-08-15 12:18:37 +00:00
|
|
|
@tags("primitives", "float", "collection")
|
|
|
|
class FloatCollectionInvocation(BaseInvocation):
|
|
|
|
"""A collection of float primitive values"""
|
|
|
|
|
|
|
|
type: Literal["float_collection"] = "float_collection"
|
|
|
|
|
|
|
|
# Inputs
|
|
|
|
collection: list[float] = InputField(
|
2023-08-20 10:22:23 +00:00
|
|
|
default_factory=list, description="The collection of float values", ui_type=UIType.FloatCollection
|
2023-08-15 12:18:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def invoke(self, context: InvocationContext) -> FloatCollectionOutput:
|
|
|
|
return FloatCollectionOutput(collection=self.collection)
|
|
|
|
|
|
|
|
|
2023-08-14 09:41:29 +00:00
|
|
|
# endregion
|
|
|
|
|
|
|
|
# region String
|
|
|
|
|
|
|
|
|
|
|
|
class StringOutput(BaseInvocationOutput):
|
|
|
|
"""Base class for nodes that output a single string"""
|
|
|
|
|
|
|
|
type: Literal["string_output"] = "string_output"
|
2023-08-18 10:17:21 +00:00
|
|
|
value: str = OutputField(description="The output string")
|
2023-08-14 09:41:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
class StringCollectionOutput(BaseInvocationOutput):
|
|
|
|
"""Base class for nodes that output a collection of strings"""
|
|
|
|
|
|
|
|
type: Literal["string_collection_output"] = "string_collection_output"
|
|
|
|
|
|
|
|
# Outputs
|
2023-08-20 10:22:23 +00:00
|
|
|
collection: list[str] = OutputField(description="The output strings", ui_type=UIType.StringCollection)
|
2023-08-14 09:41:29 +00:00
|
|
|
|
|
|
|
|
2023-08-16 07:18:58 +00:00
|
|
|
@title("String Primitive")
|
2023-08-15 12:18:37 +00:00
|
|
|
@tags("primitives", "string")
|
2023-08-14 09:41:29 +00:00
|
|
|
class StringInvocation(BaseInvocation):
|
|
|
|
"""A string primitive value"""
|
|
|
|
|
|
|
|
type: Literal["string"] = "string"
|
|
|
|
|
|
|
|
# Inputs
|
2023-08-18 10:17:21 +00:00
|
|
|
value: str = InputField(default="", description="The string value", ui_component=UIComponent.Textarea)
|
2023-08-14 09:41:29 +00:00
|
|
|
|
|
|
|
def invoke(self, context: InvocationContext) -> StringOutput:
|
2023-08-18 10:17:21 +00:00
|
|
|
return StringOutput(value=self.value)
|
2023-08-14 09:41:29 +00:00
|
|
|
|
|
|
|
|
2023-08-16 07:18:58 +00:00
|
|
|
@title("String Primitive Collection")
|
2023-08-15 12:18:37 +00:00
|
|
|
@tags("primitives", "string", "collection")
|
|
|
|
class StringCollectionInvocation(BaseInvocation):
|
|
|
|
"""A collection of string primitive values"""
|
|
|
|
|
|
|
|
type: Literal["string_collection"] = "string_collection"
|
|
|
|
|
|
|
|
# Inputs
|
|
|
|
collection: list[str] = InputField(
|
2023-08-20 10:22:23 +00:00
|
|
|
default_factory=list, description="The collection of string values", ui_type=UIType.StringCollection
|
2023-08-15 12:18:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def invoke(self, context: InvocationContext) -> StringCollectionOutput:
|
|
|
|
return StringCollectionOutput(collection=self.collection)
|
|
|
|
|
|
|
|
|
2023-08-14 09:41:29 +00:00
|
|
|
# endregion
|
|
|
|
|
|
|
|
# region Image
|
|
|
|
|
|
|
|
|
|
|
|
class ImageField(BaseModel):
|
|
|
|
"""An image primitive field"""
|
|
|
|
|
|
|
|
image_name: str = Field(description="The name of the image")
|
|
|
|
|
|
|
|
|
|
|
|
class ImageOutput(BaseInvocationOutput):
|
|
|
|
"""Base class for nodes that output a single image"""
|
|
|
|
|
|
|
|
type: Literal["image_output"] = "image_output"
|
|
|
|
image: ImageField = OutputField(description="The output image")
|
|
|
|
width: int = OutputField(description="The width of the image in pixels")
|
|
|
|
height: int = OutputField(description="The height of the image in pixels")
|
|
|
|
|
|
|
|
|
|
|
|
class ImageCollectionOutput(BaseInvocationOutput):
|
|
|
|
"""Base class for nodes that output a collection of images"""
|
|
|
|
|
|
|
|
type: Literal["image_collection_output"] = "image_collection_output"
|
|
|
|
|
|
|
|
# Outputs
|
2023-08-20 10:22:23 +00:00
|
|
|
collection: list[ImageField] = OutputField(description="The output images", ui_type=UIType.ImageCollection)
|
2023-08-14 09:41:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
@title("Image Primitive")
|
2023-08-15 12:18:37 +00:00
|
|
|
@tags("primitives", "image")
|
2023-08-14 09:41:29 +00:00
|
|
|
class ImageInvocation(BaseInvocation):
|
|
|
|
"""An image primitive value"""
|
|
|
|
|
|
|
|
# Metadata
|
|
|
|
type: Literal["image"] = "image"
|
|
|
|
|
|
|
|
# Inputs
|
|
|
|
image: ImageField = InputField(description="The image to load")
|
|
|
|
|
|
|
|
def invoke(self, context: InvocationContext) -> ImageOutput:
|
|
|
|
image = context.services.images.get_pil_image(self.image.image_name)
|
|
|
|
|
|
|
|
return ImageOutput(
|
|
|
|
image=ImageField(image_name=self.image.image_name),
|
|
|
|
width=image.width,
|
|
|
|
height=image.height,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2023-08-16 07:18:58 +00:00
|
|
|
@title("Image Primitive Collection")
|
2023-08-15 12:18:37 +00:00
|
|
|
@tags("primitives", "image", "collection")
|
|
|
|
class ImageCollectionInvocation(BaseInvocation):
|
|
|
|
"""A collection of image primitive values"""
|
|
|
|
|
|
|
|
type: Literal["image_collection"] = "image_collection"
|
|
|
|
|
|
|
|
# Inputs
|
|
|
|
collection: list[ImageField] = InputField(
|
|
|
|
default=0, description="The collection of image values", ui_type=UIType.ImageCollection
|
|
|
|
)
|
|
|
|
|
|
|
|
def invoke(self, context: InvocationContext) -> ImageCollectionOutput:
|
|
|
|
return ImageCollectionOutput(collection=self.collection)
|
|
|
|
|
|
|
|
|
2023-08-17 16:19:07 +00:00
|
|
|
# endregion
|
|
|
|
|
2023-08-26 17:50:13 +00:00
|
|
|
# region DenoiseMask
|
2023-08-17 16:19:07 +00:00
|
|
|
|
|
|
|
|
2023-08-26 17:50:13 +00:00
|
|
|
class DenoiseMaskField(BaseModel):
|
2023-08-17 16:54:23 +00:00
|
|
|
"""An inpaint mask field"""
|
2023-08-17 16:19:07 +00:00
|
|
|
|
|
|
|
mask_name: str = Field(description="The name of the mask image")
|
2023-08-18 01:07:40 +00:00
|
|
|
masked_latents_name: Optional[str] = Field(description="The name of the masked image latents")
|
|
|
|
|
|
|
|
|
2023-08-26 17:50:13 +00:00
|
|
|
class DenoiseMaskOutput(BaseInvocationOutput):
|
2023-08-18 01:07:40 +00:00
|
|
|
"""Base class for nodes that output a single image"""
|
|
|
|
|
2023-08-26 17:50:13 +00:00
|
|
|
type: Literal["denoise_mask_output"] = "denoise_mask_output"
|
|
|
|
denoise_mask: DenoiseMaskField = OutputField(description="Mask for denoise model run")
|
2023-08-17 16:19:07 +00:00
|
|
|
|
|
|
|
|
2023-08-14 09:41:29 +00:00
|
|
|
# endregion
|
|
|
|
|
|
|
|
# region Latents
|
|
|
|
|
|
|
|
|
|
|
|
class LatentsField(BaseModel):
|
|
|
|
"""A latents tensor primitive field"""
|
|
|
|
|
|
|
|
latents_name: str = Field(description="The name of the latents")
|
|
|
|
seed: Optional[int] = Field(default=None, description="Seed used to generate this latents")
|
|
|
|
|
|
|
|
|
|
|
|
class LatentsOutput(BaseInvocationOutput):
|
|
|
|
"""Base class for nodes that output a single latents tensor"""
|
|
|
|
|
|
|
|
type: Literal["latents_output"] = "latents_output"
|
|
|
|
|
|
|
|
latents: LatentsField = OutputField(
|
|
|
|
description=FieldDescriptions.latents,
|
|
|
|
)
|
|
|
|
width: int = OutputField(description=FieldDescriptions.width)
|
|
|
|
height: int = OutputField(description=FieldDescriptions.height)
|
|
|
|
|
|
|
|
|
|
|
|
class LatentsCollectionOutput(BaseInvocationOutput):
|
|
|
|
"""Base class for nodes that output a collection of latents tensors"""
|
|
|
|
|
|
|
|
type: Literal["latents_collection_output"] = "latents_collection_output"
|
|
|
|
|
2023-08-15 12:18:37 +00:00
|
|
|
collection: list[LatentsField] = OutputField(
|
2023-08-14 09:41:29 +00:00
|
|
|
description=FieldDescriptions.latents,
|
2023-08-15 11:45:40 +00:00
|
|
|
ui_type=UIType.LatentsCollection,
|
2023-08-14 09:41:29 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@title("Latents Primitive")
|
2023-08-15 12:18:37 +00:00
|
|
|
@tags("primitives", "latents")
|
2023-08-14 09:41:29 +00:00
|
|
|
class LatentsInvocation(BaseInvocation):
|
|
|
|
"""A latents tensor primitive value"""
|
|
|
|
|
|
|
|
type: Literal["latents"] = "latents"
|
|
|
|
|
|
|
|
# Inputs
|
|
|
|
latents: LatentsField = InputField(description="The latents tensor", input=Input.Connection)
|
|
|
|
|
|
|
|
def invoke(self, context: InvocationContext) -> LatentsOutput:
|
|
|
|
latents = context.services.latents.get(self.latents.latents_name)
|
|
|
|
|
|
|
|
return build_latents_output(self.latents.latents_name, latents)
|
|
|
|
|
|
|
|
|
2023-08-16 07:18:58 +00:00
|
|
|
@title("Latents Primitive Collection")
|
2023-08-15 12:18:37 +00:00
|
|
|
@tags("primitives", "latents", "collection")
|
|
|
|
class LatentsCollectionInvocation(BaseInvocation):
|
|
|
|
"""A collection of latents tensor primitive values"""
|
|
|
|
|
|
|
|
type: Literal["latents_collection"] = "latents_collection"
|
|
|
|
|
|
|
|
# Inputs
|
|
|
|
collection: list[LatentsField] = InputField(
|
2023-08-20 10:22:23 +00:00
|
|
|
description="The collection of latents tensors", ui_type=UIType.LatentsCollection
|
2023-08-15 12:18:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
def invoke(self, context: InvocationContext) -> LatentsCollectionOutput:
|
|
|
|
return LatentsCollectionOutput(collection=self.collection)
|
|
|
|
|
|
|
|
|
2023-08-14 09:41:29 +00:00
|
|
|
def build_latents_output(latents_name: str, latents: torch.Tensor, seed: Optional[int] = None):
|
|
|
|
return LatentsOutput(
|
|
|
|
latents=LatentsField(latents_name=latents_name, seed=seed),
|
|
|
|
width=latents.size()[3] * 8,
|
|
|
|
height=latents.size()[2] * 8,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# endregion
|
|
|
|
|
|
|
|
# region Color
|
|
|
|
|
|
|
|
|
|
|
|
class ColorField(BaseModel):
|
|
|
|
"""A color primitive field"""
|
|
|
|
|
|
|
|
r: int = Field(ge=0, le=255, description="The red component")
|
|
|
|
g: int = Field(ge=0, le=255, description="The green component")
|
|
|
|
b: int = Field(ge=0, le=255, description="The blue component")
|
|
|
|
a: int = Field(ge=0, le=255, description="The alpha component")
|
|
|
|
|
|
|
|
def tuple(self) -> Tuple[int, int, int, int]:
|
|
|
|
return (self.r, self.g, self.b, self.a)
|
|
|
|
|
|
|
|
|
|
|
|
class ColorOutput(BaseInvocationOutput):
|
|
|
|
"""Base class for nodes that output a single color"""
|
|
|
|
|
|
|
|
type: Literal["color_output"] = "color_output"
|
|
|
|
color: ColorField = OutputField(description="The output color")
|
|
|
|
|
|
|
|
|
|
|
|
class ColorCollectionOutput(BaseInvocationOutput):
|
|
|
|
"""Base class for nodes that output a collection of colors"""
|
|
|
|
|
|
|
|
type: Literal["color_collection_output"] = "color_collection_output"
|
|
|
|
|
|
|
|
# Outputs
|
2023-08-20 10:22:23 +00:00
|
|
|
collection: list[ColorField] = OutputField(description="The output colors", ui_type=UIType.ColorCollection)
|
2023-08-14 09:41:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
@title("Color Primitive")
|
2023-08-15 12:18:37 +00:00
|
|
|
@tags("primitives", "color")
|
2023-08-14 09:41:29 +00:00
|
|
|
class ColorInvocation(BaseInvocation):
|
|
|
|
"""A color primitive value"""
|
|
|
|
|
|
|
|
type: Literal["color"] = "color"
|
|
|
|
|
|
|
|
# Inputs
|
|
|
|
color: ColorField = InputField(default=ColorField(r=0, g=0, b=0, a=255), description="The color value")
|
|
|
|
|
|
|
|
def invoke(self, context: InvocationContext) -> ColorOutput:
|
|
|
|
return ColorOutput(color=self.color)
|
|
|
|
|
|
|
|
|
|
|
|
# endregion
|
|
|
|
|
|
|
|
# region Conditioning
|
|
|
|
|
|
|
|
|
|
|
|
class ConditioningField(BaseModel):
|
2023-08-15 12:18:37 +00:00
|
|
|
"""A conditioning tensor primitive value"""
|
2023-08-14 09:41:29 +00:00
|
|
|
|
|
|
|
conditioning_name: str = Field(description="The name of conditioning tensor")
|
|
|
|
|
|
|
|
|
|
|
|
class ConditioningOutput(BaseInvocationOutput):
|
|
|
|
"""Base class for nodes that output a single conditioning tensor"""
|
|
|
|
|
|
|
|
type: Literal["conditioning_output"] = "conditioning_output"
|
|
|
|
|
|
|
|
conditioning: ConditioningField = OutputField(description=FieldDescriptions.cond)
|
|
|
|
|
|
|
|
|
|
|
|
class ConditioningCollectionOutput(BaseInvocationOutput):
|
|
|
|
"""Base class for nodes that output a collection of conditioning tensors"""
|
|
|
|
|
|
|
|
type: Literal["conditioning_collection_output"] = "conditioning_collection_output"
|
|
|
|
|
|
|
|
# Outputs
|
|
|
|
collection: list[ConditioningField] = OutputField(
|
|
|
|
description="The output conditioning tensors",
|
2023-08-15 11:45:40 +00:00
|
|
|
ui_type=UIType.ConditioningCollection,
|
2023-08-14 09:41:29 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@title("Conditioning Primitive")
|
2023-08-15 12:18:37 +00:00
|
|
|
@tags("primitives", "conditioning")
|
2023-08-14 09:41:29 +00:00
|
|
|
class ConditioningInvocation(BaseInvocation):
|
|
|
|
"""A conditioning tensor primitive value"""
|
|
|
|
|
|
|
|
type: Literal["conditioning"] = "conditioning"
|
|
|
|
|
|
|
|
conditioning: ConditioningField = InputField(description=FieldDescriptions.cond, input=Input.Connection)
|
|
|
|
|
|
|
|
def invoke(self, context: InvocationContext) -> ConditioningOutput:
|
|
|
|
return ConditioningOutput(conditioning=self.conditioning)
|
|
|
|
|
|
|
|
|
2023-08-16 07:18:58 +00:00
|
|
|
@title("Conditioning Primitive Collection")
|
2023-08-15 12:18:37 +00:00
|
|
|
@tags("primitives", "conditioning", "collection")
|
|
|
|
class ConditioningCollectionInvocation(BaseInvocation):
|
|
|
|
"""A collection of conditioning tensor primitive values"""
|
|
|
|
|
|
|
|
type: Literal["conditioning_collection"] = "conditioning_collection"
|
|
|
|
|
|
|
|
# Inputs
|
|
|
|
collection: list[ConditioningField] = InputField(
|
|
|
|
default=0, description="The collection of conditioning tensors", ui_type=UIType.ConditioningCollection
|
|
|
|
)
|
|
|
|
|
|
|
|
def invoke(self, context: InvocationContext) -> ConditioningCollectionOutput:
|
|
|
|
return ConditioningCollectionOutput(collection=self.collection)
|
|
|
|
|
|
|
|
|
2023-08-14 09:41:29 +00:00
|
|
|
# endregion
|