From d9b1e4a98c6f6c8e93dfdfff36ca8fb18a92c613 Mon Sep 17 00:00:00 2001 From: user1 Date: Fri, 26 May 2023 11:06:37 -0700 Subject: [PATCH] Added nodes for float params: ParamFloatInvocation and FloatCollectionOutput. Also added FloatOutput. --- invokeai/app/invocations/collections.py | 8 ++++++++ invokeai/app/invocations/math.py | 9 +++++++++ invokeai/app/invocations/params.py | 12 +++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/invokeai/app/invocations/collections.py b/invokeai/app/invocations/collections.py index 475b6028a9..891f217317 100644 --- a/invokeai/app/invocations/collections.py +++ b/invokeai/app/invocations/collections.py @@ -22,6 +22,14 @@ class IntCollectionOutput(BaseInvocationOutput): # Outputs collection: list[int] = Field(default=[], description="The int collection") +class FloatCollectionOutput(BaseInvocationOutput): + """A collection of floats""" + + type: Literal["float_collection"] = "float_collection" + + # Outputs + collection: list[float] = Field(default=[], description="The float collection") + class RangeInvocation(BaseInvocation): """Creates a range of numbers from start to stop with step""" diff --git a/invokeai/app/invocations/math.py b/invokeai/app/invocations/math.py index 2ce58c016b..113b630200 100644 --- a/invokeai/app/invocations/math.py +++ b/invokeai/app/invocations/math.py @@ -34,6 +34,15 @@ class IntOutput(BaseInvocationOutput): # fmt: on +class FloatOutput(BaseInvocationOutput): + """A float output""" + + # fmt: off + type: Literal["float_output"] = "float_output" + param: float = Field(default=None, description="The output float") + # fmt: on + + class AddInvocation(BaseInvocation, MathInvocationConfig): """Adds two numbers""" diff --git a/invokeai/app/invocations/params.py b/invokeai/app/invocations/params.py index fcc7f1737a..1c6297665b 100644 --- a/invokeai/app/invocations/params.py +++ b/invokeai/app/invocations/params.py @@ -3,7 +3,7 @@ from typing import Literal from pydantic import Field from .baseinvocation import BaseInvocation, BaseInvocationOutput, InvocationContext -from .math import IntOutput +from .math import IntOutput, FloatOutput # Pass-through parameter nodes - used by subgraphs @@ -16,3 +16,13 @@ class ParamIntInvocation(BaseInvocation): def invoke(self, context: InvocationContext) -> IntOutput: return IntOutput(a=self.a) + +class ParamFloatInvocation(BaseInvocation): + """A float parameter""" + #fmt: off + type: Literal["param_float"] = "param_float" + param: float = Field(default=0.0, description="The float value") + #fmt: on + + def invoke(self, context: InvocationContext) -> FloatOutput: + return FloatOutput(param=self.param)