Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

Add OKLab and Oklch image utilities and nodes, refactor color space nodes (#8999)

Jonathanf99858b89fb1
diff --git a/invokeai/app/invocations/composition-nodes.py b/invokeai/app/invocations/composition-nodes.py
index 55842ec34f..babbf29151 100644
--- a/invokeai/app/invocations/composition-nodes.py
+++ b/invokeai/app/invocations/composition-nodes.py
@@ -14,22 +14,27 @@ from PIL import Image, ImageChops, ImageCms, ImageColor, ImageDraw, ImageEnhance
from torchvision.transforms.functional import to_pil_image as pil_image_from_tensor
from invokeai.app.invocations.primitives import ImageOutput
-from invokeai.backend.image_util.composition import (
- CIELAB_TO_UPLAB_ICC_PATH,
- MAX_FLOAT,
- equivalent_achromatic_lightness,
- gamut_clip_tensor,
+from invokeai.backend.image_util.color_conversion import (
hsl_from_srgb,
linear_srgb_from_oklab,
+ linear_srgb_from_oklch,
linear_srgb_from_srgb,
okhsl_from_srgb,
okhsv_from_srgb,
oklab_from_linear_srgb,
- remove_nans,
+ oklab_from_oklch,
+ oklch_from_oklab,
srgb_from_hsl,
- srgb_from_linear_srgb,
srgb_from_okhsl,
srgb_from_okhsv,
+)
+from invokeai.backend.image_util.composition import (
+ CIELAB_TO_UPLAB_ICC_PATH,
+ MAX_FLOAT,
+ equivalent_achromatic_lightness,
+ gamut_clip_tensor,
+ remove_nans,
+ srgb_from_linear_srgb,
tensor_from_pil_image,
)
from invokeai.backend.stable_diffusion.diffusers_pipeline import image_resized_to_grid_as_tensor
@@ -136,20 +141,20 @@ class InvokeAdjustImageHuePlusInvocation(BaseInvocation, WithMetadata, WithBoard
if space == "hsv":
hsv_tensor = image_resized_to_grid_as_tensor(image_in.convert("HSV"), normalize=False, multiple_of=1)
- hsv_tensor[0, :, :] = torch.remainder(torch.add(hsv_tensor[0, :, :], torch.div(self.degrees, 360.0)), 1.0)
+ hsv_tensor[0, :, :] = torch.remainder(torch.add(hsv_tensor[0, :, :] * 360.0, self.degrees), 360.0) / 360.0
image_out = pil_image_from_tensor(hsv_tensor, mode="HSV").convert("RGB")
elif space == "okhsl":
rgb_tensor = image_resized_to_grid_as_tensor(image_in.convert("RGB"), normalize=False, multiple_of=1)
hsl_tensor = okhsl_from_srgb(rgb_tensor, steps=(3 if self.ok_high_precision else 1))
- hsl_tensor[0, :, :] = torch.remainder(torch.add(hsl_tensor[0, :, :], torch.div(self.degrees, 360.0)), 1.0)
+ hsl_tensor[0, :, :] = torch.remainder(torch.add(hsl_tensor[0, :, :], self.degrees), 360.0)
rgb_tensor = srgb_from_okhsl(hsl_tensor, alpha=0.0)
image_out = pil_image_from_tensor(rgb_tensor, mode="RGB")
elif space == "okhsv":
rgb_tensor = image_resized_to_grid_as_tensor(image_in.convert("RGB"), normalize=False, multiple_of=1)
hsv_tensor = okhsv_from_srgb(rgb_tensor, steps=(3 if self.ok_high_precision else 1))
- hsv_tensor[0, :, :] = torch.remainder(torch.add(hsv_tensor[0, :, :], torch.div(self.degrees, 360.0)), 1.0)
+ hsv_tensor[0, :, :] = torch.remainder(torch.add(hsv_tensor[0, :, :], self.degrees), 360.0)
rgb_tensor = srgb_from_okhsv(hsv_tensor, alpha=0.0)
image_out = pil_image_from_tensor(rgb_tensor, mode="RGB")
@@ -197,24 +202,9 @@ class InvokeAdjustImageHuePlusInvocation(BaseInvocation, WithMetadata, WithBoard
rgb_tensor = image_resized_to_grid_as_tensor(image_in.convert("RGB"), normalize=False, multiple_of=1)
linear_srgb_tensor = linear_srgb_from_srgb(rgb_tensor)
-
- lab_tensor = oklab_from_linear_srgb(linear_srgb_tensor)
-
- # L*a*b* to L*C*h
- c_tensor = torch.sqrt(torch.add(torch.pow(lab_tensor[1, :, :], 2.0), torch.pow(lab_tensor[2, :, :], 2.0)))
- h_tensor = torch.atan2(lab_tensor[2, :, :], lab_tensor[1, :, :])
-
- # Rotate h
- rot_rads = (self.degrees / 180.0) * PI
-
- h_rot = torch.add(h_tensor, rot_rads)
- h_rot = torch.remainder(torch.add(h_rot, 2 * PI), 2 * PI)
-
- # L*C*h to L*a*b*
- lab_tensor[1, :, :] = torch.mul(c_tensor, torch.cos(h_rot))
- lab_tensor[2, :, :] = torch.mul(c_tensor, torch.sin(h_rot))
-
- linear_srgb_tensor = linear_srgb_from_oklab(lab_tensor)
+ oklch_tensor = oklch_from_oklab(oklab_from_linear_srgb(linear_srgb_tensor))
+ oklch_tensor[2, :, :] = torch.remainder(torch.add(oklch_tensor[2, :, :], self.degrees), 360.0)
+ linear_srgb_tensor = linear_srgb_from_oklch(oklch_tensor)
rgb_tensor = srgb_from_linear_srgb(
linear_srgb_tensor, alpha=self.ok_adaptive_gamut, steps=(3 if self.ok_high_precision else 1)
@@ -602,14 +592,14 @@ class InvokeImageBlendInvocation(BaseInvocation, WithMetadata, WithBoard):
image_hsv_upper, image_hsv_lower = image_upper.convert("HSV"), image_lower.convert("HSV")
upper_hsv_tensor = torch.stack(
[
- tensor_from_pil_image(image_hsv_upper.getchannel("H"), normalize=False)[0, :, :],
+ tensor_from_pil_image(image_hsv_upper.getchannel("H"), normalize=False)[0, :, :] * 360.0,
tensor_from_pil_image(image_hsv_upper.getchannel("S"), normalize=False)[0, :, :],
tensor_from_pil_image(image_hsv_upper.getchannel("V"), normalize=False)[0, :, :],
]
)
lower_hsv_tensor = torch.stack(
[
- tensor_from_pil_image(image_hsv_lower.getchannel("H"), normalize=False)[0, :, :],
+ tensor_from_pil_image(image_hsv_lower.getchannel("H"), normalize=False)[0, :, :] * 360.0,
tensor_from_pil_image(image_hsv_lower.getchannel("S"), normalize=False)[0, :, :],
tensor_from_pil_image(image_hsv_lower.getchannel("V"), normalize=False)[0, :, :],
]
@@ -655,29 +645,8 @@ class InvokeImageBlendInvocation(BaseInvocation, WithMetadata, WithBoard):
if "oklch" in required:
upper_oklab_tensor = oklab_from_linear_srgb(upper_rgb_l_tensor)
lower_oklab_tensor = oklab_from_linear_srgb(lower_rgb_l_tensor)
-
- upper_oklch_tensor = torch.stack(
- [
- upper_oklab_tensor[0, :, :],
- torch.sqrt(
- torch.add(
- torch.pow(upper_oklab_tensor[1, :, :], 2.0), torch.pow(upper_oklab_tensor[2, :, :], 2.0)
- )
- ),
- torch.atan2(upper_oklab_tensor[2, :, :], upper_oklab_tensor[1, :, :]),
- ]
- )
- lower_oklch_tensor = torch.stack(
- [
- lower_oklab_tensor[0, :, :],
- torch.sqrt(
- torch.add(
- torch.pow(lower_oklab_tensor[1, :, :], 2.0), torch.pow(lower_oklab_tensor[2, :, :], 2.0)
- )
- ),
- torch.atan2(lower_oklab_tensor[2, :, :], lower_oklab_tensor[1, :, :]),
- ]
- )
+ upper_oklch_tensor = oklch_from_oklab(upper_oklab_tensor)
+ lower_oklch_tensor = oklch_from_oklab(lower_oklab_tensor)
return (
upper_rgb_l_tensor,
@@ -736,7 +705,17 @@ class InvokeImageBlendInvocation(BaseInvocation, WithMetadata, WithBoard):
"HSL": lambda t: linear_srgb_from_srgb(srgb_from_hsl(t)),
"HSV": lambda t: linear_srgb_from_srgb(
tensor_from_pil_image(
- pil_image_from_tensor(t.clamp(0.0, 1.0), mode="HSV").convert("RGB"), normalize=False
+ pil_image_from_tensor(
+ torch.stack(
+ [
+ torch.remainder(t[0, :, :], 360.0) / 360.0,
+ t[1, :, :].clamp(0.0, 1.0),
+ t[2, :, :].clamp(0.0, 1.0),
+ ]
+ ),
+ mode="HSV",
+ ).convert("RGB"),
+ normalize=False,
)
),
"Okhsl": lambda t: linear_srgb_from_srgb(
@@ -745,15 +724,7 @@ class InvokeImageBlendInvocation(BaseInvocation, WithMetadata, WithBoard):
"Okhsv": lambda t: linear_srgb_from_srgb(
srgb_from_okhsv(t, alpha=self.adaptive_gamut, steps=(3 if self.high_precision else 1))
),
- "Oklch": lambda t: linear_srgb_from_oklab(
- torch.stack(
- [
- t[0, :, :],
- torch.mul(t[1, :, :], torch.cos(t[2, :, :])),
- torch.mul(t[1, :, :], torch.sin(t[2, :, :])),
- ]
- )
- ),
+ "Oklch": lambda t: linear_srgb_from_oklab(oklab_from_oklch(t)),
"LCh": lambda t: linear_srgb_from_srgb(
tensor_from_pil_image(
self.image_convert_with_xform(
@@ -784,9 +755,9 @@ class InvokeImageBlendInvocation(BaseInvocation, WithMetadata, WithBoard):
alpha_upper_tensor,
alpha_lower_tensor,
mask_tensor,
- upper_hsv_tensor, # h_rgb, s_hsv, v_hsv
+ upper_hsv_tensor, # h_hsv_degrees, s_hsv, v_hsv
lower_hsv_tensor,
- upper_hsl_tensor, # , s_hsl, l_hsl
+ upper_hsl_tensor, # h_hsl_degrees, s_hsl, l_hsl
lower_hsl_tensor,
upper_lab_tensor, # l_lab, a_lab, b_lab
lower_lab_tensor,
@@ -796,11 +767,11 @@ class InvokeImageBlendInvocation(BaseInvocation, WithMetadata, WithBoard):
lower_l_eal_tensor,
upper_oklab_tensor, # l_oklab, a_oklab, b_oklab
lower_oklab_tensor,
- upper_oklch_tensor, # , c_oklab, h_oklab
+ upper_oklch_tensor, # l_oklab, c_oklab, h_oklab_degrees
lower_oklch_tensor,
- upper_okhsv_tensor, # h_okhsv, s_okhsv, v_okhsv
+ upper_okhsv_tensor, # h_okhsv_degrees, s_okhsv, v_okhsv
lower_okhsv_tensor,
- upper_okhsl_tensor, # h_okhsl, s_okhsl, l_r_oklab
+ upper_okhsl_tensor, # h_okhsl_degrees, s_okhsl, l_r_oklab
lower_okhsl_tensor,
) = image_tensors
@@ -850,6 +821,17 @@ class InvokeImageBlendInvocation(BaseInvocation, WithMetadata, WithBoard):
"LCh": 2,
}[color_space]
+ hue_period = {
+ "RGB": None,
+ "Linear": None,
+ "HSL": 360.0,
+ "HSV": 360.0,
+ "Okhsl": 360.0,
+ "Okhsv": 360.0,
+ "Oklch": 360.0,
+ "LCh": 2.0 * PI,
+ }[color_space]
+
if blend_mode == "Normal":
upper_rgb_l_tensor = reassembly_function(upper_space_tensor)
@@ -982,19 +964,19 @@ class InvokeImageBlendInvocation(BaseInvocation, WithMetadata, WithBoard):
elif blend_mode == "Linear Dodge (Add)":
lower_space_tensor = torch.add(lower_space_tensor, upper_space_tensor)
if hue_index is not None:
- lower_space_tensor[hue_index, :, :] = torch.remainder(lower_space_tensor[hue_index, :, :], 1.0)
+ lower_space_tensor[hue_index, :, :] = torch.remainder(lower_space_tensor[hue_index, :, :], hue_period)
upper_rgb_l_tensor = adaptive_clipped(reassembly_function(lower_space_tensor))
elif blend_mode == "Color Dodge":
lower_space_tensor = torch.div(lower_space_tensor, torch.add(torch.mul(upper_space_tensor, -1.0), 1.0))
if hue_index is not None:
- lower_space_tensor[hue_index, :, :] = torch.remainder(lower_space_tensor[hue_index, :, :], 1.0)
+ lower_space_tensor[hue_index, :, :] = torch.remainder(lower_space_tensor[hue_index, :, :], hue_period)
upper_rgb_l_tensor = adaptive_clipped(reassembly_function(lower_space_tensor))
elif blend_mode == "Divide":
lower_space_tensor = torch.div(lower_space_tensor, upper_space_tensor)
if hue_index is not None:
- lower_space_tensor[hue_index, :, :] = torch.remainder(lower_space_tensor[hue_index, :, :], 1.0)
+ lower_space_tensor[hue_index, :, :] = torch.remainder(lower_space_tensor[hue_index, :, :], hue_period)
upper_rgb_l_tensor = adaptive_clipped(reassembly_function(lower_space_tensor))
elif blend_mode == "Linear Burn":
@@ -1088,7 +1070,7 @@ class InvokeImageBlendInvocation(BaseInvocation, WithMetadata, WithBoard):
elif blend_mode == "Subtract":
lower_space_tensor = torch.sub(lower_space_tensor, upper_space_tensor)
if hue_index is not None:
- lower_space_tensor[hue_index, :, :] = torch.remainder(lower_space_tensor[hue_index, :, :], 1.0)
+ lower_space_tensor[hue_index, :, :] = torch.remainder(lower_space_tensor[hue_index, :, :], hue_period)
upper_rgb_l_tensor = adaptive_clipped(reassembly_function(lower_space_tensor))
elif blend_mode == "Difference":
diff --git a/invokeai/app/invocations/image.py b/invokeai/app/invocations/image.py
index 17576a0296..dabea9c868 100644
--- a/invokeai/app/invocations/image.py
+++ b/invokeai/app/invocations/image.py
@@ -4,6 +4,7 @@ from typing import Literal, Optional
import cv2
import numpy
+import torch
from PIL import Image, ImageChops, ImageFilter, ImageOps
from invokeai.app.invocations.baseinvocation import (
@@ -25,10 +26,41 @@ from invokeai.app.invocations.primitives import ImageOutput, StringOutput
from invokeai.app.services.image_records.image_records_common import ImageCategory
from invokeai.app.services.shared.invocation_context import InvocationContext
from invokeai.app.util.misc import SEED_MAX
+from invokeai.backend.image_util.color_conversion import (
+ linear_srgb_from_oklab,
+ linear_srgb_from_oklch,
+ linear_srgb_from_srgb,
+ oklab_from_linear_srgb,
+ oklch_from_oklab,
+ srgb_from_linear_srgb,
+)
from invokeai.backend.image_util.invisible_watermark import InvisibleWatermark
from invokeai.backend.image_util.safety_checker import SafetyChecker
+def _extract_alpha_channel(image: Image.Image) -> Image.Image | None:
+ if image.mode in ("RGBA", "LA", "PA"):
+ return image.getchannel("A")
+ return None
+
+
+def _restore_original_mode(image: Image.Image, mode: str, alpha_channel: Image.Image | None) -> Image.Image:
+ if alpha_channel is None:
+ return image.convert(mode)
+
+ if mode == "RGBA":
+ image = image.convert("RGB")
+ elif mode == "LA":
+ image = image.convert("L")
+ elif mode == "PA":
+ image = image.convert("P")
+ else:
+ return image.convert(mode)
+
+ image.putalpha(alpha_channel)
+ return image
+
+
@invocation("show_image", title="Show Image", tags=["image"], category="image", version="1.0.1")
class ShowImageInvocation(BaseInvocation):
"""Displays a provided image using the OS image viewer, and passes it forward in the pipeline."""
@@ -373,7 +405,7 @@ class UnsharpMaskInvocation(BaseInvocation, WithMetadata, WithBoard):
image = context.images.get_pil(self.image.image_name)
mode = image.mode
- alpha_channel = image.getchannel("A") if mode == "RGBA" else None
+ alpha_channel = _extract_alpha_channel(image)
image = image.convert("RGB")
image_blurred = self.array_from_pil(image.filter(ImageFilter.GaussianBlur(radius=self.radius)))
@@ -397,6 +429,53 @@ class UnsharpMaskInvocation(BaseInvocation, WithMetadata, WithBoard):
)
+@invocation(
+ "unsharp_mask_oklab",
+ title="Unsharp Mask (Oklab)",
+ tags=["image", "unsharp_mask", "oklab"],
+ category="image",
+ version="1.0.0",
+)
+class OklabUnsharpMaskInvocation(BaseInvocation, WithMetadata, WithBoard):
+ """Applies an unsharp mask filter to an image in the Oklab color space"""
+
+ image: ImageField = InputField(description="The image to use")
+ radius: float = InputField(gt=0, description="Unsharp mask radius", default=2)
+ strength: float = InputField(ge=0, description="Unsharp mask strength", default=50)
+
+ def pil_from_tensor(self, tensor: torch.Tensor) -> Image.Image:
+ array = torch.clamp(tensor, 0.0, 1.0).permute(1, 2, 0).cpu().numpy()
+ return Image.fromarray((array * 255).astype("uint8"))
+
+ def tensor_from_pil(self, img: Image.Image) -> torch.Tensor:
+ return torch.from_numpy(numpy.array(img, dtype=numpy.float32) / 255.0).permute(2, 0, 1)
+
+ def invoke(self, context: InvocationContext) -> ImageOutput:
+ image = context.images.get_pil(self.image.image_name)
+ mode = image.mode
+
+ alpha_channel = _extract_alpha_channel(image)
+ image = image.convert("RGB")
+
+ image_blurred = self.tensor_from_pil(image.filter(ImageFilter.GaussianBlur(radius=self.radius)))
+ image_tensor = self.tensor_from_pil(image)
+
+ image_oklab = oklab_from_linear_srgb(linear_srgb_from_srgb(image_tensor))
+ image_blurred_oklab = oklab_from_linear_srgb(linear_srgb_from_srgb(image_blurred))
+
+ image_oklab[0, ...] += (image_oklab[0, ...] - image_blurred_oklab[0, ...]) * (self.strength / 100.0)
+ image_oklab = torch.clamp(image_oklab, -1.0, 1.0)
+
+ image = _restore_original_mode(
+ self.pil_from_tensor(srgb_from_linear_srgb(linear_srgb_from_oklab(image_oklab))),
+ mode,
+ alpha_channel,
+ )
+
+ image_dto = context.images.save(image=image)
+ return ImageOutput.build(image_dto)
+
+
PIL_RESAMPLING_MODES = Literal[
"nearest",
"box",
@@ -802,6 +881,47 @@ class ImageHueAdjustmentInvocation(BaseInvocation, WithMetadata, WithBoard):
return ImageOutput.build(image_dto)
+@invocation(
+ "img_hue_adjust_oklch",
+ title="Adjust Image Hue (Oklch)",
+ tags=["image", "hue", "oklch"],
+ category="image",
+ version="1.0.0",
+)
+class OklchImageHueAdjustmentInvocation(BaseInvocation, WithMetadata, WithBoard):
+ """Adjusts the hue of an image in Oklch space."""
+
+ image: ImageField = InputField(description="The image to adjust")
+ hue: int = InputField(default=0, description="The degrees by which to rotate the hue, 0-360")
+
+ def invoke(self, context: InvocationContext) -> ImageOutput:
+ image = context.images.get_pil(self.image.image_name)
+ mode = image.mode
+ alpha_channel = _extract_alpha_channel(image)
+
+ rgb = torch.from_numpy(numpy.asarray(image.convert("RGB"), dtype=numpy.float32) / 255.0).permute(2, 0, 1)
+ oklch = oklch_from_oklab(oklab_from_linear_srgb(linear_srgb_from_srgb(rgb)))
+ oklch[2, ...] = (oklch[2, ...] + self.hue) % 360.0
+
+ image = _restore_original_mode(
+ Image.fromarray(
+ (
+ torch.clamp(srgb_from_linear_srgb(linear_srgb_from_oklch(oklch)), 0.0, 1.0)
+ .permute(1, 2, 0)
+ .cpu()
+ .numpy()
+ * 255.0
+ ).astype(numpy.uint8),
+ mode="RGB",
+ ),
+ mode,
+ alpha_channel,
+ )
+
+ image_dto = context.images.save(image=image)
+ return ImageOutput.build(image_dto)
+
+
COLOR_CHANNELS = Literal[
"Red (RGBA)",
"Green (RGBA)",
diff --git a/invokeai/backend/image_util/color_conversion.py b/invokeai/backend/image_util/color_conversion.py
new file mode 100644
index 0000000000..0dc368f983
--- /dev/null
+++ b/invokeai/backend/image_util/color_conversion.py
@@ -0,0 +1,1084 @@
+from math import pi as PI
+
+import torch
+
+MAX_FLOAT = torch.finfo(torch.tensor(1.0).dtype).max
+_SRGB_TO_LINEAR_THRESHOLD = 0.0404482362771082
+_LINEAR_TO_SRGB_THRESHOLD = 0.0031308
+_SRGB_TO_XYZ_D65_MATRIX = (
+ (0.4124, 0.3576, 0.1805),
+ (0.2126, 0.7152, 0.0722),
+ (0.0193, 0.1192, 0.9505),
+)
+_XYZ_D65_TO_SRGB_MATRIX = (
+ (3.2406255, -1.5372080, -0.4986286),
+ (-0.9689307, 1.8757561, 0.0415175),
+ (0.0557101, -0.2040211, 1.0569959),
+)
+_BRADFORD_MATRIX = (
+ (0.8951, 0.2664, -0.1614),
+ (-0.7502, 1.7135, 0.0367),
+ (0.0389, -0.0685, 1.0296),
+)
+_BRADFORD_INVERSE_MATRIX = (
+ (0.9869929, -0.1470543, 0.1599627),
+ (0.4323053, 0.5183603, 0.0492912),
+ (-0.0085287, 0.0400428, 0.9684867),
+)
+_REFERENCE_ILLUMINANTS = {
+ "D65": (0.950489, 1.0, 1.088840),
+ "D50": (0.964212, 1.0, 0.825188),
+}
+_LINEAR_SRGB_TO_OKLAB_LMS_MATRIX = (
+ (0.4122214708, 0.5363325363, 0.0514459929),
+ (0.2119034982, 0.6806995451, 0.1073969566),
+ (0.0883024619, 0.2817188376, 0.6299787005),
+)
+_LMS_CUBE_ROOT_TO_OKLAB_MATRIX = (
+ (0.2104542553, 0.7936177850, -0.0040720468),
+ (1.9779984951, -2.4285922050, 0.4505937099),
+ (0.0259040371, 0.7827717662, -0.8086757660),
+)
+_OKLAB_TO_LMS_CUBE_ROOT_MATRIX = (
+ (1.0, 0.3963377774, 0.2158037573),
+ (1.0, -0.1055613458, -0.0638541728),
+ (1.0, -0.0894841775, -1.2914855480),
+)
+_LMS_TO_LINEAR_SRGB_MATRIX = (
+ (4.0767416621, -3.3077115913, 0.2309699292),
+ (-1.2684380046, 2.6097574011, -0.3413193965),
+ (-0.0041960863, -0.7034186147, 1.7076147010),
+)
+
+
+def _require_color_tensor(color_tensor: torch.Tensor) -> torch.Tensor:
+ if color_tensor.ndim != 3 or color_tensor.shape[0] != 3:
+ raise ValueError("color_tensor must be a 3xHxW tensor")
+ return color_tensor
+
+
+def _require_reference_illuminant(reference_illuminant: str) -> str:
+ normalized = reference_illuminant.upper()
+ if normalized not in _REFERENCE_ILLUMINANTS:
+ raise ValueError(f"Unsupported reference_illuminant: {reference_illuminant}")
+ return normalized
+
+
+def _full_like_spatial(reference_tensor: torch.Tensor, fill_value: float) -> torch.Tensor:
+ return torch.full(
+ reference_tensor.shape[1:], fill_value, dtype=reference_tensor.dtype, device=reference_tensor.device
+ )
+
+
+def _degrees_from_unit_hue(unit_hue_tensor: torch.Tensor) -> torch.Tensor:
+ return torch.remainder(unit_hue_tensor * 360.0, 360.0)
+
+
+def _unit_hue_from_degrees(hue_tensor: torch.Tensor) -> torch.Tensor:
+ return torch.remainder(hue_tensor, 360.0) / 360.0
+
+
+def _matrix_tensor(matrix: tuple[tuple[float, ...], ...], reference_tensor: torch.Tensor) -> torch.Tensor:
+ return torch.tensor(matrix, dtype=reference_tensor.dtype, device=reference_tensor.device)
+
+
+def _apply_matrix(matrix: tuple[tuple[float, ...], ...], color_tensor: torch.Tensor) -> torch.Tensor:
+ return torch.einsum("rc,cwh->rwh", _matrix_tensor(matrix, color_tensor), color_tensor)
+
+
+def _reference_white_tensor(reference_illuminant: str, reference_tensor: torch.Tensor) -> torch.Tensor:
+ return torch.tensor(
+ _REFERENCE_ILLUMINANTS[reference_illuminant], dtype=reference_tensor.dtype, device=reference_tensor.device
+ ).view(3, 1, 1)
+
+
+def _adapt_xyz(xyz_tensor: torch.Tensor, source_illuminant: str, target_illuminant: str) -> torch.Tensor:
+ xyz_tensor = _require_color_tensor(xyz_tensor)
+ source_illuminant = _require_reference_illuminant(source_illuminant)
+ target_illuminant = _require_reference_illuminant(target_illuminant)
+ if source_illuminant == target_illuminant:
+ return xyz_tensor
+ source_white_lms = _apply_matrix(_BRADFORD_MATRIX, _reference_white_tensor(source_illuminant, xyz_tensor))
+ target_white_lms = _apply_matrix(_BRADFORD_MATRIX, _reference_white_tensor(target_illuminant, xyz_tensor))
+ xyz_lms = _apply_matrix(_BRADFORD_MATRIX, xyz_tensor)
+ adapted_lms = xyz_lms * (target_white_lms / source_white_lms)
+ return _apply_matrix(_BRADFORD_INVERSE_MATRIX, adapted_lms)
+
+
+def srgb_from_linear_srgb(linear_srgb_tensor: torch.Tensor) -> torch.Tensor:
+ """Convert a 3xHxW linear-light sRGB tensor in [0, 1] to gamma-corrected sRGB."""
+
+ linear_srgb_tensor = _require_color_tensor(linear_srgb_tensor)
+ linear_srgb_tensor = linear_srgb_tensor.clamp(0.0, 1.0)
+ return torch.where(
+ linear_srgb_tensor <= _LINEAR_TO_SRGB_THRESHOLD,
+ linear_srgb_tensor * 12.92,
+ 1.055 * torch.pow(linear_srgb_tensor, 1.0 / 2.4) - 0.055,
+ )
+
+
+def linear_srgb_from_srgb(srgb_tensor: torch.Tensor) -> torch.Tensor:
+ """Convert a 3xHxW gamma-corrected sRGB tensor in [0, 1] to linear-light sRGB."""
+
+ srgb_tensor = _require_color_tensor(srgb_tensor)
+ return torch.where(
+ srgb_tensor <= _SRGB_TO_LINEAR_THRESHOLD,
+ srgb_tensor / 12.92,
+ torch.pow((srgb_tensor + 0.055) / 1.055, 2.4),
+ )
+
+
+def xyz_from_linear_srgb(linear_srgb_tensor: torch.Tensor) -> torch.Tensor:
+ """Convert a 3xHxW linear-light sRGB tensor to normalized XYZ, where D65 white is approximately 1.0."""
+
+ linear_srgb_tensor = _require_color_tensor(linear_srgb_tensor)
+ return _apply_matrix(_SRGB_TO_XYZ_D65_MATRIX, linear_srgb_tensor)
+
+
+def linear_srgb_from_xyz(xyz_tensor: torch.Tensor) -> torch.Tensor:
+ """Convert a 3xHxW normalized XYZ tensor, where D65 white is approximately 1.0, to linear-light sRGB."""
+
+ xyz_tensor = _require_color_tensor(xyz_tensor)
+ return _apply_matrix(_XYZ_D65_TO_SRGB_MATRIX, xyz_tensor)
+
+
+def xyz_from_srgb(srgb_tensor: torch.Tensor) -> torch.Tensor:
+ """Convert a 3xHxW gamma-corrected sRGB tensor to normalized XYZ, where D65 white is approximately 1.0."""
+
+ srgb_tensor = _require_color_tensor(srgb_tensor)
+ return xyz_from_linear_srgb(linear_srgb_from_srgb(srgb_tensor))
+
+
+def srgb_from_xyz(xyz_tensor: torch.Tensor) -> torch.Tensor:
+ """Convert a 3xHxW normalized XYZ tensor, where D65 white is approximately 1.0, to gamma-corrected sRGB."""
+
+ xyz_tensor = _require_color_tensor(xyz_tensor)
+ return srgb_from_linear_srgb(linear_srgb_from_xyz(xyz_tensor))
+
+
+def xyz_d65_to_d50(xyz_tensor: torch.Tensor) -> torch.Tensor:
+ """Adapt a 3xHxW normalized XYZ tensor from D65 to D50 using Bradford chromatic adaptation."""
+
+ return _adapt_xyz(xyz_tensor, source_illuminant="D65", target_illuminant="D50")
+
+
+def xyz_d50_to_d65(xyz_tensor: torch.Tensor) -> torch.Tensor:
+ """Adapt a 3xHxW normalized XYZ tensor from D50 to D65 using Bradford chromatic adaptation."""
+
+ return _adapt_xyz(xyz_tensor, source_illuminant="D50", target_illuminant="D65")
+
+
+def _lab_from_xyz_helper(channel_illuminant_quotient_tensor: torch.Tensor) -> torch.Tensor:
+ delta = 6.0 / 29.0
+ return torch.where(
+ torch.gt(channel_illuminant_quotient_tensor, delta**3.0),
+ torch.pow(channel_illuminant_quotient_tensor, 1.0 / 3.0),
+ torch.add(torch.div(channel_illuminant_quotient_tensor, 3.0 * (delta**2.0)), 4.0 / 29.0),
+ )
+
+
+def _xyz_from_lab_helper(channel_tensor: torch.Tensor) -> torch.Tensor:
+ delta = 6.0 / 29.0
+ return torch.where(
+ torch.gt(channel_tensor, delta),
+ torch.pow(channel_tensor, 3.0),
+ torch.mul(3.0 * (delta**2.0), torch.sub(channel_tensor, 4.0 / 29.0)),
+ )
+
+
+def lab_from_xyz(xyz_tensor: torch.Tensor, reference_illuminant: str = "D65") -> torch.Tensor:
+ """Convert a 3xHxW normalized XYZ tensor to CIELAB using the given reference illuminant."""
+
+ xyz_tensor = _require_color_tensor(xyz_tensor)
+ reference_illuminant = _require_reference_illuminant(reference_illuminant)
+ illuminant = _reference_white_tensor(reference_illuminant, xyz_tensor)
+ l_tensor = torch.sub(torch.mul(_lab_from_xyz_helper(torch.div(xyz_tensor[1, :, :], illuminant[1])), 116.0), 16.0)
+ a_tensor = torch.mul(
+ torch.sub(
+ _lab_from_xyz_helper(torch.div(xyz_tensor[0, :, :], illuminant[0])),
+ _lab_from_xyz_helper(torch.div(xyz_tensor[1, :, :], illuminant[1])),
+ ),
+ 500.0,
+ )
+ b_tensor = torch.mul(
+ torch.sub(
+ _lab_from_xyz_helper(torch.div(xyz_tensor[1, :, :], illuminant[1])),
+ _lab_from_xyz_helper(torch.div(xyz_tensor[2, :, :], illuminant[2])),
+ ),
+ 200.0,
+ )
+ return torch.stack([l_tensor, a_tensor, b_tensor])
+
+
+def xyz_from_lab(lab_tensor: torch.Tensor, reference_illuminant: str = "D65") -> torch.Tensor:
+ """Convert a 3xHxW CIELAB tensor to normalized XYZ using the given reference illuminant."""
+
+ lab_tensor = _require_color_tensor(lab_tensor)
+ reference_illuminant = _require_reference_illuminant(reference_illuminant)
+ illuminant = _reference_white_tensor(reference_illuminant, lab_tensor)
+ fy_tensor = (lab_tensor[0, :, :] + 16.0) / 116.0
+ fx_tensor = fy_tensor + (lab_tensor[1, :, :] / 500.0)
+ fz_tensor = fy_tensor - (lab_tensor[2, :, :] / 200.0)
+ return torch.stack(
+ [
+ illuminant[0] * _xyz_from_lab_helper(fx_tensor),
+ illuminant[1] * _xyz_from_lab_helper(fy_tensor),
+ illuminant[2] * _xyz_from_lab_helper(fz_tensor),
+ ]
+ )
+
+
+def lab_from_linear_srgb(linear_srgb_tensor: torch.Tensor, reference_illuminant: str = "D65") -> torch.Tensor:
+ """Convert a 3xHxW linear-light sRGB tensor to CIELAB using the given reference illuminant."""
+
+ linear_srgb_tensor = _require_color_tensor(linear_srgb_tensor)
+ reference_illuminant = _require_reference_illuminant(reference_illuminant)
+ xyz_tensor = xyz_from_linear_srgb(linear_srgb_tensor)
+ if reference_illuminant != "D65":
+ xyz_tensor = _adapt_xyz(xyz_tensor, source_illuminant="D65", target_illuminant=reference_illuminant)
+ return lab_from_xyz(xyz_tensor, reference_illuminant=reference_illuminant)
+
+
+def linear_srgb_from_lab(lab_tensor: torch.Tensor, reference_illuminant: str = "D65") -> torch.Tensor:
+ """Convert a 3xHxW CIELAB tensor to linear-light sRGB using the given reference illuminant."""
+
+ lab_tensor = _require_color_tensor(lab_tensor)
+ reference_illuminant = _require_reference_illuminant(reference_illuminant)
+ xyz_tensor = xyz_from_lab(lab_tensor, reference_illuminant=reference_illuminant)
+ if reference_illuminant != "D65":
+ xyz_tensor = _adapt_xyz(xyz_tensor, source_illuminant=reference_illuminant, target_illuminant="D65")
+ return linear_srgb_from_xyz(xyz_tensor)
+
+
+def lab_from_srgb(srgb_tensor: torch.Tensor, reference_illuminant: str = "D65") -> torch.Tensor:
+ """Convert a 3xHxW gamma-corrected sRGB tensor to CIELAB using the given reference illuminant."""
+
+ srgb_tensor = _require_color_tensor(srgb_tensor)
+ return lab_from_linear_srgb(linear_srgb_from_srgb(srgb_tensor), reference_illuminant=reference_illuminant)
+
+
+def srgb_from_lab(lab_tensor: torch.Tensor, reference_illuminant: str = "D65") -> torch.Tensor:
+ """Convert a 3xHxW CIELAB tensor to gamma-corrected sRGB using the given reference illuminant."""
+
+ lab_tensor = _require_color_tensor(lab_tensor)
+ return srgb_from_linear_srgb(linear_srgb_from_lab(lab_tensor, reference_illuminant=reference_illuminant))
+
+
+def oklab_from_linear_srgb(linear_srgb_tensor: torch.Tensor) -> torch.Tensor:
+ """Convert a 3xHxW linear-light sRGB tensor to Oklab."""
+
+ linear_srgb_tensor = _require_color_tensor(linear_srgb_tensor)
+ lms_tensor = _apply_matrix(_LINEAR_SRGB_TO_OKLAB_LMS_MATRIX, linear_srgb_tensor)
+ lms_cbrt_tensor = torch.sign(lms_tensor) * torch.pow(torch.abs(lms_tensor), 1.0 / 3.0)
+ return _apply_matrix(_LMS_CUBE_ROOT_TO_OKLAB_MATRIX, lms_cbrt_tensor)
+
+
+def linear_srgb_from_oklab(oklab_tensor: torch.Tensor) -> torch.Tensor:
+ """Convert a 3xHxW Oklab tensor to linear-light sRGB."""
+
+ oklab_tensor = _require_color_tensor(oklab_tensor)
+ lms_cbrt_tensor = _apply_matrix(_OKLAB_TO_LMS_CUBE_ROOT_MATRIX, oklab_tensor)
+ lms_tensor = lms_cbrt_tensor**3
+ return _apply_matrix(_LMS_TO_LINEAR_SRGB_MATRIX, lms_tensor)
+
+
+def oklab_from_srgb(srgb_tensor: torch.Tensor) -> torch.Tensor:
+ """Convert a 3xHxW gamma-corrected sRGB tensor to Oklab."""
+
+ srgb_tensor = _require_color_tensor(srgb_tensor)
+ return oklab_from_linear_srgb(linear_srgb_from_srgb(srgb_tensor))
+
+
+def srgb_from_oklab(oklab_tensor: torch.Tensor) -> torch.Tensor:
+ """Convert a 3xHxW Oklab tensor to gamma-corrected sRGB."""
+
+ oklab_tensor = _require_color_tensor(oklab_tensor)
+ return srgb_from_linear_srgb(linear_srgb_from_oklab(oklab_tensor))
+
+
+def oklab_from_xyz(xyz_tensor: torch.Tensor) -> torch.Tensor:
+ """Convert a 3xHxW normalized XYZ tensor, where D65 white is approximately 1.0, to Oklab."""
+
+ xyz_tensor = _require_color_tensor(xyz_tensor)
+ return oklab_from_linear_srgb(linear_srgb_from_xyz(xyz_tensor))
+
+
+def xyz_from_oklab(oklab_tensor: torch.Tensor) -> torch.Tensor:
+ """Convert a 3xHxW Oklab tensor to normalized XYZ, where D65 white is approximately 1.0."""
+
+ oklab_tensor = _require_color_tensor(oklab_tensor)
+ return xyz_from_linear_srgb(linear_srgb_from_oklab(oklab_tensor))
+
+
+def oklch_from_oklab(oklab_tensor: torch.Tensor) -> torch.Tensor:
+ """Convert a 3xHxW Oklab tensor to Oklch, with hue in degrees."""
+
+ oklab_tensor = _require_color_tensor(oklab_tensor)
+ lightness = oklab_tensor[0, ...]
+ chroma = torch.sqrt(oklab_tensor[1, ...] ** 2 + oklab_tensor[2, ...] ** 2)
+ hue = torch.remainder(torch.rad2deg(torch.atan2(oklab_tensor[2, ...], oklab_tensor[1, ...])), 360.0)
+ return torch.stack([lightness, chroma, hue])
+
+
+def oklab_from_oklch(oklch_tensor: torch.Tensor) -> torch.Tensor:
+ """Convert a 3xHxW Oklch tensor, with hue in degrees, to Oklab."""
+
+ oklch_tensor = _require_color_tensor(oklch_tensor)
+ hue_radians = torch.deg2rad(oklch_tensor[2, ...])
+ a_channel = oklch_tensor[1, ...] * torch.cos(hue_radians)
+ b_channel = oklch_tensor[1, ...] * torch.sin(hue_radians)
+ return torch.stack([oklch_tensor[0, ...], a_channel, b_channel])
+
+
+def linear_srgb_from_oklch(oklch_tensor: torch.Tensor) -> torch.Tensor:
+ """Convert a 3xHxW Oklch tensor directly to linear-light sRGB."""
+
+ oklch_tensor = _require_color_tensor(oklch_tensor)
+ return linear_srgb_from_oklab(oklab_from_oklch(oklch_tensor))
+
+
+def oklch_from_linear_srgb(linear_srgb_tensor: torch.Tensor) -> torch.Tensor:
+ """Convert a 3xHxW linear-light sRGB tensor directly to Oklch."""
+
+ linear_srgb_tensor = _require_color_tensor(linear_srgb_tensor)
+ return oklch_from_oklab(oklab_from_linear_srgb(linear_srgb_tensor))
+
+
+def oklch_from_srgb(srgb_tensor: torch.Tensor) -> torch.Tensor:
+ """Convert a 3xHxW gamma-corrected sRGB tensor directly to Oklch."""
+
+ srgb_tensor = _require_color_tensor(srgb_tensor)
+ return oklch_from_linear_srgb(linear_srgb_from_srgb(srgb_tensor))
+
+
+def srgb_from_oklch(oklch_tensor: torch.Tensor) -> torch.Tensor:
+ """Convert a 3xHxW Oklch tensor directly to gamma-corrected sRGB."""
+
+ oklch_tensor = _require_color_tensor(oklch_tensor)
+ return srgb_from_linear_srgb(linear_srgb_from_oklch(oklch_tensor))
+
+
+def oklch_from_xyz(xyz_tensor: torch.Tensor) -> torch.Tensor:
+ """Convert a 3xHxW normalized XYZ tensor, where D65 white is approximately 1.0, to Oklch."""
+
+ xyz_tensor = _require_color_tensor(xyz_tensor)
+ return oklch_from_oklab(oklab_from_xyz(xyz_tensor))
+
+
+def xyz_from_oklch(oklch_tensor: torch.Tensor) -> torch.Tensor:
+ """Convert a 3xHxW Oklch tensor to normalized XYZ, where D65 white is approximately 1.0."""
+
+ oklch_tensor = _require_color_tensor(oklch_tensor)
+ return xyz_from_oklab(oklab_from_oklch(oklch_tensor))
+
+
+def _max_srgb_saturation_tensor(units_ab_tensor: torch.Tensor, steps: int = 1) -> torch.Tensor:
+ rgb_k_matrix = torch.tensor(
+ [
+ [1.19086277, 1.76576728, 0.59662641, 0.75515197, 0.56771245],
+ [0.73956515, -0.45954494, 0.08285427, 0.12541070, 0.14503204],
+ [1.35733652, -0.00915799, -1.15130210, -0.50559606, 0.00692167],
+ ],
+ dtype=units_ab_tensor.dtype,
+ device=units_ab_tensor.device,
+ )
+ rgb_w_matrix = _matrix_tensor(_LMS_TO_LINEAR_SRGB_MATRIX, units_ab_tensor)
+ cond_r_tensor = torch.add(
+ torch.mul(-1.88170328, units_ab_tensor[0, :, :]), torch.mul(-0.80936493, units_ab_tensor[1, :, :])
+ )
+ cond_g_tensor = torch.add(
+ torch.mul(1.81444104, units_ab_tensor[0, :, :]), torch.mul(-1.19445276, units_ab_tensor[1, :, :])
+ )
+ terms_tensor = torch.stack(
+ [
+ torch.ones(units_ab_tensor.shape[1:], dtype=units_ab_tensor.dtype, device=units_ab_tensor.device),
+ units_ab_tensor[0, :, :],
+ units_ab_tensor[1, :, :],
+ torch.pow(units_ab_tensor[0, :, :], 2.0),
+ torch.mul(units_ab_tensor[0, :, :], units_ab_tensor[1, :, :]),
+ ]
+ )
+ s_tensor = torch.where(
+ torch.gt(cond_r_tensor, 1.0),
+ torch.einsum("twh, t -> wh", terms_tensor, rgb_k_matrix[0]),
+ torch.where(
+ torch.gt(cond_g_tensor, 1.0),
+ torch.einsum("twh, t -> wh", terms_tensor, rgb_k_matrix[1]),
+ torch.einsum("twh, t -> wh", terms_tensor, rgb_k_matrix[2]),
+ ),
+ )
+ k_lms_matrix = _matrix_tensor(tuple(row[1:] for row in _OKLAB_TO_LMS_CUBE_ROOT_MATRIX), units_ab_tensor)
+ k_lms_tensor = torch.einsum("tc, cwh -> twh", k_lms_matrix, units_ab_tensor)
+ for _ in range(steps):
+ root_lms_tensor = torch.add(torch.mul(k_lms_tensor, s_tensor), 1.0)
+ lms_tensor = torch.pow(root_lms_tensor, 3.0)
+ lms_ds_tensor = torch.mul(torch.mul(k_lms_tensor, torch.pow(root_lms_tensor, 2.0)), 3.0)
+ lms_ds2_tensor = torch.mul(torch.mul(torch.pow(k_lms_tensor, 2.0), root_lms_tensor), 6.0)
+ f_tensor = torch.where(
+ torch.gt(cond_r_tensor, 1.0),
+ torch.einsum("c, cwh -> wh", rgb_w_matrix[0], lms_tensor),
+ torch.where(
+ torch.gt(cond_g_tensor, 1.0),
+ torch.einsum("c, cwh -> wh", rgb_w_matrix[1], lms_tensor),
+ torch.einsum("c, cwh -> wh", rgb_w_matrix[2], lms_tensor),
+ ),
+ )
+ f_tensor_1 = torch.where(
+ torch.gt(cond_r_tensor, 1.0),
+ torch.einsum("c, cwh -> wh", rgb_w_matrix[0], lms_ds_tensor),
+ torch.where(
+ torch.gt(cond_g_tensor, 1.0),
+ torch.einsum("c, cwh -> wh", rgb_w_matrix[1], lms_ds_tensor),
+ torch.einsum("c, cwh -> wh", rgb_w_matrix[2], lms_ds_tensor),
+ ),
+ )
+ f_tensor_2 = torch.where(
+ torch.gt(cond_r_tensor, 1.0),
+ torch.einsum("c, cwh -> wh", rgb_w_matrix[0], lms_ds2_tensor),
+ torch.where(
+ torch.gt(cond_g_tensor, 1.0),
+ torch.einsum("c, cwh -> wh", rgb_w_matrix[1], lms_ds2_tensor),
+ torch.einsum("c, cwh -> wh", rgb_w_matrix[2], lms_ds2_tensor),
+ ),
+ )
+ s_tensor = torch.sub(
+ s_tensor,
+ torch.div(
+ torch.mul(f_tensor, f_tensor_1),
+ torch.sub(torch.pow(f_tensor_1, 2.0), torch.mul(torch.mul(f_tensor, f_tensor_2), 0.5)),
+ ),
+ )
+ return s_tensor
+
+
+def _find_cusp_tensor(units_ab_tensor: torch.Tensor, steps: int = 1) -> torch.Tensor:
+ s_cusp_tensor = _max_srgb_saturation_tensor(units_ab_tensor, steps=steps)
+ oklab_tensor = torch.stack(
+ [
+ torch.ones(s_cusp_tensor.shape, dtype=s_cusp_tensor.dtype, device=s_cusp_tensor.device),
+ torch.mul(s_cusp_tensor, units_ab_tensor[0, :, :]),
+ torch.mul(s_cusp_tensor, units_ab_tensor[1, :, :]),
+ ]
+ )
+ rgb_at_max_tensor = linear_srgb_from_oklab(oklab_tensor)
+ l_cusp_tensor = torch.pow(torch.div(1.0, rgb_at_max_tensor.max(0).values), 1.0 / 3.0)
+ c_cusp_tensor = torch.mul(l_cusp_tensor, s_cusp_tensor)
+ return torch.stack([l_cusp_tensor, c_cusp_tensor])
+
+
+def _find_gamut_intersection_tensor(
+ units_ab_tensor: torch.Tensor,
+ l_1_tensor: torch.Tensor,
+ c_1_tensor: torch.Tensor,
+ l_0_tensor: torch.Tensor,
+ steps: int = 1,
+ steps_outer: int = 1,
+ lc_cusps_tensor: torch.Tensor | None = None,
+) -> torch.Tensor:
+ if lc_cusps_tensor is None:
+ lc_cusps_tensor = _find_cusp_tensor(units_ab_tensor, steps=steps)
+ cond_tensor = torch.sub(
+ torch.mul(torch.sub(l_1_tensor, l_0_tensor), lc_cusps_tensor[1, :, :]),
+ torch.mul(torch.sub(lc_cusps_tensor[0, :, :], l_0_tensor), c_1_tensor),
+ )
+ t_tensor = torch.where(
+ torch.le(cond_tensor, 0.0),
+ torch.div(
+ torch.mul(lc_cusps_tensor[1, :, :], l_0_tensor),
+ torch.add(
+ torch.mul(c_1_tensor, lc_cusps_tensor[0, :, :]),
+ torch.mul(lc_cusps_tensor[1, :, :], torch.sub(l_0_tensor, l_1_tensor)),
+ ),
+ ),
+ torch.div(
+ torch.mul(lc_cusps_tensor[1, :, :], torch.sub(l_0_tensor, 1.0)),
+ torch.add(
+ torch.mul(c_1_tensor, torch.sub(lc_cusps_tensor[0, :, :], 1.0)),
+ torch.mul(lc_cusps_tensor[1, :, :], torch.sub(l_0_tensor, l_1_tensor)),
+ ),
+ ),
+ )
+ for _ in range(steps_outer):
+ dl_tensor = torch.sub(l_1_tensor, l_0_tensor)
+ dc_tensor = c_1_tensor
+ k_lms_matrix = _matrix_tensor(tuple(row[1:] for row in _OKLAB_TO_LMS_CUBE_ROOT_MATRIX), units_ab_tensor)
+ k_lms_tensor = torch.einsum("tc, cwh -> twh", k_lms_matrix, units_ab_tensor)
+ lms_dt_tensor = torch.add(torch.mul(k_lms_tensor, dc_tensor), dl_tensor)
+ for _ in range(steps):
+ l_tensor = torch.add(
+ torch.mul(l_0_tensor, torch.add(torch.mul(t_tensor, -1.0), 1.0)), torch.mul(t_tensor, l_1_tensor)
+ )
+ c_tensor = torch.mul(t_tensor, c_1_tensor)
+ root_lms_tensor = torch.add(torch.mul(k_lms_tensor, c_tensor), l_tensor)
+ lms_tensor = torch.pow(root_lms_tensor, 3.0)
+ lms_dt_tensor_1 = torch.mul(torch.mul(torch.pow(root_lms_tensor, 2.0), lms_dt_tensor), 3.0)
+ lms_dt2_tensor = torch.mul(torch.mul(torch.pow(lms_dt_tensor, 2.0), root_lms_tensor), 6.0)
+ rgb_matrix = _matrix_tensor(_LMS_TO_LINEAR_SRGB_MATRIX, units_ab_tensor)
+ rgb_tensor = torch.sub(torch.einsum("qt, twh -> qwh", rgb_matrix, lms_tensor), 1.0)
+ rgb_tensor_1 = torch.einsum("qt, twh -> qwh", rgb_matrix, lms_dt_tensor_1)
+ rgb_tensor_2 = torch.einsum("qt, twh -> qwh", rgb_matrix, lms_dt2_tensor)
+ u_rgb_tensor = torch.div(
+ rgb_tensor_1,
+ torch.sub(torch.pow(rgb_tensor_1, 2.0), torch.mul(torch.mul(rgb_tensor, rgb_tensor_2), 0.5)),
+ )
+ t_rgb_tensor = torch.mul(torch.mul(rgb_tensor, -1.0), u_rgb_tensor)
+ max_floats = torch.mul(
+ MAX_FLOAT, torch.ones(t_rgb_tensor.shape, dtype=t_rgb_tensor.dtype, device=t_rgb_tensor.device)
+ )
+ t_rgb_tensor = torch.where(torch.lt(u_rgb_tensor, 0.0), max_floats, t_rgb_tensor)
+ t_tensor = torch.where(
+ torch.gt(cond_tensor, 0.0), torch.add(t_tensor, t_rgb_tensor.min(0).values), t_tensor
+ )
+ return t_tensor
+
+
+def gamut_clip_tensor(
+ rgb_l_tensor: torch.Tensor, alpha: float = 0.05, steps: int = 1, steps_outer: int = 1
+) -> torch.Tensor:
+ rgb_l_tensor = _require_color_tensor(rgb_l_tensor)
+ lab_tensor = oklab_from_linear_srgb(rgb_l_tensor)
+ epsilon = 0.00001
+ chroma_tensor = torch.sqrt(torch.add(torch.pow(lab_tensor[1, :, :], 2.0), torch.pow(lab_tensor[2, :, :], 2.0)))
+ chroma_tensor = torch.where(torch.lt(chroma_tensor, epsilon), epsilon, chroma_tensor)
+ units_ab_tensor = torch.div(lab_tensor[1:, :, :], chroma_tensor)
+ l_d_tensor = torch.sub(lab_tensor[0], 0.5)
+ e_1_tensor = torch.add(torch.add(torch.abs(l_d_tensor), torch.mul(chroma_tensor, alpha)), 0.5)
+ l_0_tensor = torch.mul(
+ torch.add(
+ torch.mul(
+ torch.sign(l_d_tensor),
+ torch.sub(
+ e_1_tensor, torch.sqrt(torch.sub(torch.pow(e_1_tensor, 2.0), torch.mul(torch.abs(l_d_tensor), 2.0)))
+ ),
+ ),
+ 1.0,
+ ),
+ 0.5,
+ )
+ t_tensor = _find_gamut_intersection_tensor(
+ units_ab_tensor, lab_tensor[0, :, :], chroma_tensor, l_0_tensor, steps=steps, steps_outer=steps_outer
+ )
+ l_clipped_tensor = torch.add(
+ torch.mul(l_0_tensor, torch.add(torch.mul(t_tensor, -1), 1.0)), torch.mul(t_tensor, lab_tensor[0, :, :])
+ )
+ c_clipped_tensor = torch.mul(t_tensor, chroma_tensor)
+ return torch.where(
+ torch.logical_or(torch.gt(rgb_l_tensor.max(0).values, 1.0), torch.lt(rgb_l_tensor.min(0).values, 0.0)),
+ linear_srgb_from_oklab(
+ torch.stack(
+ [
+ l_clipped_tensor,
+ torch.mul(c_clipped_tensor, units_ab_tensor[0, :, :]),
+ torch.mul(c_clipped_tensor, units_ab_tensor[1, :, :]),
+ ]
+ )
+ ),
+ rgb_l_tensor,
+ )
+
+
+def _st_cusps_from_lc(lc_cusps_tensor: torch.Tensor) -> torch.Tensor:
+ return torch.stack(
+ [
+ torch.div(lc_cusps_tensor[1, :, :], lc_cusps_tensor[0, :, :]),
+ torch.div(lc_cusps_tensor[1, :, :], torch.add(torch.mul(lc_cusps_tensor[0, :, :], -1.0), 1)),
+ ]
+ )
+
+
+def _ok_l_r_from_l_tensor(x_tensor: torch.Tensor) -> torch.Tensor:
+ k_1 = 0.206
+ k_2 = 0.03
+ k_3 = (1.0 + k_1) / (1.0 + k_2)
+ return torch.mul(
+ torch.add(
+ torch.sub(torch.mul(x_tensor, k_3), k_1),
+ torch.sqrt(
+ torch.add(
+ torch.pow(torch.sub(torch.mul(x_tensor, k_3), k_1), 2.0),
+ torch.mul(torch.mul(torch.mul(x_tensor, k_3), k_2), 4.0),
+ )
+ ),
+ ),
+ 0.5,
+ )
+
+
+def _ok_l_from_lr_tensor(x_tensor: torch.Tensor) -> torch.Tensor:
+ k_1 = 0.206
+ k_2 = 0.03
+ k_3 = (1.0 + k_1) / (1.0 + k_2)
+ return torch.div(
+ torch.add(torch.pow(x_tensor, 2.0), torch.mul(x_tensor, k_1)), torch.mul(torch.add(x_tensor, k_2), k_3)
+ )
+
+
+def srgb_from_okhsv(okhsv_tensor: torch.Tensor, alpha: float = 0.05, steps: int = 1) -> torch.Tensor:
+ """Convert a 3xHxW Okhsv tensor, with hue in degrees, to gamma-corrected sRGB."""
+
+ okhsv_tensor = _require_color_tensor(okhsv_tensor)
+ okhsv_tensor = okhsv_tensor.clone()
+ okhsv_tensor[1:, ...] = okhsv_tensor[1:, ...].clamp(0.0, 1.0)
+ unit_hue_tensor = _unit_hue_from_degrees(okhsv_tensor[0, :, :])
+ units_ab_tensor = torch.stack(
+ [torch.cos(torch.mul(unit_hue_tensor, 2.0 * PI)), torch.sin(torch.mul(unit_hue_tensor, 2.0 * PI))]
+ )
+ lc_cusps_tensor = _find_cusp_tensor(units_ab_tensor, steps=steps)
+ st_max_tensor = _st_cusps_from_lc(lc_cusps_tensor)
+ s_0_tensor = _full_like_spatial(st_max_tensor, 0.5)
+ k_tensor = torch.add(torch.mul(torch.div(s_0_tensor, st_max_tensor[0, :, :]), -1.0), 1)
+ lc_v_base_tensor = torch.add(
+ s_0_tensor,
+ torch.sub(
+ st_max_tensor[1, :, :], torch.mul(st_max_tensor[1, :, :], torch.mul(k_tensor, okhsv_tensor[1, :, :]))
+ ),
+ )
+ lc_v_tensor = torch.stack(
+ [
+ torch.add(torch.div(torch.mul(torch.mul(okhsv_tensor[1, :, :], s_0_tensor), -1.0), lc_v_base_tensor), 1.0),
+ torch.div(
+ torch.mul(torch.mul(okhsv_tensor[1, :, :], st_max_tensor[1, :, :]), s_0_tensor), lc_v_base_tensor
+ ),
+ ]
+ )
+ lc_tensor = torch.mul(okhsv_tensor[2, :, :], lc_v_tensor)
+ l_vt_tensor = _ok_l_from_lr_tensor(lc_v_tensor[0, :, :])
+ c_vt_tensor = torch.mul(lc_v_tensor[1, :, :], torch.div(l_vt_tensor, lc_v_tensor[0, :, :]))
+ l_new_tensor = _ok_l_from_lr_tensor(lc_tensor[0, :, :])
+ lc_tensor[1, :, :] = torch.mul(lc_tensor[1, :, :], torch.div(l_new_tensor, lc_tensor[0, :, :]))
+ lc_tensor[0, :, :] = l_new_tensor
+ rgb_scale_tensor = linear_srgb_from_oklab(
+ torch.stack(
+ [
+ l_vt_tensor,
+ torch.mul(units_ab_tensor[0, :, :], c_vt_tensor),
+ torch.mul(units_ab_tensor[1, :, :], c_vt_tensor),
+ ]
+ )
+ )
+ scale_l_tensor = torch.pow(
+ torch.div(
+ 1.0,
+ torch.max(
+ rgb_scale_tensor.max(0).values,
+ torch.zeros(rgb_scale_tensor.shape[1:], dtype=rgb_scale_tensor.dtype, device=rgb_scale_tensor.device),
+ ),
+ ),
+ 1.0 / 3.0,
+ )
+ lc_tensor = torch.mul(lc_tensor, scale_l_tensor.expand(lc_tensor.shape))
+ rgb_tensor = linear_srgb_from_oklab(
+ torch.stack(
+ [
+ lc_tensor[0, :, :],
+ torch.mul(units_ab_tensor[0, :, :], lc_tensor[1, :, :]),
+ torch.mul(units_ab_tensor[1, :, :], lc_tensor[1, :, :]),
+ ]
+ )
+ )
+ rgb_tensor = srgb_from_linear_srgb(gamut_clip_tensor(rgb_tensor, alpha=alpha, steps=steps))
+ return torch.where(torch.isnan(rgb_tensor), 0.0, rgb_tensor).clamp(0.0, 1.0)
+
+
+def okhsv_from_srgb(srgb_tensor: torch.Tensor, steps: int = 1) -> torch.Tensor:
+ """Convert a 3xHxW gamma-corrected sRGB tensor to Okhsv, with hue in degrees."""
+
+ srgb_tensor = _require_color_tensor(srgb_tensor)
+ lab_tensor = oklab_from_linear_srgb(linear_srgb_from_srgb(srgb_tensor))
+ c_tensor = torch.sqrt(torch.add(torch.pow(lab_tensor[1, :, :], 2.0), torch.pow(lab_tensor[2, :, :], 2.0)))
+ units_ab_tensor = torch.div(lab_tensor[1:, :, :], c_tensor)
+ h_tensor = torch.add(
+ torch.div(
+ torch.mul(torch.atan2(torch.mul(lab_tensor[2, :, :], -1.0), torch.mul(lab_tensor[1, :, :], -1.0)), 0.5), PI
+ ),
+ 0.5,
+ )
+ lc_cusps_tensor = _find_cusp_tensor(units_ab_tensor, steps=steps)
+ st_max_tensor = _st_cusps_from_lc(lc_cusps_tensor)
+ s_0_tensor = _full_like_spatial(st_max_tensor, 0.5)
+ k_tensor = torch.add(torch.mul(torch.div(s_0_tensor, st_max_tensor[0, :, :]), -1.0), 1)
+ t_tensor = torch.div(
+ st_max_tensor[1, :, :], torch.add(c_tensor, torch.mul(lab_tensor[0, :, :], st_max_tensor[1, :, :]))
+ )
+ l_v_tensor = torch.mul(t_tensor, lab_tensor[0, :, :])
+ c_v_tensor = torch.mul(t_tensor, c_tensor)
+ l_vt_tensor = _ok_l_from_lr_tensor(l_v_tensor)
+ c_vt_tensor = torch.mul(c_v_tensor, torch.div(l_vt_tensor, l_v_tensor))
+ rgb_scale_tensor = linear_srgb_from_oklab(
+ torch.stack(
+ [
+ l_vt_tensor,
+ torch.mul(units_ab_tensor[0, :, :], c_vt_tensor),
+ torch.mul(units_ab_tensor[1, :, :], c_vt_tensor),
+ ]
+ )
+ )
+ scale_l_tensor = torch.pow(
+ torch.div(
+ 1.0,
+ torch.max(
+ rgb_scale_tensor.max(0).values,
+ torch.zeros(rgb_scale_tensor.shape[1:], dtype=rgb_scale_tensor.dtype, device=rgb_scale_tensor.device),
+ ),
+ ),
+ 1.0 / 3.0,
+ )
+ lab_tensor[0, :, :] = torch.div(lab_tensor[0, :, :], scale_l_tensor)
+ c_tensor = torch.div(c_tensor, scale_l_tensor)
+ c_tensor = torch.mul(c_tensor, torch.div(_ok_l_r_from_l_tensor(lab_tensor[0, :, :]), lab_tensor[0, :, :]))
+ lab_tensor[0, :, :] = _ok_l_r_from_l_tensor(lab_tensor[0, :, :])
+ v_tensor = torch.div(lab_tensor[0, :, :], l_v_tensor)
+ s_tensor = torch.div(
+ torch.mul(torch.add(s_0_tensor, st_max_tensor[1, :, :]), c_v_tensor),
+ torch.add(
+ torch.mul(st_max_tensor[1, :, :], s_0_tensor),
+ torch.mul(st_max_tensor[1, :, :], torch.mul(k_tensor, c_v_tensor)),
+ ),
+ )
+ hsv_tensor = torch.stack([_degrees_from_unit_hue(h_tensor), s_tensor, v_tensor])
+ hsv_tensor = torch.where(torch.isnan(hsv_tensor), 0.0, hsv_tensor)
+ hsv_tensor[1:, ...] = hsv_tensor[1:, ...].clamp(0.0, 1.0)
+ return hsv_tensor
+
+
+def _get_st_mid_tensor(units_ab_tensor: torch.Tensor) -> torch.Tensor:
+ return torch.stack(
+ [
+ torch.add(
+ torch.div(
+ 1.0,
+ torch.add(
+ torch.add(
+ torch.mul(units_ab_tensor[1, :, :], 4.15901240),
+ torch.mul(
+ units_ab_tensor[0, :, :],
+ torch.add(
+ torch.add(
+ torch.mul(units_ab_tensor[1, :, :], 1.75198401),
+ torch.mul(
+ units_ab_tensor[0, :, :],
+ torch.add(
+ torch.add(
+ torch.mul(units_ab_tensor[1, :, :], -10.02301043),
+ torch.mul(
+ units_ab_tensor[0, :, :],
+ torch.add(
+ torch.add(
+ torch.mul(units_ab_tensor[1, :, :], 5.38770819),
+ torch.mul(units_ab_tensor[0, :, :], 4.69891013),
+ ),
+ -4.24894561,
+ ),
+ ),
+ ),
+ -2.13704948,
+ ),
+ ),
+ ),
+ -2.19557347,
+ ),
+ ),
+ ),
+ 7.44778970,
+ ),
+ ),
+ 0.11516993,
+ ),
+ torch.add(
+ torch.div(
+ 1.0,
+ torch.add(
+ torch.add(
+ torch.mul(units_ab_tensor[1, :, :], -0.68124379),
+ torch.mul(
+ units_ab_tensor[0, :, :],
+ torch.add(
+ torch.add(
+ torch.mul(units_ab_tensor[1, :, :], 0.90148123),
+ torch.mul(
+ units_ab_tensor[0, :, :],
+ torch.add(
+ torch.add(
+ torch.mul(units_ab_tensor[1, :, :], 0.61223990),
+ torch.mul(
+ units_ab_tensor[0, :, :],
+ torch.add(
+ torch.add(
+ torch.mul(units_ab_tensor[1, :, :], -0.45399568),
+ torch.mul(units_ab_tensor[0, :, :], -0.14661872),
+ ),
+ 0.00299215,
+ ),
+ ),
+ ),
+ -0.27087943,
+ ),
+ ),
+ ),
+ 0.40370612,
+ ),
+ ),
+ ),
+ 1.61320320,
+ ),
+ ),
+ 0.11239642,
+ ),
+ ]
+ )
+
+
+def _get_cs_tensor(
+ l_tensor: torch.Tensor, units_ab_tensor: torch.Tensor, steps: int = 1, steps_outer: int = 1
+) -> torch.Tensor:
+ lc_cusps_tensor = _find_cusp_tensor(units_ab_tensor, steps=steps)
+ c_max_tensor = _find_gamut_intersection_tensor(
+ units_ab_tensor,
+ l_tensor,
+ torch.ones(l_tensor.shape, dtype=l_tensor.dtype, device=l_tensor.device),
+ l_tensor,
+ lc_cusps_tensor=lc_cusps_tensor,
+ steps=steps,
+ steps_outer=steps_outer,
+ )
+ st_max_tensor = _st_cusps_from_lc(lc_cusps_tensor)
+ k_tensor = torch.div(
+ c_max_tensor,
+ torch.min(
+ torch.mul(l_tensor, st_max_tensor[0, :, :]),
+ torch.mul(torch.add(torch.mul(l_tensor, -1.0), 1.0), st_max_tensor[1, :, :]),
+ ),
+ )
+ st_mid_tensor = _get_st_mid_tensor(units_ab_tensor)
+ c_a_tensor = torch.mul(l_tensor, st_mid_tensor[0, :, :])
+ c_b_tensor = torch.mul(torch.add(torch.mul(l_tensor, -1.0), 1.0), st_mid_tensor[1, :, :])
+ c_mid_tensor = torch.mul(
+ torch.mul(
+ k_tensor,
+ torch.sqrt(
+ torch.sqrt(
+ torch.div(
+ 1.0,
+ torch.add(
+ torch.div(1.0, torch.pow(c_a_tensor, 4.0)), torch.div(1.0, torch.pow(c_b_tensor, 4.0))
+ ),
+ )
+ )
+ ),
+ ),
+ 0.9,
+ )
+ c_a_tensor = torch.mul(l_tensor, 0.4)
+ c_b_tensor = torch.mul(torch.add(torch.mul(l_tensor, -1.0), 1.0), 0.8)
+ c_0_tensor = torch.sqrt(
+ torch.div(
+ 1.0, torch.add(torch.div(1.0, torch.pow(c_a_tensor, 2.0)), torch.div(1.0, torch.pow(c_b_tensor, 2.0)))
+ )
+ )
+ return torch.stack([c_0_tensor, c_mid_tensor, c_max_tensor])
+
+
+def srgb_from_okhsl(
+ hsl_tensor: torch.Tensor, alpha: float = 0.05, steps: int = 1, steps_outer: int = 1
+) -> torch.Tensor:
+ """Convert a 3xHxW Okhsl tensor, with hue in degrees, to gamma-corrected sRGB."""
+
+ hsl_tensor = _require_color_tensor(hsl_tensor)
+ hsl_tensor = hsl_tensor.clone()
+ hsl_tensor[1:, ...] = hsl_tensor[1:, ...].clamp(0.0, 1.0)
+ l_ones_mask = torch.eq(hsl_tensor[2, :, :], 1.0)
+ l_zeros_mask = torch.eq(hsl_tensor[2, :, :], 0.0)
+ l_ones_mask = l_ones_mask.expand(hsl_tensor.shape)
+ l_zeros_mask = l_zeros_mask.expand(hsl_tensor.shape)
+ calc_rgb_mask = torch.logical_not(torch.logical_or(l_ones_mask, l_zeros_mask))
+ rgb_tensor = torch.empty_like(hsl_tensor)
+ rgb_tensor = torch.where(l_ones_mask, 1.0, torch.where(l_zeros_mask, 0.0, rgb_tensor))
+ unit_hue_tensor = _unit_hue_from_degrees(hsl_tensor[0, :, :])
+ units_ab_tensor = torch.stack(
+ [torch.cos(torch.mul(unit_hue_tensor, 2.0 * PI)), torch.sin(torch.mul(unit_hue_tensor, 2.0 * PI))]
+ )
+ l_tensor = _ok_l_from_lr_tensor(hsl_tensor[2, :, :])
+ cs_tensor = _get_cs_tensor(l_tensor, units_ab_tensor, steps=steps, steps_outer=steps_outer)
+ mid = 0.8
+ mid_inv = 1.25
+ s_lt_mid_mask = torch.lt(hsl_tensor[1, :, :], mid)
+ t_tensor = torch.where(
+ s_lt_mid_mask,
+ torch.mul(hsl_tensor[1, :, :], mid_inv),
+ torch.div(torch.sub(hsl_tensor[1, :, :], mid), 1.0 - mid),
+ )
+ k_1_tensor = torch.where(
+ s_lt_mid_mask,
+ torch.mul(cs_tensor[0, :, :], mid),
+ torch.div(
+ torch.mul(torch.mul(torch.pow(cs_tensor[1, :, :], 2.0), mid_inv**2.0), 1.0 - mid), cs_tensor[0, :, :]
+ ),
+ )
+ k_2_tensor = torch.where(
+ s_lt_mid_mask,
+ torch.add(torch.mul(torch.div(k_1_tensor, cs_tensor[1, :, :]), -1.0), 1.0),
+ torch.add(torch.mul(torch.div(k_1_tensor, torch.sub(cs_tensor[2, :, :], cs_tensor[1, :, :])), -1.0), 1.0),
+ )
+ c_tensor = torch.div(
+ torch.mul(t_tensor, k_1_tensor), torch.add(torch.mul(torch.mul(k_2_tensor, t_tensor), -1.0), 1.0)
+ )
+ c_tensor = torch.where(s_lt_mid_mask, c_tensor, torch.add(cs_tensor[1, :, :], c_tensor))
+ rgb_tensor = torch.where(
+ calc_rgb_mask,
+ linear_srgb_from_oklab(
+ torch.stack(
+ [l_tensor, torch.mul(c_tensor, units_ab_tensor[0, :, :]), torch.mul(c_tensor, units_ab_tensor[1, :, :])]
+ )
+ ),
+ rgb_tensor,
+ )
+ rgb_tensor = srgb_from_linear_srgb(gamut_clip_tensor(rgb_tensor, alpha=alpha, steps=steps, steps_outer=steps_outer))
+ return torch.where(torch.isnan(rgb_tensor), 0.0, rgb_tensor).clamp(0.0, 1.0)
+
+
+def okhsl_from_srgb(rgb_tensor: torch.Tensor, steps: int = 1, steps_outer: int = 1) -> torch.Tensor:
+ """Convert a 3xHxW gamma-corrected sRGB tensor to Okhsl, with hue in degrees."""
+
+ rgb_tensor = _require_color_tensor(rgb_tensor)
+ lab_tensor = oklab_from_linear_srgb(linear_srgb_from_srgb(rgb_tensor))
+ c_tensor = torch.sqrt(torch.add(torch.pow(lab_tensor[1, :, :], 2.0), torch.pow(lab_tensor[2, :, :], 2.0)))
+ units_ab_tensor = torch.stack([torch.div(lab_tensor[1, :, :], c_tensor), torch.div(lab_tensor[2, :, :], c_tensor)])
+ h_tensor = torch.add(
+ torch.div(
+ torch.mul(torch.atan2(torch.mul(lab_tensor[2, :, :], -1.0), torch.mul(lab_tensor[1, :, :], -1.0)), 0.5), PI
+ ),
+ 0.5,
+ )
+ cs_tensor = _get_cs_tensor(lab_tensor[0, :, :], units_ab_tensor, steps=steps, steps_outer=steps_outer)
+ mid = 0.8
+ mid_inv = 1.25
+ c_lt_c_mid_mask = torch.lt(c_tensor, cs_tensor[1, :, :])
+ k_1_tensor = torch.where(
+ c_lt_c_mid_mask,
+ torch.mul(cs_tensor[0, :, :], mid),
+ torch.div(torch.mul(torch.mul(torch.pow(cs_tensor[1, :, :], 2.0), mid_inv**2), 1.0 - mid), cs_tensor[0, :, :]),
+ )
+ k_2_tensor = torch.where(
+ c_lt_c_mid_mask,
+ torch.add(torch.mul(torch.div(k_1_tensor, cs_tensor[1, :, :]), -1.0), 1.0),
+ torch.add(torch.mul(torch.div(k_1_tensor, torch.sub(cs_tensor[2, :, :], cs_tensor[1, :, :])), -1.0), 1.0),
+ )
+ t_tensor = torch.where(
+ c_lt_c_mid_mask,
+ torch.div(c_tensor, torch.add(k_1_tensor, torch.mul(k_2_tensor, c_tensor))),
+ torch.div(
+ torch.sub(c_tensor, cs_tensor[1, :, :]),
+ torch.add(k_1_tensor, torch.mul(k_2_tensor, torch.sub(c_tensor, cs_tensor[1, :, :]))),
+ ),
+ )
+ s_tensor = torch.where(c_lt_c_mid_mask, torch.mul(t_tensor, mid), torch.add(torch.mul(t_tensor, 1.0 - mid), mid))
+ l_tensor = _ok_l_r_from_l_tensor(lab_tensor[0, :, :])
+ hsl_tensor = torch.stack([_degrees_from_unit_hue(h_tensor), s_tensor, l_tensor])
+ hsl_tensor = torch.where(torch.isnan(hsl_tensor), 0.0, hsl_tensor)
+ hsl_tensor[1:, ...] = hsl_tensor[1:, ...].clamp(0.0, 1.0)
+ return hsl_tensor
+
+
+def hsl_from_srgb(rgb_tensor: torch.Tensor) -> torch.Tensor:
+ """Convert a 3xHxW gamma-corrected sRGB tensor to HSL, with hue in degrees."""
+
+ rgb_tensor = _require_color_tensor(rgb_tensor)
+ c_max_tensor = rgb_tensor.max(0).values
+ c_min_tensor = rgb_tensor.min(0).values
+ c_sum_tensor = torch.add(c_max_tensor, c_min_tensor)
+ c_range_tensor = torch.sub(c_max_tensor, c_min_tensor)
+ l_tensor = torch.div(c_sum_tensor, 2.0)
+ s_tensor = torch.where(
+ torch.eq(c_max_tensor, c_min_tensor),
+ 0.0,
+ torch.where(
+ torch.lt(l_tensor, 0.5),
+ torch.div(c_range_tensor, c_sum_tensor),
+ torch.div(c_range_tensor, torch.add(torch.mul(torch.add(c_max_tensor, c_min_tensor), -1.0), 2.0)),
+ ),
+ )
+ rgb_c_tensor = torch.div(
+ torch.sub(c_max_tensor.expand(rgb_tensor.shape), rgb_tensor), c_range_tensor.expand(rgb_tensor.shape)
+ )
+ h_tensor = torch.where(
+ torch.eq(c_max_tensor, c_min_tensor),
+ 0.0,
+ torch.where(
+ torch.eq(rgb_tensor[0, :, :], c_max_tensor),
+ torch.sub(rgb_c_tensor[2, :, :], rgb_c_tensor[1, :, :]),
+ torch.where(
+ torch.eq(rgb_tensor[1, :, :], c_max_tensor),
+ torch.add(torch.sub(rgb_c_tensor[0, :, :], rgb_c_tensor[2, :, :]), 2.0),
+ torch.add(torch.sub(rgb_c_tensor[1, :, :], rgb_c_tensor[0, :, :]), 4.0),
+ ),
+ ),
+ )
+ h_tensor = _degrees_from_unit_hue(torch.remainder(torch.div(h_tensor, 6.0), 1.0))
+ return torch.stack([h_tensor, s_tensor, l_tensor])
+
+
+def srgb_from_hsl(hsl_tensor: torch.Tensor) -> torch.Tensor:
+ """Convert a 3xHxW HSL tensor, with hue in degrees, to gamma-corrected sRGB."""
+
+ hsl_tensor = _require_color_tensor(hsl_tensor)
+ hsl_tensor = hsl_tensor.clone()
+ hsl_tensor[1:, ...] = hsl_tensor[1:, ...].clamp(0.0, 1.0)
+ rgb_tensor = torch.empty_like(hsl_tensor)
+ s_0_mask = torch.eq(hsl_tensor[1, :, :], 0.0)
+ rgb_tensor = torch.where(
+ s_0_mask.expand(rgb_tensor.shape), hsl_tensor[2, :, :].expand(hsl_tensor.shape), rgb_tensor
+ )
+ m2_tensor = torch.where(
+ torch.le(hsl_tensor[2, :, :], 0.5),
+ torch.mul(hsl_tensor[2, :, :], torch.add(hsl_tensor[1, :, :], 1.0)),
+ torch.sub(
+ torch.add(hsl_tensor[2, :, :], hsl_tensor[1, :, :]), torch.mul(hsl_tensor[2, :, :], hsl_tensor[1, :, :])
+ ),
+ )
+ m1_tensor = torch.sub(torch.mul(hsl_tensor[2, :, :], 2.0), m2_tensor)
+ unit_hue_tensor = _unit_hue_from_degrees(hsl_tensor[0, :, :])
+
+ def hsl_values(m1_tensor: torch.Tensor, m2_tensor: torch.Tensor, h_tensor: torch.Tensor) -> torch.Tensor:
+ h_tensor = torch.remainder(h_tensor, 1.0)
+ result_tensor = m1_tensor.clone()
+ return torch.where(
+ torch.lt(h_tensor, 1.0 / 6.0),
+ torch.add(m1_tensor, torch.mul(torch.sub(m2_tensor, m1_tensor), torch.mul(h_tensor, 6.0))),
+ torch.where(
+ torch.lt(h_tensor, 0.5),
+ m2_tensor,
+ torch.where(
+ torch.lt(h_tensor, 2.0 / 3.0),
+ torch.add(
+ m1_tensor,
+ torch.mul(
+ torch.sub(m2_tensor, m1_tensor),
+ torch.mul(torch.add(torch.mul(h_tensor, -1.0), 2.0 / 3.0), 6.0),
+ ),
+ ),
+ result_tensor,
+ ),
+ ),
+ )
+
+ return torch.stack(
+ [
+ hsl_values(m1_tensor, m2_tensor, torch.add(unit_hue_tensor, 1.0 / 3.0)),
+ hsl_values(m1_tensor, m2_tensor, unit_hue_tensor),
+ hsl_values(m1_tensor, m2_tensor, torch.sub(unit_hue_tensor, 1.0 / 3.0)),
+ ]
+ )
+
+
+def hsl_from_linear_srgb(linear_srgb_tensor: torch.Tensor) -> torch.Tensor:
+ """Convert a 3xHxW linear-light sRGB tensor directly to HSL, with hue in degrees."""
+
+ linear_srgb_tensor = _require_color_tensor(linear_srgb_tensor)
+ return hsl_from_srgb(srgb_from_linear_srgb(linear_srgb_tensor))
+
+
+def linear_srgb_from_hsl(hsl_tensor: torch.Tensor) -> torch.Tensor:
+ """Convert a 3xHxW HSL tensor, with hue in degrees, directly to linear-light sRGB."""
+
+ hsl_tensor = _require_color_tensor(hsl_tensor)
+ return linear_srgb_from_srgb(srgb_from_hsl(hsl_tensor))
diff --git a/invokeai/backend/image_util/composition.py b/invokeai/backend/image_util/composition.py
index 4e7b4fbfe8..36911eb322 100644
--- a/invokeai/backend/image_util/composition.py
+++ b/invokeai/backend/image_util/composition.py
@@ -9,11 +9,16 @@
# HSL code based on CPython: Copyright (c) 2001-2023 Python Software Foundation; All Rights Reserved
from math import pi as PI
from pathlib import Path
-from typing import Literal, Optional
import torch
from PIL import Image
+from invokeai.backend.image_util.color_conversion import (
+ gamut_clip_tensor,
+)
+from invokeai.backend.image_util.color_conversion import (
+ srgb_from_linear_srgb as shared_srgb_from_linear_srgb,
+)
from invokeai.backend.stable_diffusion.diffusers_pipeline import image_resized_to_grid_as_tensor
MAX_FLOAT = torch.finfo(torch.tensor(1.0).dtype).max
@@ -60,910 +65,7 @@ def srgb_from_linear_srgb(linear_srgb_tensor: torch.Tensor, alpha: float = 0.0,
if 0.0 < alpha:
linear_srgb_tensor = gamut_clip_tensor(linear_srgb_tensor, alpha=alpha, steps=steps)
- linear_srgb_tensor = linear_srgb_tensor.clamp(0.0, 1.0)
- mask = torch.lt(linear_srgb_tensor, 0.0404482362771082 / 12.92)
- rgb_tensor = torch.sub(torch.mul(torch.pow(linear_srgb_tensor, (1 / 2.4)), 1.055), 0.055)
- rgb_tensor[mask] = torch.mul(linear_srgb_tensor[mask], 12.92)
-
- return rgb_tensor
-
-
-def linear_srgb_from_srgb(srgb_tensor: torch.Tensor):
- """Get linear-light sRGB from a standard gamma-corrected sRGB image tensor"""
-
- linear_srgb_tensor = torch.pow(torch.div(torch.add(srgb_tensor, 0.055), 1.055), 2.4)
- linear_srgb_tensor_1 = torch.div(srgb_tensor, 12.92)
- mask = torch.le(srgb_tensor, 0.0404482362771082)
- linear_srgb_tensor[mask] = linear_srgb_tensor_1[mask]
-
- return linear_srgb_tensor
-
-
-def max_srgb_saturation_tensor(units_ab_tensor: torch.Tensor, steps: int = 1):
- """Compute maximum sRGB saturation of a tensor of Oklab ab unit vectors"""
-
- rgb_k_matrix = torch.tensor(
- [
- [1.19086277, 1.76576728, 0.59662641, 0.75515197, 0.56771245],
- [0.73956515, -0.45954494, 0.08285427, 0.12541070, 0.14503204],
- [1.35733652, -0.00915799, -1.15130210, -0.50559606, 0.00692167],
- ]
- )
-
- rgb_w_matrix = torch.tensor(
- [
- [4.0767416621, -3.3077115913, 0.2309699292],
- [-1.2684380046, 2.6097574011, -0.3413193965],
- [-0.0041960863, -0.7034186147, 1.7076147010],
- ]
- )
-
- cond_r_tensor = torch.add(
- torch.mul(-1.88170328, units_ab_tensor[0, :, :]), torch.mul(-0.80936493, units_ab_tensor[1, :, :])
- )
- cond_g_tensor = torch.add(
- torch.mul(1.81444104, units_ab_tensor[0, :, :]), torch.mul(-1.19445276, units_ab_tensor[1, :, :])
- )
-
- terms_tensor = torch.stack(
- [
- torch.ones(units_ab_tensor.shape[1:]),
- units_ab_tensor[0, :, :],
- units_ab_tensor[1, :, :],
- torch.pow(units_ab_tensor[0, :, :], 2.0),
- torch.mul(units_ab_tensor[0, :, :], units_ab_tensor[1, :, :]),
- ]
- )
-
- s_tensor = torch.empty(units_ab_tensor.shape[1:])
- s_tensor = torch.where(
- torch.gt(cond_r_tensor, 1.0),
- torch.einsum("twh, t -> wh", terms_tensor, rgb_k_matrix[0]),
- torch.where(
- torch.gt(cond_g_tensor, 1.0),
- torch.einsum("twh, t -> wh", terms_tensor, rgb_k_matrix[1]),
- torch.einsum("twh, t -> wh", terms_tensor, rgb_k_matrix[2]),
- ),
- )
-
- k_lms_matrix = torch.tensor(
- [[0.3963377774, 0.2158037573], [-0.1055613458, -0.0638541728], [-0.0894841775, -1.2914855480]]
- )
-
- k_lms_tensor = torch.einsum("tc, cwh -> twh", k_lms_matrix, units_ab_tensor)
-
- for _ in range(steps):
- root_lms_tensor = torch.add(torch.mul(k_lms_tensor, s_tensor), 1.0)
- lms_tensor = torch.pow(root_lms_tensor, 3.0)
- lms_ds_tensor = torch.mul(torch.mul(k_lms_tensor, torch.pow(root_lms_tensor, 2.0)), 3.0)
- lms_ds2_tensor = torch.mul(torch.mul(torch.pow(k_lms_tensor, 2.0), root_lms_tensor), 6.0)
- f_tensor = torch.where(
- torch.gt(cond_r_tensor, 1.0),
- torch.einsum("c, cwh -> wh", rgb_w_matrix[0], lms_tensor),
- torch.where(
- torch.gt(cond_g_tensor, 1.0),
- torch.einsum("c, cwh -> wh", rgb_w_matrix[1], lms_tensor),
- torch.einsum("c, cwh -> wh", rgb_w_matrix[2], lms_tensor),
- ),
- )
- f_tensor_1 = torch.where(
- torch.gt(cond_r_tensor, 1.0),
- torch.einsum("c, cwh -> wh", rgb_w_matrix[0], lms_ds_tensor),
- torch.where(
- torch.gt(cond_g_tensor, 1.0),
- torch.einsum("c, cwh -> wh", rgb_w_matrix[1], lms_ds_tensor),
- torch.einsum("c, cwh -> wh", rgb_w_matrix[2], lms_ds_tensor),
- ),
- )
- f_tensor_2 = torch.where(
- torch.gt(cond_r_tensor, 1.0),
- torch.einsum("c, cwh -> wh", rgb_w_matrix[0], lms_ds2_tensor),
- torch.where(
- torch.gt(cond_g_tensor, 1.0),
- torch.einsum("c, cwh -> wh", rgb_w_matrix[1], lms_ds2_tensor),
- torch.einsum("c, cwh -> wh", rgb_w_matrix[2], lms_ds2_tensor),
- ),
- )
- s_tensor = torch.sub(
- s_tensor,
- torch.div(
- torch.mul(f_tensor, f_tensor_1),
- torch.sub(torch.pow(f_tensor_1, 2.0), torch.mul(torch.mul(f_tensor, f_tensor_2), 0.5)),
- ),
- )
-
- return s_tensor
-
-
-def linear_srgb_from_oklab(oklab_tensor: torch.Tensor):
- """Get linear-light sRGB from an Oklab image tensor"""
-
- # L*a*b* to LMS
- lms_matrix_1 = torch.tensor(
- [[1.0, 0.3963377774, 0.2158037573], [1.0, -0.1055613458, -0.0638541728], [1.0, -0.0894841775, -1.2914855480]]
- )
-
- lms_tensor_1 = torch.einsum("lwh, kl -> kwh", oklab_tensor, lms_matrix_1)
- lms_tensor = torch.pow(lms_tensor_1, 3.0)
-
- # LMS to linear RGB
- rgb_matrix = torch.tensor(
- [
- [4.0767416621, -3.3077115913, 0.2309699292],
- [-1.2684380046, 2.6097574011, -0.3413193965],
- [-0.0041960863, -0.7034186147, 1.7076147010],
- ]
- )
-
- linear_srgb_tensor = torch.einsum("kwh, sk -> swh", lms_tensor, rgb_matrix)
-
- return linear_srgb_tensor
-
-
-def oklab_from_linear_srgb(linear_srgb_tensor: torch.Tensor):
- """Get an Oklab image tensor from a tensor of linear-light sRGB"""
- # linear RGB to LMS
- lms_matrix = torch.tensor(
- [
- [0.4122214708, 0.5363325363, 0.0514459929],
- [0.2119034982, 0.6806995451, 0.1073969566],
- [0.0883024619, 0.2817188376, 0.6299787005],
- ]
- )
-
- lms_tensor = torch.einsum("cwh, kc -> kwh", linear_srgb_tensor, lms_matrix)
-
- # LMS to L*a*b*
- lms_tensor_neg_mask = torch.lt(lms_tensor, 0.0)
- lms_tensor[lms_tensor_neg_mask] = torch.mul(lms_tensor[lms_tensor_neg_mask], -1.0)
- lms_tensor_1 = torch.pow(lms_tensor, 1.0 / 3.0)
- lms_tensor[lms_tensor_neg_mask] = torch.mul(lms_tensor[lms_tensor_neg_mask], -1.0)
- lms_tensor_1[lms_tensor_neg_mask] = torch.mul(lms_tensor_1[lms_tensor_neg_mask], -1.0)
- lab_matrix = torch.tensor(
- [
- [0.2104542553, 0.7936177850, -0.0040720468],
- [1.9779984951, -2.4285922050, 0.4505937099],
- [0.0259040371, 0.7827717662, -0.8086757660],
- ]
- )
-
- lab_tensor = torch.einsum("kwh, lk -> lwh", lms_tensor_1, lab_matrix)
-
- return lab_tensor
-
-
-def find_cusp_tensor(units_ab_tensor: torch.Tensor, steps: int = 1):
- """Compute maximum sRGB lightness and chroma from a tensor of Oklab ab unit vectors"""
-
- s_cusp_tensor = max_srgb_saturation_tensor(units_ab_tensor, steps=steps)
-
- oklab_tensor = torch.stack(
- [
- torch.ones(s_cusp_tensor.shape),
- torch.mul(s_cusp_tensor, units_ab_tensor[0, :, :]),
- torch.mul(s_cusp_tensor, units_ab_tensor[1, :, :]),
- ]
- )
-
- rgb_at_max_tensor = linear_srgb_from_oklab(oklab_tensor)
-
- l_cusp_tensor = torch.pow(torch.div(1.0, rgb_at_max_tensor.max(0).values), 1.0 / 3.0)
- c_cusp_tensor = torch.mul(l_cusp_tensor, s_cusp_tensor)
-
- return torch.stack([l_cusp_tensor, c_cusp_tensor])
-
-
-def find_gamut_intersection_tensor(
- units_ab_tensor: torch.Tensor,
- l_1_tensor: torch.Tensor,
- c_1_tensor: torch.Tensor,
- l_0_tensor: torch.Tensor,
- steps: int = 1,
- steps_outer: int = 1,
- lc_cusps_tensor: Optional[torch.Tensor] = None,
-):
- """Find thresholds of lightness intersecting RGB gamut from Oklab component tensors"""
-
- if lc_cusps_tensor is None:
- lc_cusps_tensor = find_cusp_tensor(units_ab_tensor, steps=steps)
-
- # if (((l_1 - l_0) * c_cusp -
- # (l_cusp - l_0) * c_1) <= 0.):
- cond_tensor = torch.sub(
- torch.mul(torch.sub(l_1_tensor, l_0_tensor), lc_cusps_tensor[1, :, :]),
- torch.mul(torch.sub(lc_cusps_tensor[0, :, :], l_0_tensor), c_1_tensor),
- )
-
- t_tensor = torch.where(
- torch.le(cond_tensor, 0.0), # cond <= 0
- # t = (c_cusp * l_0) /
- # ((c_1 * l_cusp) + (c_cusp * (l_0 - l_1)))
- torch.div(
- torch.mul(lc_cusps_tensor[1, :, :], l_0_tensor),
- torch.add(
- torch.mul(c_1_tensor, lc_cusps_tensor[0, :, :]),
- torch.mul(lc_cusps_tensor[1, :, :], torch.sub(l_0_tensor, l_1_tensor)),
- ),
- ),
- # t = (c_cusp * (l_0-1.)) /
- # ((c_1 * (l_cusp-1.)) + (c_cusp * (l_0 - l_1)))
- torch.div(
- torch.mul(lc_cusps_tensor[1, :, :], torch.sub(l_0_tensor, 1.0)),
- torch.add(
- torch.mul(c_1_tensor, torch.sub(lc_cusps_tensor[0, :, :], 1.0)),
- torch.mul(lc_cusps_tensor[1, :, :], torch.sub(l_0_tensor, l_1_tensor)),
- ),
- ),
- )
-
- for _ in range(steps_outer):
- dl_tensor = torch.sub(l_1_tensor, l_0_tensor)
- dc_tensor = c_1_tensor
-
- k_lms_matrix = torch.tensor(
- [[0.3963377774, 0.2158037573], [-0.1055613458, -0.0638541728], [-0.0894841775, -1.2914855480]]
- )
- k_lms_tensor = torch.einsum("tc, cwh -> twh", k_lms_matrix, units_ab_tensor)
-
- lms_dt_tensor = torch.add(torch.mul(k_lms_tensor, dc_tensor), dl_tensor)
-
- for _ in range(steps):
- l_tensor = torch.add(
- torch.mul(l_0_tensor, torch.add(torch.mul(t_tensor, -1.0), 1.0)), torch.mul(t_tensor, l_1_tensor)
- )
- c_tensor = torch.mul(t_tensor, c_1_tensor)
-
- root_lms_tensor = torch.add(torch.mul(k_lms_tensor, c_tensor), l_tensor)
-
- lms_tensor = torch.pow(root_lms_tensor, 3.0)
- lms_dt_tensor_1 = torch.mul(torch.mul(torch.pow(root_lms_tensor, 2.0), lms_dt_tensor), 3.0)
- lms_dt2_tensor = torch.mul(torch.mul(torch.pow(lms_dt_tensor, 2.0), root_lms_tensor), 6.0)
-
- rgb_matrix = torch.tensor(
- [
- [4.0767416621, -3.3077115913, 0.2309699292],
- [-1.2684380046, 2.6097574011, -0.3413193965],
- [-0.0041960863, -0.7034186147, 1.7076147010],
- ]
- )
-
- rgb_tensor = torch.sub(torch.einsum("qt, twh -> qwh", rgb_matrix, lms_tensor), 1.0)
- rgb_tensor_1 = torch.einsum("qt, twh -> qwh", rgb_matrix, lms_dt_tensor_1)
- rgb_tensor_2 = torch.einsum("qt, twh -> qwh", rgb_matrix, lms_dt2_tensor)
-
- u_rgb_tensor = torch.div(
- rgb_tensor_1,
- torch.sub(torch.pow(rgb_tensor_1, 2.0), torch.mul(torch.mul(rgb_tensor, rgb_tensor_2), 0.5)),
- )
-
- t_rgb_tensor = torch.mul(torch.mul(rgb_tensor, -1.0), u_rgb_tensor)
-
- max_floats = torch.mul(MAX_FLOAT, torch.ones(t_rgb_tensor.shape))
-
- t_rgb_tensor = torch.where(torch.lt(u_rgb_tensor, 0.0), max_floats, t_rgb_tensor)
-
- t_tensor = torch.where(
- torch.gt(cond_tensor, 0.0), torch.add(t_tensor, t_rgb_tensor.min(0).values), t_tensor
- )
-
- return t_tensor
-
-
-def gamut_clip_tensor(rgb_l_tensor: torch.Tensor, alpha: float = 0.05, steps: int = 1, steps_outer: int = 1):
- """Adaptively compress out-of-gamut linear-light sRGB image tensor colors into gamut"""
-
- lab_tensor = oklab_from_linear_srgb(rgb_l_tensor)
- epsilon = 0.00001
- chroma_tensor = torch.sqrt(torch.add(torch.pow(lab_tensor[1, :, :], 2.0), torch.pow(lab_tensor[2, :, :], 2.0)))
- chroma_tensor = torch.where(torch.lt(chroma_tensor, epsilon), epsilon, chroma_tensor)
-
- units_ab_tensor = torch.div(lab_tensor[1:, :, :], chroma_tensor)
-
- l_d_tensor = torch.sub(lab_tensor[0], 0.5)
- e_1_tensor = torch.add(torch.add(torch.abs(l_d_tensor), torch.mul(chroma_tensor, alpha)), 0.5)
- l_0_tensor = torch.mul(
- torch.add(
- torch.mul(
- torch.sign(l_d_tensor),
- torch.sub(
- e_1_tensor, torch.sqrt(torch.sub(torch.pow(e_1_tensor, 2.0), torch.mul(torch.abs(l_d_tensor), 2.0)))
- ),
- ),
- 1.0,
- ),
- 0.5,
- )
-
- t_tensor = find_gamut_intersection_tensor(
- units_ab_tensor, lab_tensor[0, :, :], chroma_tensor, l_0_tensor, steps=steps, steps_outer=steps_outer
- )
- l_clipped_tensor = torch.add(
- torch.mul(l_0_tensor, torch.add(torch.mul(t_tensor, -1), 1.0)), torch.mul(t_tensor, lab_tensor[0, :, :])
- )
- c_clipped_tensor = torch.mul(t_tensor, chroma_tensor)
-
- return torch.where(
- torch.logical_or(torch.gt(rgb_l_tensor.max(0).values, 1.0), torch.lt(rgb_l_tensor.min(0).values, 0.0)),
- linear_srgb_from_oklab(
- torch.stack(
- [
- l_clipped_tensor,
- torch.mul(c_clipped_tensor, units_ab_tensor[0, :, :]),
- torch.mul(c_clipped_tensor, units_ab_tensor[1, :, :]),
- ]
- )
- ),
- rgb_l_tensor,
- )
-
-
-def st_cusps_from_lc(lc_cusps_tensor: torch.Tensor):
- """Alternative cusp representation with max C as min(S*L, T*(1-L))"""
-
- return torch.stack(
- [
- torch.div(lc_cusps_tensor[1, :, :], lc_cusps_tensor[0, :, :]),
- torch.div(lc_cusps_tensor[1, :, :], torch.add(torch.mul(lc_cusps_tensor[0, :, :], -1.0), 1)),
- ]
- )
-
-
-def ok_l_r_from_l_tensor(x_tensor: torch.Tensor):
- """Lightness compensated (Y=1) estimate of lightness in Oklab space"""
-
- k_1 = 0.206
- k_2 = 0.03
- k_3 = (1.0 + k_1) / (1.0 + k_2)
- # 0.5f * (k_3 * x - k_1 + sqrtf((k_3 * x - k_1) * (k_3 * x - k_1) + 4 * k_2 * k_3 * x));
-
- return torch.mul(
- torch.add(
- torch.sub(torch.mul(x_tensor, k_3), k_1),
- torch.sqrt(
- torch.add(
- torch.pow(torch.sub(torch.mul(x_tensor, k_3), k_1), 2.0),
- torch.mul(torch.mul(torch.mul(x_tensor, k_3), k_2), 4.0),
- )
- ),
- ),
- 0.5,
- )
-
-
-def ok_l_from_lr_tensor(x_tensor: torch.Tensor):
- """Get uncompensated Oklab lightness from the lightness compensated version"""
-
- k_1 = 0.206
- k_2 = 0.03
- k_3 = (1.0 + k_1) / (1.0 + k_2)
-
- # (x * x + k_1 * x) / (k_3 * (x + k_2))
- return torch.div(
- torch.add(torch.pow(x_tensor, 2.0), torch.mul(x_tensor, k_1)), torch.mul(torch.add(x_tensor, k_2), k_3)
- )
-
-
-def srgb_from_okhsv(okhsv_tensor: torch.Tensor, alpha: float = 0.05, steps: int = 1):
- """Get standard gamma-corrected sRGB from an Okhsv image tensor"""
-
- okhsv_tensor = okhsv_tensor.clamp(0.0, 1.0)
-
- units_ab_tensor = torch.stack(
- [torch.cos(torch.mul(okhsv_tensor[0, :, :], 2.0 * PI)), torch.sin(torch.mul(okhsv_tensor[0, :, :], 2.0 * PI))]
- )
- lc_cusps_tensor = find_cusp_tensor(units_ab_tensor, steps=steps)
- st_max_tensor = st_cusps_from_lc(lc_cusps_tensor)
- s_0_tensor = torch.tensor(0.5).expand(st_max_tensor.shape[1:])
- k_tensor = torch.add(torch.mul(torch.div(s_0_tensor, st_max_tensor[0, :, :]), -1.0), 1)
-
- # First compute L and V assuming a perfect triangular gamut
- lc_v_base_tensor = torch.add(
- s_0_tensor,
- torch.sub(
- st_max_tensor[1, :, :], torch.mul(st_max_tensor[1, :, :], torch.mul(k_tensor, okhsv_tensor[1, :, :]))
- ),
- )
- lc_v_tensor = torch.stack(
- [
- torch.add(torch.div(torch.mul(torch.mul(okhsv_tensor[1, :, :], s_0_tensor), -1.0), lc_v_base_tensor), 1.0),
- torch.div(
- torch.mul(torch.mul(okhsv_tensor[1, :, :], st_max_tensor[1, :, :]), s_0_tensor), lc_v_base_tensor
- ),
- ]
- )
-
- lc_tensor = torch.mul(okhsv_tensor[2, :, :], lc_v_tensor)
-
- l_vt_tensor = ok_l_from_lr_tensor(lc_v_tensor[0, :, :])
- c_vt_tensor = torch.mul(lc_v_tensor[1, :, :], torch.div(l_vt_tensor, lc_v_tensor[0, :, :]))
-
- l_new_tensor = ok_l_from_lr_tensor(lc_tensor[0, :, :])
- lc_tensor[1, :, :] = torch.mul(lc_tensor[1, :, :], torch.div(l_new_tensor, lc_tensor[0, :, :]))
- lc_tensor[0, :, :] = l_new_tensor
-
- rgb_scale_tensor = linear_srgb_from_oklab(
- torch.stack(
- [
- l_vt_tensor,
- torch.mul(units_ab_tensor[0, :, :], c_vt_tensor),
- torch.mul(units_ab_tensor[1, :, :], c_vt_tensor),
- ]
- )
- )
-
- scale_l_tensor = torch.pow(
- torch.div(1.0, torch.max(rgb_scale_tensor.max(0).values, torch.zeros(rgb_scale_tensor.shape[1:]))), 1.0 / 3.0
- )
- lc_tensor = torch.mul(lc_tensor, scale_l_tensor.expand(lc_tensor.shape))
-
- rgb_tensor = linear_srgb_from_oklab(
- torch.stack(
- [
- lc_tensor[0, :, :],
- torch.mul(units_ab_tensor[0, :, :], lc_tensor[1, :, :]),
- torch.mul(units_ab_tensor[1, :, :], lc_tensor[1, :, :]),
- ]
- )
- )
-
- rgb_tensor = srgb_from_linear_srgb(rgb_tensor, alpha=alpha, steps=steps)
- return torch.where(torch.isnan(rgb_tensor), 0.0, rgb_tensor).clamp(0.0, 1.0)
-
-
-def okhsv_from_srgb(srgb_tensor: torch.Tensor, steps: int = 1):
- """Get Okhsv image tensor from standard gamma-corrected sRGB"""
-
- lab_tensor = oklab_from_linear_srgb(linear_srgb_from_srgb(srgb_tensor))
-
- c_tensor = torch.sqrt(torch.add(torch.pow(lab_tensor[1, :, :], 2.0), torch.pow(lab_tensor[2, :, :], 2.0)))
- units_ab_tensor = torch.div(lab_tensor[1:, :, :], c_tensor)
-
- h_tensor = torch.add(
- torch.div(
- torch.mul(
- torch.atan2(
- torch.mul(lab_tensor[2, :, :], -1.0),
- torch.mul(
- lab_tensor[1, :, :],
- -1,
- ),
- ),
- 0.5,
- ),
- PI,
- ),
- 0.5,
- )
-
- lc_cusps_tensor = find_cusp_tensor(units_ab_tensor, steps=steps)
- st_max_tensor = st_cusps_from_lc(lc_cusps_tensor)
- s_0_tensor = torch.tensor(0.5).expand(st_max_tensor.shape[1:])
- k_tensor = torch.add(torch.mul(torch.div(s_0_tensor, st_max_tensor[0, :, :]), -1.0), 1)
-
- t_tensor = torch.div(
- st_max_tensor[1, :, :], torch.add(c_tensor, torch.mul(lab_tensor[0, :, :], st_max_tensor[1, :, :]))
- )
-
- l_v_tensor = torch.mul(t_tensor, lab_tensor[0, :, :])
- c_v_tensor = torch.mul(t_tensor, c_tensor)
-
- l_vt_tensor = ok_l_from_lr_tensor(l_v_tensor)
- c_vt_tensor = torch.mul(c_v_tensor, torch.div(l_vt_tensor, l_v_tensor))
-
- rgb_scale_tensor = linear_srgb_from_oklab(
- torch.stack(
- [
- l_vt_tensor,
- torch.mul(units_ab_tensor[0, :, :], c_vt_tensor),
- torch.mul(units_ab_tensor[1, :, :], c_vt_tensor),
- ]
- )
- )
-
- scale_l_tensor = torch.pow(
- torch.div(1.0, torch.max(rgb_scale_tensor.max(0).values, torch.zeros(rgb_scale_tensor.shape[1:]))), 1.0 / 3.0
- )
-
- lab_tensor[0, :, :] = torch.div(lab_tensor[0, :, :], scale_l_tensor)
- c_tensor = torch.div(c_tensor, scale_l_tensor)
-
- c_tensor = torch.mul(c_tensor, torch.div(ok_l_r_from_l_tensor(lab_tensor[0, :, :]), lab_tensor[0, :, :]))
- lab_tensor[0, :, :] = ok_l_r_from_l_tensor(lab_tensor[0, :, :])
-
- v_tensor = torch.div(lab_tensor[0, :, :], l_v_tensor)
- s_tensor = torch.div(
- torch.mul(torch.add(s_0_tensor, st_max_tensor[1, :, :]), c_v_tensor),
- torch.add(
- torch.mul(st_max_tensor[1, :, :], s_0_tensor),
- torch.mul(st_max_tensor[1, :, :], torch.mul(k_tensor, c_v_tensor)),
- ),
- )
-
- hsv_tensor = torch.stack([h_tensor, s_tensor, v_tensor])
- return torch.where(torch.isnan(hsv_tensor), 0.0, hsv_tensor).clamp(0.0, 1.0)
-
-
-def get_st_mid_tensor(units_ab_tensor: torch.Tensor):
- """Returns a smooth approximation of cusp, where st_mid < st_max"""
-
- return torch.stack(
- [
- torch.add(
- torch.div(
- 1.0,
- torch.add(
- torch.add(
- torch.mul(units_ab_tensor[1, :, :], 4.15901240),
- torch.mul(
- units_ab_tensor[0, :, :],
- torch.add(
- torch.add(
- torch.mul(units_ab_tensor[1, :, :], 1.75198401),
- torch.mul(
- units_ab_tensor[0, :, :],
- torch.add(
- torch.add(
- torch.mul(units_ab_tensor[1, :, :], -10.02301043),
- torch.mul(
- units_ab_tensor[0, :, :],
- torch.add(
- torch.add(
- torch.mul(units_ab_tensor[1, :, :], 5.38770819),
- torch.mul(units_ab_tensor[0, :, :], 4.69891013),
- ),
- -4.24894561,
- ),
- ),
- ),
- -2.13704948,
- ),
- ),
- ),
- -2.19557347,
- ),
- ),
- ),
- 7.44778970,
- ),
- ),
- 0.11516993,
- ),
- torch.add(
- torch.div(
- 1.0,
- torch.add(
- torch.add(
- torch.mul(units_ab_tensor[1, :, :], -0.68124379),
- torch.mul(
- units_ab_tensor[0, :, :],
- torch.add(
- torch.add(
- torch.mul(units_ab_tensor[1, :, :], 0.90148123),
- torch.mul(
- units_ab_tensor[0, :, :],
- torch.add(
- torch.add(
- torch.mul(units_ab_tensor[1, :, :], 0.61223990),
- torch.mul(
- units_ab_tensor[0, :, :],
- torch.add(
- torch.add(
- torch.mul(units_ab_tensor[1, :, :], -0.45399568),
- torch.mul(units_ab_tensor[0, :, :], -0.14661872),
- ),
- 0.00299215,
- ),
- ),
- ),
- -0.27087943,
- ),
- ),
- ),
- 0.40370612,
- ),
- ),
- ),
- 1.61320320,
- ),
- ),
- 0.11239642,
- ),
- ]
- )
-
-
-def get_cs_tensor(
- l_tensor: torch.Tensor, units_ab_tensor: torch.Tensor, steps: int = 1, steps_outer: int = 1
-): # -> [C_0, C_mid, C_max]
- """Arrange minimum, midpoint, and max chroma values from tensors of luminance and ab unit vectors"""
-
- lc_cusps_tensor = find_cusp_tensor(units_ab_tensor, steps=steps)
-
- c_max_tensor = find_gamut_intersection_tensor(
- units_ab_tensor,
- l_tensor,
- torch.ones(l_tensor.shape),
- l_tensor,
- lc_cusps_tensor=lc_cusps_tensor,
- steps=steps,
- steps_outer=steps_outer,
- )
- st_max_tensor = st_cusps_from_lc(lc_cusps_tensor)
-
- k_tensor = torch.div(
- c_max_tensor,
- torch.min(
- torch.mul(l_tensor, st_max_tensor[0, :, :]),
- torch.mul(torch.add(torch.mul(l_tensor, -1.0), 1.0), st_max_tensor[1, :, :]),
- ),
- )
-
- st_mid_tensor = get_st_mid_tensor(units_ab_tensor)
- c_a_tensor = torch.mul(l_tensor, st_mid_tensor[0, :, :])
- c_b_tensor = torch.mul(torch.add(torch.mul(l_tensor, -1.0), 1.0), st_mid_tensor[1, :, :])
- c_mid_tensor = torch.mul(
- torch.mul(
- k_tensor,
- torch.sqrt(
- torch.sqrt(
- torch.div(
- 1.0,
- torch.add(
- torch.div(1.0, torch.pow(c_a_tensor, 4.0)), torch.div(1.0, torch.pow(c_b_tensor, 4.0))
- ),
- )
- )
- ),
- ),
- 0.9,
- )
-
- c_a_tensor = torch.mul(l_tensor, 0.4)
- c_b_tensor = torch.mul(torch.add(torch.mul(l_tensor, -1.0), 1.0), 0.8)
- c_0_tensor = torch.sqrt(
- torch.div(
- 1.0, torch.add(torch.div(1.0, torch.pow(c_a_tensor, 2.0)), torch.div(1.0, torch.pow(c_b_tensor, 2.0)))
- )
- )
-
- return torch.stack([c_0_tensor, c_mid_tensor, c_max_tensor])
-
-
-def srgb_from_okhsl(hsl_tensor: torch.Tensor, alpha: float = 0.05, steps: int = 1, steps_outer: int = 1):
- """Get gamma-corrected sRGB from an Okhsl image tensor"""
-
- hsl_tensor = hsl_tensor.clamp(0.0, 1.0)
-
- l_ones_mask = torch.eq(hsl_tensor[2, :, :], 1.0)
- l_zeros_mask = torch.eq(hsl_tensor[2, :, :], 0.0)
- l_ones_mask = l_ones_mask.expand(hsl_tensor.shape)
- l_zeros_mask = l_zeros_mask.expand(hsl_tensor.shape)
- calc_rgb_mask = torch.logical_not(torch.logical_or(l_ones_mask, l_zeros_mask))
-
- rgb_tensor = torch.empty(hsl_tensor.shape)
- rgb_tensor = torch.where(l_ones_mask, 1.0, torch.where(l_zeros_mask, 0.0, rgb_tensor))
-
- units_ab_tensor = torch.stack(
- [torch.cos(torch.mul(hsl_tensor[0, :, :], 2.0 * PI)), torch.sin(torch.mul(hsl_tensor[0, :, :], 2.0 * PI))]
- )
- l_tensor = ok_l_from_lr_tensor(hsl_tensor[2, :, :])
-
- # {C_0, C_mid, C_max}
- cs_tensor = get_cs_tensor(l_tensor, units_ab_tensor, steps=steps, steps_outer=steps_outer)
-
- mid = 0.8
- mid_inv = 1.25
-
- s_lt_mid_mask = torch.lt(hsl_tensor[1, :, :], mid)
- t_tensor = torch.where(
- s_lt_mid_mask,
- torch.mul(hsl_tensor[1, :, :], mid_inv),
- torch.div(torch.sub(hsl_tensor[1, :, :], mid), 1.0 - mid),
- )
- k_1_tensor = torch.where(
- s_lt_mid_mask,
- torch.mul(cs_tensor[0, :, :], mid),
- torch.div(
- torch.mul(torch.mul(torch.pow(cs_tensor[1, :, :], 2.0), mid_inv**2.0), 1.0 - mid), cs_tensor[0, :, :]
- ),
- )
- k_2_tensor = torch.where(
- s_lt_mid_mask,
- torch.add(torch.mul(torch.div(k_1_tensor, cs_tensor[1, :, :]), -1.0), 1.0),
- torch.add(torch.mul(torch.div(k_1_tensor, torch.sub(cs_tensor[2, :, :], cs_tensor[1, :, :])), -1.0), 1.0),
- )
-
- c_tensor = torch.div(
- torch.mul(t_tensor, k_1_tensor), torch.add(torch.mul(torch.mul(k_2_tensor, t_tensor), -1.0), 1.0)
- )
- c_tensor = torch.where(s_lt_mid_mask, c_tensor, torch.add(cs_tensor[1, :, :], c_tensor))
-
- rgb_tensor = torch.where(
- calc_rgb_mask,
- linear_srgb_from_oklab(
- torch.stack(
- [l_tensor, torch.mul(c_tensor, units_ab_tensor[0, :, :]), torch.mul(c_tensor, units_ab_tensor[1, :, :])]
- )
- ),
- rgb_tensor,
- )
-
- rgb_tensor = srgb_from_linear_srgb(rgb_tensor, alpha=alpha, steps=steps)
- return torch.where(torch.isnan(rgb_tensor), 0.0, rgb_tensor).clamp(0.0, 1.0)
-
-
-def okhsl_from_srgb(rgb_tensor: torch.Tensor, steps: int = 1, steps_outer: int = 1):
- """Get an Okhsl image tensor from gamma-corrected sRGB"""
-
- lab_tensor = oklab_from_linear_srgb(linear_srgb_from_srgb(rgb_tensor))
-
- c_tensor = torch.sqrt(torch.add(torch.pow(lab_tensor[1, :, :], 2.0), torch.pow(lab_tensor[2, :, :], 2.0)))
- units_ab_tensor = torch.stack([torch.div(lab_tensor[1, :, :], c_tensor), torch.div(lab_tensor[2, :, :], c_tensor)])
-
- h_tensor = torch.add(
- torch.div(
- torch.mul(torch.atan2(torch.mul(lab_tensor[2, :, :], -1.0), torch.mul(lab_tensor[1, :, :], -1.0)), 0.5), PI
- ),
- 0.5,
- )
-
- # {C_0, C_mid, C_max}
- cs_tensor = get_cs_tensor(lab_tensor[0, :, :], units_ab_tensor, steps=1, steps_outer=1)
-
- mid = 0.8
- mid_inv = 1.25
-
- c_lt_c_mid_mask = torch.lt(c_tensor, cs_tensor[1, :, :])
- k_1_tensor = torch.where(
- c_lt_c_mid_mask,
- torch.mul(cs_tensor[0, :, :], mid),
- torch.div(torch.mul(torch.mul(torch.pow(cs_tensor[1, :, :], 2.0), mid_inv**2), 1.0 - mid), cs_tensor[0, :, :]),
- )
- k_2_tensor = torch.where(
- c_lt_c_mid_mask,
- torch.add(torch.mul(torch.div(k_1_tensor, cs_tensor[1, :, :]), -1.0), 1.0),
- torch.add(torch.mul(torch.div(k_1_tensor, torch.sub(cs_tensor[2, :, :], cs_tensor[1, :, :])), -1.0), 1.0),
- )
- t_tensor = torch.where(
- c_lt_c_mid_mask,
- torch.div(c_tensor, torch.add(k_1_tensor, torch.mul(k_2_tensor, c_tensor))),
- torch.div(
- torch.sub(c_tensor, cs_tensor[1, :, :]),
- torch.add(k_1_tensor, torch.mul(k_2_tensor, torch.sub(c_tensor, cs_tensor[1, :, :]))),
- ),
- )
-
- s_tensor = torch.where(c_lt_c_mid_mask, torch.mul(t_tensor, mid), torch.add(torch.mul(t_tensor, 1.0 - mid), mid))
- l_tensor = ok_l_r_from_l_tensor(lab_tensor[0, :, :])
-
- hsl_tensor = torch.stack([h_tensor, s_tensor, l_tensor])
- return torch.where(torch.isnan(hsl_tensor), 0.0, hsl_tensor).clamp(0.0, 1.0)
-
-
-def xyz_from_srgb(rgb_l_tensor: torch.Tensor):
- conversion_matrix = torch.tensor([[0.4124, 0.3576, 0.1805], [0.2126, 0.7152, 0.0722], [0.0193, 0.1192, 0.9505]])
- return torch.einsum("zc, cwh -> zwh", conversion_matrix, rgb_l_tensor)
-
-
-def lab_from_xyz_helper(channel_illuminant_quotient_matrix: torch.Tensor):
- delta = 6.0 / 29.0
-
- return torch.where(
- torch.gt(channel_illuminant_quotient_matrix, delta**3.0),
- torch.pow(channel_illuminant_quotient_matrix, 1.0 / 3.0),
- torch.add(torch.div(channel_illuminant_quotient_matrix, 3.0 * (delta**2.0)), 4.0 / 29.0),
- )
-
-
-def lab_from_xyz(xyz_tensor: torch.Tensor, reference_illuminant: Literal["D65", "D50"] = "D65"):
- illuminant = {"D65": [95.0489, 100.0, 108.8840], "D50": [96.4212, 100.0, 82.5188]}[reference_illuminant]
- l_tensor = torch.sub(torch.mul(lab_from_xyz_helper(torch.div(xyz_tensor[1, :, :], illuminant[1])), 116.0), 16.0)
- a_tensor = torch.mul(
- torch.sub(
- lab_from_xyz_helper(torch.div(xyz_tensor[0, :, :], illuminant[0])),
- lab_from_xyz_helper(torch.div(xyz_tensor[1, :, :], illuminant[1])),
- ),
- 500.0,
- )
- b_tensor = torch.mul(
- torch.sub(
- lab_from_xyz_helper(torch.div(xyz_tensor[1, :, :], illuminant[1])),
- lab_from_xyz_helper(torch.div(xyz_tensor[2, :, :], illuminant[2])),
- ),
- 200.0,
- )
-
- return torch.stack([l_tensor, a_tensor, b_tensor])
-
-
-######################################################################################\
-# HSL Code derived from CPython colorsys source code [license text below]
-def hsl_from_srgb(rgb_tensor: torch.Tensor):
- """Get HSL image tensor from standard gamma-corrected sRGB"""
- c_max_tensor = rgb_tensor.max(0).values
- c_min_tensor = rgb_tensor.min(0).values
- c_sum_tensor = torch.add(c_max_tensor, c_min_tensor)
- c_range_tensor = torch.sub(c_max_tensor, c_min_tensor)
- l_tensor = torch.div(c_sum_tensor, 2.0)
- s_tensor = torch.where(
- torch.eq(c_max_tensor, c_min_tensor),
- 0.0,
- torch.where(
- torch.lt(l_tensor, 0.5),
- torch.div(c_range_tensor, c_sum_tensor),
- torch.div(c_range_tensor, torch.add(torch.mul(torch.add(c_max_tensor, c_min_tensor), -1.0), 2.0)),
- ),
- )
- rgb_c_tensor = torch.div(
- torch.sub(c_max_tensor.expand(rgb_tensor.shape), rgb_tensor), c_range_tensor.expand(rgb_tensor.shape)
- )
- h_tensor = torch.where(
- torch.eq(c_max_tensor, c_min_tensor),
- 0.0,
- torch.where(
- torch.eq(rgb_tensor[0, :, :], c_max_tensor),
- torch.sub(rgb_c_tensor[2, :, :], rgb_c_tensor[1, :, :]),
- torch.where(
- torch.eq(rgb_tensor[1, :, :], c_max_tensor),
- torch.add(torch.sub(rgb_c_tensor[0, :, :], rgb_c_tensor[2, :, :]), 2.0),
- torch.add(torch.sub(rgb_c_tensor[1, :, :], rgb_c_tensor[0, :, :]), 4.0),
- ),
- ),
- )
- h_tensor = torch.remainder(torch.div(h_tensor, 6.0), 1.0)
- return torch.stack([h_tensor, s_tensor, l_tensor])
-
-
-def srgb_from_hsl(hsl_tensor: torch.Tensor):
- """Get gamma-corrected sRGB from an HSL image tensor"""
- hsl_tensor = hsl_tensor.clamp(0.0, 1.0)
- rgb_tensor = torch.empty(hsl_tensor.shape)
- s_0_mask = torch.eq(hsl_tensor[1, :, :], 0.0)
- rgb_tensor = torch.where(
- s_0_mask.expand(rgb_tensor.shape), hsl_tensor[2, :, :].expand(hsl_tensor.shape), rgb_tensor
- )
- m2_tensor = torch.where(
- torch.le(hsl_tensor[2, :, :], 0.5),
- torch.mul(hsl_tensor[2, :, :], torch.add(hsl_tensor[1, :, :], 1.0)),
- torch.sub(
- torch.add(hsl_tensor[2, :, :], hsl_tensor[1, :, :]), torch.mul(hsl_tensor[2, :, :], hsl_tensor[1, :, :])
- ),
- )
- m1_tensor = torch.sub(torch.mul(hsl_tensor[2, :, :], 2.0), m2_tensor)
-
- def hsl_values(m1_tensor: torch.Tensor, m2_tensor: torch.Tensor, h_tensor: torch.Tensor):
- """Helper for computing output components"""
-
- h_tensor = torch.remainder(h_tensor, 1.0)
- result_tensor = m1_tensor.clone()
- result_tensor = torch.where(
- torch.lt(h_tensor, 1.0 / 6.0),
- torch.add(m1_tensor, torch.mul(torch.sub(m2_tensor, m1_tensor), torch.mul(h_tensor, 6.0))),
- torch.where(
- torch.lt(h_tensor, 0.5),
- m2_tensor,
- torch.where(
- torch.lt(h_tensor, 2.0 / 3.0),
- torch.add(
- m1_tensor,
- torch.mul(
- torch.sub(m2_tensor, m1_tensor),
- torch.mul(torch.add(torch.mul(h_tensor, -1.0), 2.0 / 3.0), 6.0),
- ),
- ),
- result_tensor,
- ),
- ),
- )
- return result_tensor
-
- return torch.stack(
- [
- hsl_values(m1_tensor, m2_tensor, torch.add(hsl_tensor[0, :, :], 1.0 / 3.0)),
- hsl_values(m1_tensor, m2_tensor, hsl_tensor[0, :, :]),
- hsl_values(m1_tensor, m2_tensor, torch.sub(hsl_tensor[0, :, :], 1.0 / 3.0)),
- ]
- )
+ return shared_srgb_from_linear_srgb(linear_srgb_tensor)
def remove_nans(tensor: torch.Tensor, replace_with: float = MAX_FLOAT):
diff --git a/invokeai/frontend/web/src/services/api/schema.ts b/invokeai/frontend/web/src/services/api/schema.ts
index 63e365ce33..99b7c0ea91 100644
--- a/invokeai/frontend/web/src/services/api/schema.ts
+++ b/invokeai/frontend/web/src/services/api/schema.ts
@@ -12248,7 +12248,7 @@ export type components = {
* @description The nodes in this graph
*/
nodes?: {
- [key: string]: components["schemas"]["AddInvocation"] | components["schemas"]["AlibabaCloudImageGenerationInvocation"] | components["schemas"]["AlphaMaskToTensorInvocation"] | components["schemas"]["AnimaDenoiseInvocation"] | components["schemas"]["AnimaImageToLatentsInvocation"] | components["schemas"]["AnimaLatentsToImageInvocation"] | components["schemas"]["AnimaLoRACollectionLoader"] | components["schemas"]["AnimaLoRALoaderInvocation"] | components["schemas"]["AnimaModelLoaderInvocation"] | components["schemas"]["AnimaTextEncoderInvocation"] | components["schemas"]["ApplyMaskTensorToImageInvocation"] | components["schemas"]["ApplyMaskToImageInvocation"] | components["schemas"]["BlankImageInvocation"] | components["schemas"]["BlendLatentsInvocation"] | components["schemas"]["BooleanCollectionInvocation"] | components["schemas"]["BooleanInvocation"] | components["schemas"]["BoundingBoxInvocation"] | components["schemas"]["CLIPSkipInvocation"] | components["schemas"]["CV2InfillInvocation"] | components["schemas"]["CalculateImageTilesEvenSplitInvocation"] | components["schemas"]["CalculateImageTilesInvocation"] | components["schemas"]["CalculateImageTilesMinimumOverlapInvocation"] | components["schemas"]["CannyEdgeDetectionInvocation"] | components["schemas"]["CanvasOutputInvocation"] | components["schemas"]["CanvasPasteBackInvocation"] | components["schemas"]["CanvasV2MaskAndCropInvocation"] | components["schemas"]["CenterPadCropInvocation"] | components["schemas"]["CogView4DenoiseInvocation"] | components["schemas"]["CogView4ImageToLatentsInvocation"] | components["schemas"]["CogView4LatentsToImageInvocation"] | components["schemas"]["CogView4ModelLoaderInvocation"] | components["schemas"]["CogView4TextEncoderInvocation"] | components["schemas"]["CollectInvocation"] | components["schemas"]["ColorCorrectInvocation"] | components["schemas"]["ColorInvocation"] | components["schemas"]["ColorMapInvocation"] | components["schemas"]["CompelInvocation"] | components["schemas"]["ConditioningCollectionInvocation"] | components["schemas"]["ConditioningInvocation"] | components["schemas"]["ContentShuffleInvocation"] | components["schemas"]["ControlNetInvocation"] | components["schemas"]["CoreMetadataInvocation"] | components["schemas"]["CreateDenoiseMaskInvocation"] | components["schemas"]["CreateGradientMaskInvocation"] | components["schemas"]["CropImageToBoundingBoxInvocation"] | components["schemas"]["CropLatentsCoreInvocation"] | components["schemas"]["CvInpaintInvocation"] | components["schemas"]["DWOpenposeDetectionInvocation"] | components["schemas"]["DecodeInvisibleWatermarkInvocation"] | components["schemas"]["DenoiseLatentsInvocation"] | components["schemas"]["DenoiseLatentsMetaInvocation"] | components["schemas"]["DepthAnythingDepthEstimationInvocation"] | components["schemas"]["DivideInvocation"] | components["schemas"]["DynamicPromptInvocation"] | components["schemas"]["ESRGANInvocation"] | components["schemas"]["ExpandMaskWithFadeInvocation"] | components["schemas"]["FLUXLoRACollectionLoader"] | components["schemas"]["FaceIdentifierInvocation"] | components["schemas"]["FaceMaskInvocation"] | components["schemas"]["FaceOffInvocation"] | components["schemas"]["FloatBatchInvocation"] | components["schemas"]["FloatCollectionInvocation"] | components["schemas"]["FloatGenerator"] | components["schemas"]["FloatInvocation"] | components["schemas"]["FloatLinearRangeInvocation"] | components["schemas"]["FloatMathInvocation"] | components["schemas"]["FloatToIntegerInvocation"] | components["schemas"]["Flux2DenoiseInvocation"] | components["schemas"]["Flux2KleinLoRACollectionLoader"] | components["schemas"]["Flux2KleinLoRALoaderInvocation"] | components["schemas"]["Flux2KleinModelLoaderInvocation"] | components["schemas"]["Flux2KleinTextEncoderInvocation"] | components["schemas"]["Flux2VaeDecodeInvocation"] | components["schemas"]["Flux2VaeEncodeInvocation"] | components["schemas"]["FluxControlLoRALoaderInvocation"] | components["schemas"]["FluxControlNetInvocation"] | components["schemas"]["FluxDenoiseInvocation"] | components["schemas"]["FluxDenoiseLatentsMetaInvocation"] | components["schemas"]["FluxFillInvocation"] | components["schemas"]["FluxIPAdapterInvocation"] | components["schemas"]["FluxKontextConcatenateImagesInvocation"] | components["schemas"]["FluxKontextInvocation"] | components["schemas"]["FluxLoRALoaderInvocation"] | components["schemas"]["FluxModelLoaderInvocation"] | components["schemas"]["FluxReduxInvocation"] | components["schemas"]["FluxTextEncoderInvocation"] | components["schemas"]["FluxVaeDecodeInvocation"] | components["schemas"]["FluxVaeEncodeInvocation"] | components["schemas"]["FreeUInvocation"] | components["schemas"]["GeminiImageGenerationInvocation"] | components["schemas"]["GetMaskBoundingBoxInvocation"] | components["schemas"]["GroundingDinoInvocation"] | components["schemas"]["HEDEdgeDetectionInvocation"] | components["schemas"]["HeuristicResizeInvocation"] | components["schemas"]["IPAdapterInvocation"] | components["schemas"]["IdealSizeInvocation"] | components["schemas"]["IfInvocation"] | components["schemas"]["ImageBatchInvocation"] | components["schemas"]["ImageBlurInvocation"] | components["schemas"]["ImageChannelInvocation"] | components["schemas"]["ImageChannelMultiplyInvocation"] | components["schemas"]["ImageChannelOffsetInvocation"] | components["schemas"]["ImageCollectionInvocation"] | components["schemas"]["ImageConvertInvocation"] | components["schemas"]["ImageCropInvocation"] | components["schemas"]["ImageGenerator"] | components["schemas"]["ImageHueAdjustmentInvocation"] | components["schemas"]["ImageInverseLerpInvocation"] | components["schemas"]["ImageInvocation"] | components["schemas"]["ImageLerpInvocation"] | components["schemas"]["ImageMaskToTensorInvocation"] | components["schemas"]["ImageMultiplyInvocation"] | components["schemas"]["ImageNSFWBlurInvocation"] | components["schemas"]["ImageNoiseInvocation"] | components["schemas"]["ImagePanelLayoutInvocation"] | components["schemas"]["ImagePasteInvocation"] | components["schemas"]["ImageResizeInvocation"] | components["schemas"]["ImageScaleInvocation"] | components["schemas"]["ImageToLatentsInvocation"] | components["schemas"]["ImageWatermarkInvocation"] | components["schemas"]["InfillColorInvocation"] | components["schemas"]["InfillPatchMatchInvocation"] | components["schemas"]["InfillTileInvocation"] | components["schemas"]["IntegerBatchInvocation"] | components["schemas"]["IntegerCollectionInvocation"] | components["schemas"]["IntegerGenerator"] | components["schemas"]["IntegerInvocation"] | components["schemas"]["IntegerMathInvocation"] | components["schemas"]["InvertTensorMaskInvocation"] | components["schemas"]["InvokeAdjustImageHuePlusInvocation"] | components["schemas"]["InvokeEquivalentAchromaticLightnessInvocation"] | components["schemas"]["InvokeImageBlendInvocation"] | components["schemas"]["InvokeImageCompositorInvocation"] | components["schemas"]["InvokeImageDilateOrErodeInvocation"] | components["schemas"]["InvokeImageEnhanceInvocation"] | components["schemas"]["InvokeImageValueThresholdsInvocation"] | components["schemas"]["IterateInvocation"] | components["schemas"]["LaMaInfillInvocation"] | components["schemas"]["LatentsCollectionInvocation"] | components["schemas"]["LatentsInvocation"] | components["schemas"]["LatentsToImageInvocation"] | components["schemas"]["LineartAnimeEdgeDetectionInvocation"] | components["schemas"]["LineartEdgeDetectionInvocation"] | components["schemas"]["LlavaOnevisionVllmInvocation"] | components["schemas"]["LoRACollectionLoader"] | components["schemas"]["LoRALoaderInvocation"] | components["schemas"]["LoRASelectorInvocation"] | components["schemas"]["MLSDDetectionInvocation"] | components["schemas"]["MainModelLoaderInvocation"] | components["schemas"]["MaskCombineInvocation"] | components["schemas"]["MaskEdgeInvocation"] | components["schemas"]["MaskFromAlphaInvocation"] | components["schemas"]["MaskFromIDInvocation"] | components["schemas"]["MaskTensorToImageInvocation"] | components["schemas"]["MediaPipeFaceDetectionInvocation"] | components["schemas"]["MergeMetadataInvocation"] | components["schemas"]["MergeTilesToImageInvocation"] | components["schemas"]["MetadataFieldExtractorInvocation"] | components["schemas"]["MetadataFromImageInvocation"] | components["schemas"]["MetadataInvocation"] | components["schemas"]["MetadataItemInvocation"] | components["schemas"]["MetadataItemLinkedInvocation"] | components["schemas"]["MetadataToBoolCollectionInvocation"] | components["schemas"]["MetadataToBoolInvocation"] | components["schemas"]["MetadataToControlnetsInvocation"] | components["schemas"]["MetadataToFloatCollectionInvocation"] | components["schemas"]["MetadataToFloatInvocation"] | components["schemas"]["MetadataToIPAdaptersInvocation"] | components["schemas"]["MetadataToIntegerCollectionInvocation"] | components["schemas"]["MetadataToIntegerInvocation"] | components["schemas"]["MetadataToLorasCollectionInvocation"] | components["schemas"]["MetadataToLorasInvocation"] | components["schemas"]["MetadataToModelInvocation"] | components["schemas"]["MetadataToSDXLLorasInvocation"] | components["schemas"]["MetadataToSDXLModelInvocation"] | components["schemas"]["MetadataToSchedulerInvocation"] | components["schemas"]["MetadataToStringCollectionInvocation"] | components["schemas"]["MetadataToStringInvocation"] | components["schemas"]["MetadataToT2IAdaptersInvocation"] | components["schemas"]["MetadataToVAEInvocation"] | components["schemas"]["ModelIdentifierInvocation"] | components["schemas"]["MultiplyInvocation"] | components["schemas"]["NoiseInvocation"] | components["schemas"]["NormalMapInvocation"] | components["schemas"]["OpenAIImageGenerationInvocation"] | components["schemas"]["PBRMapsInvocation"] | components["schemas"]["PairTileImageInvocation"] | components["schemas"]["PasteImageIntoBoundingBoxInvocation"] | components["schemas"]["PiDiNetEdgeDetectionInvocation"] | components["schemas"]["PromptTemplateInvocation"] | components["schemas"]["PromptsFromFileInvocation"] | components["schemas"]["QwenImageDenoiseInvocation"] | components["schemas"]["QwenImageImageToLatentsInvocation"] | components["schemas"]["QwenImageLatentsToImageInvocation"] | components["schemas"]["QwenImageLoRACollectionLoader"] | components["schemas"]["QwenImageLoRALoaderInvocation"] | components["schemas"]["QwenImageModelLoaderInvocation"] | components["schemas"]["QwenImageTextEncoderInvocation"] | components["schemas"]["RandomFloatInvocation"] | components["schemas"]["RandomIntInvocation"] | components["schemas"]["RandomRangeInvocation"] | components["schemas"]["RangeInvocation"] | components["schemas"]["RangeOfSizeInvocation"] | components["schemas"]["RectangleMaskInvocation"] | components["schemas"]["ResizeLatentsInvocation"] | components["schemas"]["RoundInvocation"] | components["schemas"]["SD3DenoiseInvocation"] | components["schemas"]["SD3ImageToLatentsInvocation"] | components["schemas"]["SD3LatentsToImageInvocation"] | components["schemas"]["SDXLCompelPromptInvocation"] | components["schemas"]["SDXLLoRACollectionLoader"] | components["schemas"]["SDXLLoRALoaderInvocation"] | components["schemas"]["SDXLModelLoaderInvocation"] | components["schemas"]["SDXLRefinerCompelPromptInvocation"] | components["schemas"]["SDXLRefinerModelLoaderInvocation"] | components["schemas"]["SaveImageInvocation"] | components["schemas"]["ScaleLatentsInvocation"] | components["schemas"]["SchedulerInvocation"] | components["schemas"]["Sd3ModelLoaderInvocation"] | components["schemas"]["Sd3TextEncoderInvocation"] | components["schemas"]["SeamlessModeInvocation"] | components["schemas"]["SeedreamImageGenerationInvocation"] | components["schemas"]["SegmentAnythingInvocation"] | components["schemas"]["ShowImageInvocation"] | components["schemas"]["SpandrelImageToImageAutoscaleInvocation"] | components["schemas"]["SpandrelImageToImageInvocation"] | components["schemas"]["StringBatchInvocation"] | components["schemas"]["StringCollectionInvocation"] | components["schemas"]["StringGenerator"] | components["schemas"]["StringInvocation"] | components["schemas"]["StringJoinInvocation"] | components["schemas"]["StringJoinThreeInvocation"] | components["schemas"]["StringReplaceInvocation"] | components["schemas"]["StringSplitInvocation"] | components["schemas"]["StringSplitNegInvocation"] | components["schemas"]["SubtractInvocation"] | components["schemas"]["T2IAdapterInvocation"] | components["schemas"]["TextLLMInvocation"] | components["schemas"]["TileToPropertiesInvocation"] | components["schemas"]["TiledMultiDiffusionDenoiseLatents"] | components["schemas"]["UnsharpMaskInvocation"] | components["schemas"]["VAELoaderInvocation"] | components["schemas"]["ZImageControlInvocation"] | components["schemas"]["ZImageDenoiseInvocation"] | components["schemas"]["ZImageDenoiseMetaInvocation"] | components["schemas"]["ZImageImageToLatentsInvocation"] | components["schemas"]["ZImageLatentsToImageInvocation"] | components["schemas"]["ZImageLoRACollectionLoader"] | components["schemas"]["ZImageLoRALoaderInvocation"] | components["schemas"]["ZImageModelLoaderInvocation"] | components["schemas"]["ZImageSeedVarianceEnhancerInvocation"] | components["schemas"]["ZImageTextEncoderInvocation"];
+ [key: string]: components["schemas"]["AddInvocation"] | components["schemas"]["AlibabaCloudImageGenerationInvocation"] | components["schemas"]["AlphaMaskToTensorInvocation"] | components["schemas"]["AnimaDenoiseInvocation"] | components["schemas"]["AnimaImageToLatentsInvocation"] | components["schemas"]["AnimaLatentsToImageInvocation"] | components["schemas"]["AnimaLoRACollectionLoader"] | components["schemas"]["AnimaLoRALoaderInvocation"] | components["schemas"]["AnimaModelLoaderInvocation"] | components["schemas"]["AnimaTextEncoderInvocation"] | components["schemas"]["ApplyMaskTensorToImageInvocation"] | components["schemas"]["ApplyMaskToImageInvocation"] | components["schemas"]["BlankImageInvocation"] | components["schemas"]["BlendLatentsInvocation"] | components["schemas"]["BooleanCollectionInvocation"] | components["schemas"]["BooleanInvocation"] | components["schemas"]["BoundingBoxInvocation"] | components["schemas"]["CLIPSkipInvocation"] | components["schemas"]["CV2InfillInvocation"] | components["schemas"]["CalculateImageTilesEvenSplitInvocation"] | components["schemas"]["CalculateImageTilesInvocation"] | components["schemas"]["CalculateImageTilesMinimumOverlapInvocation"] | components["schemas"]["CannyEdgeDetectionInvocation"] | components["schemas"]["CanvasOutputInvocation"] | components["schemas"]["CanvasPasteBackInvocation"] | components["schemas"]["CanvasV2MaskAndCropInvocation"] | components["schemas"]["CenterPadCropInvocation"] | components["schemas"]["CogView4DenoiseInvocation"] | components["schemas"]["CogView4ImageToLatentsInvocation"] | components["schemas"]["CogView4LatentsToImageInvocation"] | components["schemas"]["CogView4ModelLoaderInvocation"] | components["schemas"]["CogView4TextEncoderInvocation"] | components["schemas"]["CollectInvocation"] | components["schemas"]["ColorCorrectInvocation"] | components["schemas"]["ColorInvocation"] | components["schemas"]["ColorMapInvocation"] | components["schemas"]["CompelInvocation"] | components["schemas"]["ConditioningCollectionInvocation"] | components["schemas"]["ConditioningInvocation"] | components["schemas"]["ContentShuffleInvocation"] | components["schemas"]["ControlNetInvocation"] | components["schemas"]["CoreMetadataInvocation"] | components["schemas"]["CreateDenoiseMaskInvocation"] | components["schemas"]["CreateGradientMaskInvocation"] | components["schemas"]["CropImageToBoundingBoxInvocation"] | components["schemas"]["CropLatentsCoreInvocation"] | components["schemas"]["CvInpaintInvocation"] | components["schemas"]["DWOpenposeDetectionInvocation"] | components["schemas"]["DecodeInvisibleWatermarkInvocation"] | components["schemas"]["DenoiseLatentsInvocation"] | components["schemas"]["DenoiseLatentsMetaInvocation"] | components["schemas"]["DepthAnythingDepthEstimationInvocation"] | components["schemas"]["DivideInvocation"] | components["schemas"]["DynamicPromptInvocation"] | components["schemas"]["ESRGANInvocation"] | components["schemas"]["ExpandMaskWithFadeInvocation"] | components["schemas"]["FLUXLoRACollectionLoader"] | components["schemas"]["FaceIdentifierInvocation"] | components["schemas"]["FaceMaskInvocation"] | components["schemas"]["FaceOffInvocation"] | components["schemas"]["FloatBatchInvocation"] | components["schemas"]["FloatCollectionInvocation"] | components["schemas"]["FloatGenerator"] | components["schemas"]["FloatInvocation"] | components["schemas"]["FloatLinearRangeInvocation"] | components["schemas"]["FloatMathInvocation"] | components["schemas"]["FloatToIntegerInvocation"] | components["schemas"]["Flux2DenoiseInvocation"] | components["schemas"]["Flux2KleinLoRACollectionLoader"] | components["schemas"]["Flux2KleinLoRALoaderInvocation"] | components["schemas"]["Flux2KleinModelLoaderInvocation"] | components["schemas"]["Flux2KleinTextEncoderInvocation"] | components["schemas"]["Flux2VaeDecodeInvocation"] | components["schemas"]["Flux2VaeEncodeInvocation"] | components["schemas"]["FluxControlLoRALoaderInvocation"] | components["schemas"]["FluxControlNetInvocation"] | components["schemas"]["FluxDenoiseInvocation"] | components["schemas"]["FluxDenoiseLatentsMetaInvocation"] | components["schemas"]["FluxFillInvocation"] | components["schemas"]["FluxIPAdapterInvocation"] | components["schemas"]["FluxKontextConcatenateImagesInvocation"] | components["schemas"]["FluxKontextInvocation"] | components["schemas"]["FluxLoRALoaderInvocation"] | components["schemas"]["FluxModelLoaderInvocation"] | components["schemas"]["FluxReduxInvocation"] | components["schemas"]["FluxTextEncoderInvocation"] | components["schemas"]["FluxVaeDecodeInvocation"] | components["schemas"]["FluxVaeEncodeInvocation"] | components["schemas"]["FreeUInvocation"] | components["schemas"]["GeminiImageGenerationInvocation"] | components["schemas"]["GetMaskBoundingBoxInvocation"] | components["schemas"]["GroundingDinoInvocation"] | components["schemas"]["HEDEdgeDetectionInvocation"] | components["schemas"]["HeuristicResizeInvocation"] | components["schemas"]["IPAdapterInvocation"] | components["schemas"]["IdealSizeInvocation"] | components["schemas"]["IfInvocation"] | components["schemas"]["ImageBatchInvocation"] | components["schemas"]["ImageBlurInvocation"] | components["schemas"]["ImageChannelInvocation"] | components["schemas"]["ImageChannelMultiplyInvocation"] | components["schemas"]["ImageChannelOffsetInvocation"] | components["schemas"]["ImageCollectionInvocation"] | components["schemas"]["ImageConvertInvocation"] | components["schemas"]["ImageCropInvocation"] | components["schemas"]["ImageGenerator"] | components["schemas"]["ImageHueAdjustmentInvocation"] | components["schemas"]["ImageInverseLerpInvocation"] | components["schemas"]["ImageInvocation"] | components["schemas"]["ImageLerpInvocation"] | components["schemas"]["ImageMaskToTensorInvocation"] | components["schemas"]["ImageMultiplyInvocation"] | components["schemas"]["ImageNSFWBlurInvocation"] | components["schemas"]["ImageNoiseInvocation"] | components["schemas"]["ImagePanelLayoutInvocation"] | components["schemas"]["ImagePasteInvocation"] | components["schemas"]["ImageResizeInvocation"] | components["schemas"]["ImageScaleInvocation"] | components["schemas"]["ImageToLatentsInvocation"] | components["schemas"]["ImageWatermarkInvocation"] | components["schemas"]["InfillColorInvocation"] | components["schemas"]["InfillPatchMatchInvocation"] | components["schemas"]["InfillTileInvocation"] | components["schemas"]["IntegerBatchInvocation"] | components["schemas"]["IntegerCollectionInvocation"] | components["schemas"]["IntegerGenerator"] | components["schemas"]["IntegerInvocation"] | components["schemas"]["IntegerMathInvocation"] | components["schemas"]["InvertTensorMaskInvocation"] | components["schemas"]["InvokeAdjustImageHuePlusInvocation"] | components["schemas"]["InvokeEquivalentAchromaticLightnessInvocation"] | components["schemas"]["InvokeImageBlendInvocation"] | components["schemas"]["InvokeImageCompositorInvocation"] | components["schemas"]["InvokeImageDilateOrErodeInvocation"] | components["schemas"]["InvokeImageEnhanceInvocation"] | components["schemas"]["InvokeImageValueThresholdsInvocation"] | components["schemas"]["IterateInvocation"] | components["schemas"]["LaMaInfillInvocation"] | components["schemas"]["LatentsCollectionInvocation"] | components["schemas"]["LatentsInvocation"] | components["schemas"]["LatentsToImageInvocation"] | components["schemas"]["LineartAnimeEdgeDetectionInvocation"] | components["schemas"]["LineartEdgeDetectionInvocation"] | components["schemas"]["LlavaOnevisionVllmInvocation"] | components["schemas"]["LoRACollectionLoader"] | components["schemas"]["LoRALoaderInvocation"] | components["schemas"]["LoRASelectorInvocation"] | components["schemas"]["MLSDDetectionInvocation"] | components["schemas"]["MainModelLoaderInvocation"] | components["schemas"]["MaskCombineInvocation"] | components["schemas"]["MaskEdgeInvocation"] | components["schemas"]["MaskFromAlphaInvocation"] | components["schemas"]["MaskFromIDInvocation"] | components["schemas"]["MaskTensorToImageInvocation"] | components["schemas"]["MediaPipeFaceDetectionInvocation"] | components["schemas"]["MergeMetadataInvocation"] | components["schemas"]["MergeTilesToImageInvocation"] | components["schemas"]["MetadataFieldExtractorInvocation"] | components["schemas"]["MetadataFromImageInvocation"] | components["schemas"]["MetadataInvocation"] | components["schemas"]["MetadataItemInvocation"] | components["schemas"]["MetadataItemLinkedInvocation"] | components["schemas"]["MetadataToBoolCollectionInvocation"] | components["schemas"]["MetadataToBoolInvocation"] | components["schemas"]["MetadataToControlnetsInvocation"] | components["schemas"]["MetadataToFloatCollectionInvocation"] | components["schemas"]["MetadataToFloatInvocation"] | components["schemas"]["MetadataToIPAdaptersInvocation"] | components["schemas"]["MetadataToIntegerCollectionInvocation"] | components["schemas"]["MetadataToIntegerInvocation"] | components["schemas"]["MetadataToLorasCollectionInvocation"] | components["schemas"]["MetadataToLorasInvocation"] | components["schemas"]["MetadataToModelInvocation"] | components["schemas"]["MetadataToSDXLLorasInvocation"] | components["schemas"]["MetadataToSDXLModelInvocation"] | components["schemas"]["MetadataToSchedulerInvocation"] | components["schemas"]["MetadataToStringCollectionInvocation"] | components["schemas"]["MetadataToStringInvocation"] | components["schemas"]["MetadataToT2IAdaptersInvocation"] | components["schemas"]["MetadataToVAEInvocation"] | components["schemas"]["ModelIdentifierInvocation"] | components["schemas"]["MultiplyInvocation"] | components["schemas"]["NoiseInvocation"] | components["schemas"]["NormalMapInvocation"] | components["schemas"]["OklabUnsharpMaskInvocation"] | components["schemas"]["OklchImageHueAdjustmentInvocation"] | components["schemas"]["OpenAIImageGenerationInvocation"] | components["schemas"]["PBRMapsInvocation"] | components["schemas"]["PairTileImageInvocation"] | components["schemas"]["PasteImageIntoBoundingBoxInvocation"] | components["schemas"]["PiDiNetEdgeDetectionInvocation"] | components["schemas"]["PromptTemplateInvocation"] | components["schemas"]["PromptsFromFileInvocation"] | components["schemas"]["QwenImageDenoiseInvocation"] | components["schemas"]["QwenImageImageToLatentsInvocation"] | components["schemas"]["QwenImageLatentsToImageInvocation"] | components["schemas"]["QwenImageLoRACollectionLoader"] | components["schemas"]["QwenImageLoRALoaderInvocation"] | components["schemas"]["QwenImageModelLoaderInvocation"] | components["schemas"]["QwenImageTextEncoderInvocation"] | components["schemas"]["RandomFloatInvocation"] | components["schemas"]["RandomIntInvocation"] | components["schemas"]["RandomRangeInvocation"] | components["schemas"]["RangeInvocation"] | components["schemas"]["RangeOfSizeInvocation"] | components["schemas"]["RectangleMaskInvocation"] | components["schemas"]["ResizeLatentsInvocation"] | components["schemas"]["RoundInvocation"] | components["schemas"]["SD3DenoiseInvocation"] | components["schemas"]["SD3ImageToLatentsInvocation"] | components["schemas"]["SD3LatentsToImageInvocation"] | components["schemas"]["SDXLCompelPromptInvocation"] | components["schemas"]["SDXLLoRACollectionLoader"] | components["schemas"]["SDXLLoRALoaderInvocation"] | components["schemas"]["SDXLModelLoaderInvocation"] | components["schemas"]["SDXLRefinerCompelPromptInvocation"] | components["schemas"]["SDXLRefinerModelLoaderInvocation"] | components["schemas"]["SaveImageInvocation"] | components["schemas"]["ScaleLatentsInvocation"] | components["schemas"]["SchedulerInvocation"] | components["schemas"]["Sd3ModelLoaderInvocation"] | components["schemas"]["Sd3TextEncoderInvocation"] | components["schemas"]["SeamlessModeInvocation"] | components["schemas"]["SeedreamImageGenerationInvocation"] | components["schemas"]["SegmentAnythingInvocation"] | components["schemas"]["ShowImageInvocation"] | components["schemas"]["SpandrelImageToImageAutoscaleInvocation"] | components["schemas"]["SpandrelImageToImageInvocation"] | components["schemas"]["StringBatchInvocation"] | components["schemas"]["StringCollectionInvocation"] | components["schemas"]["StringGenerator"] | components["schemas"]["StringInvocation"] | components["schemas"]["StringJoinInvocation"] | components["schemas"]["StringJoinThreeInvocation"] | components["schemas"]["StringReplaceInvocation"] | components["schemas"]["StringSplitInvocation"] | components["schemas"]["StringSplitNegInvocation"] | components["schemas"]["SubtractInvocation"] | components["schemas"]["T2IAdapterInvocation"] | components["schemas"]["TextLLMInvocation"] | components["schemas"]["TileToPropertiesInvocation"] | components["schemas"]["TiledMultiDiffusionDenoiseLatents"] | components["schemas"]["UnsharpMaskInvocation"] | components["schemas"]["VAELoaderInvocation"] | components["schemas"]["ZImageControlInvocation"] | components["schemas"]["ZImageDenoiseInvocation"] | components["schemas"]["ZImageDenoiseMetaInvocation"] | components["schemas"]["ZImageImageToLatentsInvocation"] | components["schemas"]["ZImageLatentsToImageInvocation"] | components["schemas"]["ZImageLoRACollectionLoader"] | components["schemas"]["ZImageLoRALoaderInvocation"] | components["schemas"]["ZImageModelLoaderInvocation"] | components["schemas"]["ZImageSeedVarianceEnhancerInvocation"] | components["schemas"]["ZImageTextEncoderInvocation"];
};
/**
* Edges
@@ -15646,7 +15646,7 @@ export type components = {
* Invocation
* @description The ID of the invocation
*/
- invocation: components["schemas"]["AddInvocation"] | components["schemas"]["AlibabaCloudImageGenerationInvocation"] | components["schemas"]["AlphaMaskToTensorInvocation"] | components["schemas"]["AnimaDenoiseInvocation"] | components["schemas"]["AnimaImageToLatentsInvocation"] | components["schemas"]["AnimaLatentsToImageInvocation"] | components["schemas"]["AnimaLoRACollectionLoader"] | components["schemas"]["AnimaLoRALoaderInvocation"] | components["schemas"]["AnimaModelLoaderInvocation"] | components["schemas"]["AnimaTextEncoderInvocation"] | components["schemas"]["ApplyMaskTensorToImageInvocation"] | components["schemas"]["ApplyMaskToImageInvocation"] | components["schemas"]["BlankImageInvocation"] | components["schemas"]["BlendLatentsInvocation"] | components["schemas"]["BooleanCollectionInvocation"] | components["schemas"]["BooleanInvocation"] | components["schemas"]["BoundingBoxInvocation"] | components["schemas"]["CLIPSkipInvocation"] | components["schemas"]["CV2InfillInvocation"] | components["schemas"]["CalculateImageTilesEvenSplitInvocation"] | components["schemas"]["CalculateImageTilesInvocation"] | components["schemas"]["CalculateImageTilesMinimumOverlapInvocation"] | components["schemas"]["CannyEdgeDetectionInvocation"] | components["schemas"]["CanvasOutputInvocation"] | components["schemas"]["CanvasPasteBackInvocation"] | components["schemas"]["CanvasV2MaskAndCropInvocation"] | components["schemas"]["CenterPadCropInvocation"] | components["schemas"]["CogView4DenoiseInvocation"] | components["schemas"]["CogView4ImageToLatentsInvocation"] | components["schemas"]["CogView4LatentsToImageInvocation"] | components["schemas"]["CogView4ModelLoaderInvocation"] | components["schemas"]["CogView4TextEncoderInvocation"] | components["schemas"]["CollectInvocation"] | components["schemas"]["ColorCorrectInvocation"] | components["schemas"]["ColorInvocation"] | components["schemas"]["ColorMapInvocation"] | components["schemas"]["CompelInvocation"] | components["schemas"]["ConditioningCollectionInvocation"] | components["schemas"]["ConditioningInvocation"] | components["schemas"]["ContentShuffleInvocation"] | components["schemas"]["ControlNetInvocation"] | components["schemas"]["CoreMetadataInvocation"] | components["schemas"]["CreateDenoiseMaskInvocation"] | components["schemas"]["CreateGradientMaskInvocation"] | components["schemas"]["CropImageToBoundingBoxInvocation"] | components["schemas"]["CropLatentsCoreInvocation"] | components["schemas"]["CvInpaintInvocation"] | components["schemas"]["DWOpenposeDetectionInvocation"] | components["schemas"]["DecodeInvisibleWatermarkInvocation"] | components["schemas"]["DenoiseLatentsInvocation"] | components["schemas"]["DenoiseLatentsMetaInvocation"] | components["schemas"]["DepthAnythingDepthEstimationInvocation"] | components["schemas"]["DivideInvocation"] | components["schemas"]["DynamicPromptInvocation"] | components["schemas"]["ESRGANInvocation"] | components["schemas"]["ExpandMaskWithFadeInvocation"] | components["schemas"]["FLUXLoRACollectionLoader"] | components["schemas"]["FaceIdentifierInvocation"] | components["schemas"]["FaceMaskInvocation"] | components["schemas"]["FaceOffInvocation"] | components["schemas"]["FloatBatchInvocation"] | components["schemas"]["FloatCollectionInvocation"] | components["schemas"]["FloatGenerator"] | components["schemas"]["FloatInvocation"] | components["schemas"]["FloatLinearRangeInvocation"] | components["schemas"]["FloatMathInvocation"] | components["schemas"]["FloatToIntegerInvocation"] | components["schemas"]["Flux2DenoiseInvocation"] | components["schemas"]["Flux2KleinLoRACollectionLoader"] | components["schemas"]["Flux2KleinLoRALoaderInvocation"] | components["schemas"]["Flux2KleinModelLoaderInvocation"] | components["schemas"]["Flux2KleinTextEncoderInvocation"] | components["schemas"]["Flux2VaeDecodeInvocation"] | components["schemas"]["Flux2VaeEncodeInvocation"] | components["schemas"]["FluxControlLoRALoaderInvocation"] | components["schemas"]["FluxControlNetInvocation"] | components["schemas"]["FluxDenoiseInvocation"] | components["schemas"]["FluxDenoiseLatentsMetaInvocation"] | components["schemas"]["FluxFillInvocation"] | components["schemas"]["FluxIPAdapterInvocation"] | components["schemas"]["FluxKontextConcatenateImagesInvocation"] | components["schemas"]["FluxKontextInvocation"] | components["schemas"]["FluxLoRALoaderInvocation"] | components["schemas"]["FluxModelLoaderInvocation"] | components["schemas"]["FluxReduxInvocation"] | components["schemas"]["FluxTextEncoderInvocation"] | components["schemas"]["FluxVaeDecodeInvocation"] | components["schemas"]["FluxVaeEncodeInvocation"] | components["schemas"]["FreeUInvocation"] | components["schemas"]["GeminiImageGenerationInvocation"] | components["schemas"]["GetMaskBoundingBoxInvocation"] | components["schemas"]["GroundingDinoInvocation"] | components["schemas"]["HEDEdgeDetectionInvocation"] | components["schemas"]["HeuristicResizeInvocation"] | components["schemas"]["IPAdapterInvocation"] | components["schemas"]["IdealSizeInvocation"] | components["schemas"]["IfInvocation"] | components["schemas"]["ImageBatchInvocation"] | components["schemas"]["ImageBlurInvocation"] | components["schemas"]["ImageChannelInvocation"] | components["schemas"]["ImageChannelMultiplyInvocation"] | components["schemas"]["ImageChannelOffsetInvocation"] | components["schemas"]["ImageCollectionInvocation"] | components["schemas"]["ImageConvertInvocation"] | components["schemas"]["ImageCropInvocation"] | components["schemas"]["ImageGenerator"] | components["schemas"]["ImageHueAdjustmentInvocation"] | components["schemas"]["ImageInverseLerpInvocation"] | components["schemas"]["ImageInvocation"] | components["schemas"]["ImageLerpInvocation"] | components["schemas"]["ImageMaskToTensorInvocation"] | components["schemas"]["ImageMultiplyInvocation"] | components["schemas"]["ImageNSFWBlurInvocation"] | components["schemas"]["ImageNoiseInvocation"] | components["schemas"]["ImagePanelLayoutInvocation"] | components["schemas"]["ImagePasteInvocation"] | components["schemas"]["ImageResizeInvocation"] | components["schemas"]["ImageScaleInvocation"] | components["schemas"]["ImageToLatentsInvocation"] | components["schemas"]["ImageWatermarkInvocation"] | components["schemas"]["InfillColorInvocation"] | components["schemas"]["InfillPatchMatchInvocation"] | components["schemas"]["InfillTileInvocation"] | components["schemas"]["IntegerBatchInvocation"] | components["schemas"]["IntegerCollectionInvocation"] | components["schemas"]["IntegerGenerator"] | components["schemas"]["IntegerInvocation"] | components["schemas"]["IntegerMathInvocation"] | components["schemas"]["InvertTensorMaskInvocation"] | components["schemas"]["InvokeAdjustImageHuePlusInvocation"] | components["schemas"]["InvokeEquivalentAchromaticLightnessInvocation"] | components["schemas"]["InvokeImageBlendInvocation"] | components["schemas"]["InvokeImageCompositorInvocation"] | components["schemas"]["InvokeImageDilateOrErodeInvocation"] | components["schemas"]["InvokeImageEnhanceInvocation"] | components["schemas"]["InvokeImageValueThresholdsInvocation"] | components["schemas"]["IterateInvocation"] | components["schemas"]["LaMaInfillInvocation"] | components["schemas"]["LatentsCollectionInvocation"] | components["schemas"]["LatentsInvocation"] | components["schemas"]["LatentsToImageInvocation"] | components["schemas"]["LineartAnimeEdgeDetectionInvocation"] | components["schemas"]["LineartEdgeDetectionInvocation"] | components["schemas"]["LlavaOnevisionVllmInvocation"] | components["schemas"]["LoRACollectionLoader"] | components["schemas"]["LoRALoaderInvocation"] | components["schemas"]["LoRASelectorInvocation"] | components["schemas"]["MLSDDetectionInvocation"] | components["schemas"]["MainModelLoaderInvocation"] | components["schemas"]["MaskCombineInvocation"] | components["schemas"]["MaskEdgeInvocation"] | components["schemas"]["MaskFromAlphaInvocation"] | components["schemas"]["MaskFromIDInvocation"] | components["schemas"]["MaskTensorToImageInvocation"] | components["schemas"]["MediaPipeFaceDetectionInvocation"] | components["schemas"]["MergeMetadataInvocation"] | components["schemas"]["MergeTilesToImageInvocation"] | components["schemas"]["MetadataFieldExtractorInvocation"] | components["schemas"]["MetadataFromImageInvocation"] | components["schemas"]["MetadataInvocation"] | components["schemas"]["MetadataItemInvocation"] | components["schemas"]["MetadataItemLinkedInvocation"] | components["schemas"]["MetadataToBoolCollectionInvocation"] | components["schemas"]["MetadataToBoolInvocation"] | components["schemas"]["MetadataToControlnetsInvocation"] | components["schemas"]["MetadataToFloatCollectionInvocation"] | components["schemas"]["MetadataToFloatInvocation"] | components["schemas"]["MetadataToIPAdaptersInvocation"] | components["schemas"]["MetadataToIntegerCollectionInvocation"] | components["schemas"]["MetadataToIntegerInvocation"] | components["schemas"]["MetadataToLorasCollectionInvocation"] | components["schemas"]["MetadataToLorasInvocation"] | components["schemas"]["MetadataToModelInvocation"] | components["schemas"]["MetadataToSDXLLorasInvocation"] | components["schemas"]["MetadataToSDXLModelInvocation"] | components["schemas"]["MetadataToSchedulerInvocation"] | components["schemas"]["MetadataToStringCollectionInvocation"] | components["schemas"]["MetadataToStringInvocation"] | components["schemas"]["MetadataToT2IAdaptersInvocation"] | components["schemas"]["MetadataToVAEInvocation"] | components["schemas"]["ModelIdentifierInvocation"] | components["schemas"]["MultiplyInvocation"] | components["schemas"]["NoiseInvocation"] | components["schemas"]["NormalMapInvocation"] | components["schemas"]["OpenAIImageGenerationInvocation"] | components["schemas"]["PBRMapsInvocation"] | components["schemas"]["PairTileImageInvocation"] | components["schemas"]["PasteImageIntoBoundingBoxInvocation"] | components["schemas"]["PiDiNetEdgeDetectionInvocation"] | components["schemas"]["PromptTemplateInvocation"] | components["schemas"]["PromptsFromFileInvocation"] | components["schemas"]["QwenImageDenoiseInvocation"] | components["schemas"]["QwenImageImageToLatentsInvocation"] | components["schemas"]["QwenImageLatentsToImageInvocation"] | components["schemas"]["QwenImageLoRACollectionLoader"] | components["schemas"]["QwenImageLoRALoaderInvocation"] | components["schemas"]["QwenImageModelLoaderInvocation"] | components["schemas"]["QwenImageTextEncoderInvocation"] | components["schemas"]["RandomFloatInvocation"] | components["schemas"]["RandomIntInvocation"] | components["schemas"]["RandomRangeInvocation"] | components["schemas"]["RangeInvocation"] | components["schemas"]["RangeOfSizeInvocation"] | components["schemas"]["RectangleMaskInvocation"] | components["schemas"]["ResizeLatentsInvocation"] | components["schemas"]["RoundInvocation"] | components["schemas"]["SD3DenoiseInvocation"] | components["schemas"]["SD3ImageToLatentsInvocation"] | components["schemas"]["SD3LatentsToImageInvocation"] | components["schemas"]["SDXLCompelPromptInvocation"] | components["schemas"]["SDXLLoRACollectionLoader"] | components["schemas"]["SDXLLoRALoaderInvocation"] | components["schemas"]["SDXLModelLoaderInvocation"] | components["schemas"]["SDXLRefinerCompelPromptInvocation"] | components["schemas"]["SDXLRefinerModelLoaderInvocation"] | components["schemas"]["SaveImageInvocation"] | components["schemas"]["ScaleLatentsInvocation"] | components["schemas"]["SchedulerInvocation"] | components["schemas"]["Sd3ModelLoaderInvocation"] | components["schemas"]["Sd3TextEncoderInvocation"] | components["schemas"]["SeamlessModeInvocation"] | components["schemas"]["SeedreamImageGenerationInvocation"] | components["schemas"]["SegmentAnythingInvocation"] | components["schemas"]["ShowImageInvocation"] | components["schemas"]["SpandrelImageToImageAutoscaleInvocation"] | components["schemas"]["SpandrelImageToImageInvocation"] | components["schemas"]["StringBatchInvocation"] | components["schemas"]["StringCollectionInvocation"] | components["schemas"]["StringGenerator"] | components["schemas"]["StringInvocation"] | components["schemas"]["StringJoinInvocation"] | components["schemas"]["StringJoinThreeInvocation"] | components["schemas"]["StringReplaceInvocation"] | components["schemas"]["StringSplitInvocation"] | components["schemas"]["StringSplitNegInvocation"] | components["schemas"]["SubtractInvocation"] | components["schemas"]["T2IAdapterInvocation"] | components["schemas"]["TextLLMInvocation"] | components["schemas"]["TileToPropertiesInvocation"] | components["schemas"]["TiledMultiDiffusionDenoiseLatents"] | components["schemas"]["UnsharpMaskInvocation"] | components["schemas"]["VAELoaderInvocation"] | components["schemas"]["ZImageControlInvocation"] | components["schemas"]["ZImageDenoiseInvocation"] | components["schemas"]["ZImageDenoiseMetaInvocation"] | components["schemas"]["ZImageImageToLatentsInvocation"] | components["schemas"]["ZImageLatentsToImageInvocation"] | components["schemas"]["ZImageLoRACollectionLoader"] | components["schemas"]["ZImageLoRALoaderInvocation"] | components["schemas"]["ZImageModelLoaderInvocation"] | components["schemas"]["ZImageSeedVarianceEnhancerInvocation"] | components["schemas"]["ZImageTextEncoderInvocation"];
+ invocation: components["schemas"]["AddInvocation"] | components["schemas"]["AlibabaCloudImageGenerationInvocation"] | components["schemas"]["AlphaMaskToTensorInvocation"] | components["schemas"]["AnimaDenoiseInvocation"] | components["schemas"]["AnimaImageToLatentsInvocation"] | components["schemas"]["AnimaLatentsToImageInvocation"] | components["schemas"]["AnimaLoRACollectionLoader"] | components["schemas"]["AnimaLoRALoaderInvocation"] | components["schemas"]["AnimaModelLoaderInvocation"] | components["schemas"]["AnimaTextEncoderInvocation"] | components["schemas"]["ApplyMaskTensorToImageInvocation"] | components["schemas"]["ApplyMaskToImageInvocation"] | components["schemas"]["BlankImageInvocation"] | components["schemas"]["BlendLatentsInvocation"] | components["schemas"]["BooleanCollectionInvocation"] | components["schemas"]["BooleanInvocation"] | components["schemas"]["BoundingBoxInvocation"] | components["schemas"]["CLIPSkipInvocation"] | components["schemas"]["CV2InfillInvocation"] | components["schemas"]["CalculateImageTilesEvenSplitInvocation"] | components["schemas"]["CalculateImageTilesInvocation"] | components["schemas"]["CalculateImageTilesMinimumOverlapInvocation"] | components["schemas"]["CannyEdgeDetectionInvocation"] | components["schemas"]["CanvasOutputInvocation"] | components["schemas"]["CanvasPasteBackInvocation"] | components["schemas"]["CanvasV2MaskAndCropInvocation"] | components["schemas"]["CenterPadCropInvocation"] | components["schemas"]["CogView4DenoiseInvocation"] | components["schemas"]["CogView4ImageToLatentsInvocation"] | components["schemas"]["CogView4LatentsToImageInvocation"] | components["schemas"]["CogView4ModelLoaderInvocation"] | components["schemas"]["CogView4TextEncoderInvocation"] | components["schemas"]["CollectInvocation"] | components["schemas"]["ColorCorrectInvocation"] | components["schemas"]["ColorInvocation"] | components["schemas"]["ColorMapInvocation"] | components["schemas"]["CompelInvocation"] | components["schemas"]["ConditioningCollectionInvocation"] | components["schemas"]["ConditioningInvocation"] | components["schemas"]["ContentShuffleInvocation"] | components["schemas"]["ControlNetInvocation"] | components["schemas"]["CoreMetadataInvocation"] | components["schemas"]["CreateDenoiseMaskInvocation"] | components["schemas"]["CreateGradientMaskInvocation"] | components["schemas"]["CropImageToBoundingBoxInvocation"] | components["schemas"]["CropLatentsCoreInvocation"] | components["schemas"]["CvInpaintInvocation"] | components["schemas"]["DWOpenposeDetectionInvocation"] | components["schemas"]["DecodeInvisibleWatermarkInvocation"] | components["schemas"]["DenoiseLatentsInvocation"] | components["schemas"]["DenoiseLatentsMetaInvocation"] | components["schemas"]["DepthAnythingDepthEstimationInvocation"] | components["schemas"]["DivideInvocation"] | components["schemas"]["DynamicPromptInvocation"] | components["schemas"]["ESRGANInvocation"] | components["schemas"]["ExpandMaskWithFadeInvocation"] | components["schemas"]["FLUXLoRACollectionLoader"] | components["schemas"]["FaceIdentifierInvocation"] | components["schemas"]["FaceMaskInvocation"] | components["schemas"]["FaceOffInvocation"] | components["schemas"]["FloatBatchInvocation"] | components["schemas"]["FloatCollectionInvocation"] | components["schemas"]["FloatGenerator"] | components["schemas"]["FloatInvocation"] | components["schemas"]["FloatLinearRangeInvocation"] | components["schemas"]["FloatMathInvocation"] | components["schemas"]["FloatToIntegerInvocation"] | components["schemas"]["Flux2DenoiseInvocation"] | components["schemas"]["Flux2KleinLoRACollectionLoader"] | components["schemas"]["Flux2KleinLoRALoaderInvocation"] | components["schemas"]["Flux2KleinModelLoaderInvocation"] | components["schemas"]["Flux2KleinTextEncoderInvocation"] | components["schemas"]["Flux2VaeDecodeInvocation"] | components["schemas"]["Flux2VaeEncodeInvocation"] | components["schemas"]["FluxControlLoRALoaderInvocation"] | components["schemas"]["FluxControlNetInvocation"] | components["schemas"]["FluxDenoiseInvocation"] | components["schemas"]["FluxDenoiseLatentsMetaInvocation"] | components["schemas"]["FluxFillInvocation"] | components["schemas"]["FluxIPAdapterInvocation"] | components["schemas"]["FluxKontextConcatenateImagesInvocation"] | components["schemas"]["FluxKontextInvocation"] | components["schemas"]["FluxLoRALoaderInvocation"] | components["schemas"]["FluxModelLoaderInvocation"] | components["schemas"]["FluxReduxInvocation"] | components["schemas"]["FluxTextEncoderInvocation"] | components["schemas"]["FluxVaeDecodeInvocation"] | components["schemas"]["FluxVaeEncodeInvocation"] | components["schemas"]["FreeUInvocation"] | components["schemas"]["GeminiImageGenerationInvocation"] | components["schemas"]["GetMaskBoundingBoxInvocation"] | components["schemas"]["GroundingDinoInvocation"] | components["schemas"]["HEDEdgeDetectionInvocation"] | components["schemas"]["HeuristicResizeInvocation"] | components["schemas"]["IPAdapterInvocation"] | components["schemas"]["IdealSizeInvocation"] | components["schemas"]["IfInvocation"] | components["schemas"]["ImageBatchInvocation"] | components["schemas"]["ImageBlurInvocation"] | components["schemas"]["ImageChannelInvocation"] | components["schemas"]["ImageChannelMultiplyInvocation"] | components["schemas"]["ImageChannelOffsetInvocation"] | components["schemas"]["ImageCollectionInvocation"] | components["schemas"]["ImageConvertInvocation"] | components["schemas"]["ImageCropInvocation"] | components["schemas"]["ImageGenerator"] | components["schemas"]["ImageHueAdjustmentInvocation"] | components["schemas"]["ImageInverseLerpInvocation"] | components["schemas"]["ImageInvocation"] | components["schemas"]["ImageLerpInvocation"] | components["schemas"]["ImageMaskToTensorInvocation"] | components["schemas"]["ImageMultiplyInvocation"] | components["schemas"]["ImageNSFWBlurInvocation"] | components["schemas"]["ImageNoiseInvocation"] | components["schemas"]["ImagePanelLayoutInvocation"] | components["schemas"]["ImagePasteInvocation"] | components["schemas"]["ImageResizeInvocation"] | components["schemas"]["ImageScaleInvocation"] | components["schemas"]["ImageToLatentsInvocation"] | components["schemas"]["ImageWatermarkInvocation"] | components["schemas"]["InfillColorInvocation"] | components["schemas"]["InfillPatchMatchInvocation"] | components["schemas"]["InfillTileInvocation"] | components["schemas"]["IntegerBatchInvocation"] | components["schemas"]["IntegerCollectionInvocation"] | components["schemas"]["IntegerGenerator"] | components["schemas"]["IntegerInvocation"] | components["schemas"]["IntegerMathInvocation"] | components["schemas"]["InvertTensorMaskInvocation"] | components["schemas"]["InvokeAdjustImageHuePlusInvocation"] | components["schemas"]["InvokeEquivalentAchromaticLightnessInvocation"] | components["schemas"]["InvokeImageBlendInvocation"] | components["schemas"]["InvokeImageCompositorInvocation"] | components["schemas"]["InvokeImageDilateOrErodeInvocation"] | components["schemas"]["InvokeImageEnhanceInvocation"] | components["schemas"]["InvokeImageValueThresholdsInvocation"] | components["schemas"]["IterateInvocation"] | components["schemas"]["LaMaInfillInvocation"] | components["schemas"]["LatentsCollectionInvocation"] | components["schemas"]["LatentsInvocation"] | components["schemas"]["LatentsToImageInvocation"] | components["schemas"]["LineartAnimeEdgeDetectionInvocation"] | components["schemas"]["LineartEdgeDetectionInvocation"] | components["schemas"]["LlavaOnevisionVllmInvocation"] | components["schemas"]["LoRACollectionLoader"] | components["schemas"]["LoRALoaderInvocation"] | components["schemas"]["LoRASelectorInvocation"] | components["schemas"]["MLSDDetectionInvocation"] | components["schemas"]["MainModelLoaderInvocation"] | components["schemas"]["MaskCombineInvocation"] | components["schemas"]["MaskEdgeInvocation"] | components["schemas"]["MaskFromAlphaInvocation"] | components["schemas"]["MaskFromIDInvocation"] | components["schemas"]["MaskTensorToImageInvocation"] | components["schemas"]["MediaPipeFaceDetectionInvocation"] | components["schemas"]["MergeMetadataInvocation"] | components["schemas"]["MergeTilesToImageInvocation"] | components["schemas"]["MetadataFieldExtractorInvocation"] | components["schemas"]["MetadataFromImageInvocation"] | components["schemas"]["MetadataInvocation"] | components["schemas"]["MetadataItemInvocation"] | components["schemas"]["MetadataItemLinkedInvocation"] | components["schemas"]["MetadataToBoolCollectionInvocation"] | components["schemas"]["MetadataToBoolInvocation"] | components["schemas"]["MetadataToControlnetsInvocation"] | components["schemas"]["MetadataToFloatCollectionInvocation"] | components["schemas"]["MetadataToFloatInvocation"] | components["schemas"]["MetadataToIPAdaptersInvocation"] | components["schemas"]["MetadataToIntegerCollectionInvocation"] | components["schemas"]["MetadataToIntegerInvocation"] | components["schemas"]["MetadataToLorasCollectionInvocation"] | components["schemas"]["MetadataToLorasInvocation"] | components["schemas"]["MetadataToModelInvocation"] | components["schemas"]["MetadataToSDXLLorasInvocation"] | components["schemas"]["MetadataToSDXLModelInvocation"] | components["schemas"]["MetadataToSchedulerInvocation"] | components["schemas"]["MetadataToStringCollectionInvocation"] | components["schemas"]["MetadataToStringInvocation"] | components["schemas"]["MetadataToT2IAdaptersInvocation"] | components["schemas"]["MetadataToVAEInvocation"] | components["schemas"]["ModelIdentifierInvocation"] | components["schemas"]["MultiplyInvocation"] | components["schemas"]["NoiseInvocation"] | components["schemas"]["NormalMapInvocation"] | components["schemas"]["OklabUnsharpMaskInvocation"] | components["schemas"]["OklchImageHueAdjustmentInvocation"] | components["schemas"]["OpenAIImageGenerationInvocation"] | components["schemas"]["PBRMapsInvocation"] | components["schemas"]["PairTileImageInvocation"] | components["schemas"]["PasteImageIntoBoundingBoxInvocation"] | components["schemas"]["PiDiNetEdgeDetectionInvocation"] | components["schemas"]["PromptTemplateInvocation"] | components["schemas"]["PromptsFromFileInvocation"] | components["schemas"]["QwenImageDenoiseInvocation"] | components["schemas"]["QwenImageImageToLatentsInvocation"] | components["schemas"]["QwenImageLatentsToImageInvocation"] | components["schemas"]["QwenImageLoRACollectionLoader"] | components["schemas"]["QwenImageLoRALoaderInvocation"] | components["schemas"]["QwenImageModelLoaderInvocation"] | components["schemas"]["QwenImageTextEncoderInvocation"] | components["schemas"]["RandomFloatInvocation"] | components["schemas"]["RandomIntInvocation"] | components["schemas"]["RandomRangeInvocation"] | components["schemas"]["RangeInvocation"] | components["schemas"]["RangeOfSizeInvocation"] | components["schemas"]["RectangleMaskInvocation"] | components["schemas"]["ResizeLatentsInvocation"] | components["schemas"]["RoundInvocation"] | components["schemas"]["SD3DenoiseInvocation"] | components["schemas"]["SD3ImageToLatentsInvocation"] | components["schemas"]["SD3LatentsToImageInvocation"] | components["schemas"]["SDXLCompelPromptInvocation"] | components["schemas"]["SDXLLoRACollectionLoader"] | components["schemas"]["SDXLLoRALoaderInvocation"] | components["schemas"]["SDXLModelLoaderInvocation"] | components["schemas"]["SDXLRefinerCompelPromptInvocation"] | components["schemas"]["SDXLRefinerModelLoaderInvocation"] | components["schemas"]["SaveImageInvocation"] | components["schemas"]["ScaleLatentsInvocation"] | components["schemas"]["SchedulerInvocation"] | components["schemas"]["Sd3ModelLoaderInvocation"] | components["schemas"]["Sd3TextEncoderInvocation"] | components["schemas"]["SeamlessModeInvocation"] | components["schemas"]["SeedreamImageGenerationInvocation"] | components["schemas"]["SegmentAnythingInvocation"] | components["schemas"]["ShowImageInvocation"] | components["schemas"]["SpandrelImageToImageAutoscaleInvocation"] | components["schemas"]["SpandrelImageToImageInvocation"] | components["schemas"]["StringBatchInvocation"] | components["schemas"]["StringCollectionInvocation"] | components["schemas"]["StringGenerator"] | components["schemas"]["StringInvocation"] | components["schemas"]["StringJoinInvocation"] | components["schemas"]["StringJoinThreeInvocation"] | components["schemas"]["StringReplaceInvocation"] | components["schemas"]["StringSplitInvocation"] | components["schemas"]["StringSplitNegInvocation"] | components["schemas"]["SubtractInvocation"] | components["schemas"]["T2IAdapterInvocation"] | components["schemas"]["TextLLMInvocation"] | components["schemas"]["TileToPropertiesInvocation"] | components["schemas"]["TiledMultiDiffusionDenoiseLatents"] | components["schemas"]["UnsharpMaskInvocation"] | components["schemas"]["VAELoaderInvocation"] | components["schemas"]["ZImageControlInvocation"] | components["schemas"]["ZImageDenoiseInvocation"] | components["schemas"]["ZImageDenoiseMetaInvocation"] | components["schemas"]["ZImageImageToLatentsInvocation"] | components["schemas"]["ZImageLatentsToImageInvocation"] | components["schemas"]["ZImageLoRACollectionLoader"] | components["schemas"]["ZImageLoRALoaderInvocation"] | components["schemas"]["ZImageModelLoaderInvocation"] | components["schemas"]["ZImageSeedVarianceEnhancerInvocation"] | components["schemas"]["ZImageTextEncoderInvocation"];
/**
* Invocation Source Id
* @description The ID of the prepared invocation's source node
@@ -15710,7 +15710,7 @@ export type components = {
* Invocation
* @description The ID of the invocation
*/
- invocation: components["schemas"]["AddInvocation"] | components["schemas"]["AlibabaCloudImageGenerationInvocation"] | components["schemas"]["AlphaMaskToTensorInvocation"] | components["schemas"]["AnimaDenoiseInvocation"] | components["schemas"]["AnimaImageToLatentsInvocation"] | components["schemas"]["AnimaLatentsToImageInvocation"] | components["schemas"]["AnimaLoRACollectionLoader"] | components["schemas"]["AnimaLoRALoaderInvocation"] | components["schemas"]["AnimaModelLoaderInvocation"] | components["schemas"]["AnimaTextEncoderInvocation"] | components["schemas"]["ApplyMaskTensorToImageInvocation"] | components["schemas"]["ApplyMaskToImageInvocation"] | components["schemas"]["BlankImageInvocation"] | components["schemas"]["BlendLatentsInvocation"] | components["schemas"]["BooleanCollectionInvocation"] | components["schemas"]["BooleanInvocation"] | components["schemas"]["BoundingBoxInvocation"] | components["schemas"]["CLIPSkipInvocation"] | components["schemas"]["CV2InfillInvocation"] | components["schemas"]["CalculateImageTilesEvenSplitInvocation"] | components["schemas"]["CalculateImageTilesInvocation"] | components["schemas"]["CalculateImageTilesMinimumOverlapInvocation"] | components["schemas"]["CannyEdgeDetectionInvocation"] | components["schemas"]["CanvasOutputInvocation"] | components["schemas"]["CanvasPasteBackInvocation"] | components["schemas"]["CanvasV2MaskAndCropInvocation"] | components["schemas"]["CenterPadCropInvocation"] | components["schemas"]["CogView4DenoiseInvocation"] | components["schemas"]["CogView4ImageToLatentsInvocation"] | components["schemas"]["CogView4LatentsToImageInvocation"] | components["schemas"]["CogView4ModelLoaderInvocation"] | components["schemas"]["CogView4TextEncoderInvocation"] | components["schemas"]["CollectInvocation"] | components["schemas"]["ColorCorrectInvocation"] | components["schemas"]["ColorInvocation"] | components["schemas"]["ColorMapInvocation"] | components["schemas"]["CompelInvocation"] | components["schemas"]["ConditioningCollectionInvocation"] | components["schemas"]["ConditioningInvocation"] | components["schemas"]["ContentShuffleInvocation"] | components["schemas"]["ControlNetInvocation"] | components["schemas"]["CoreMetadataInvocation"] | components["schemas"]["CreateDenoiseMaskInvocation"] | components["schemas"]["CreateGradientMaskInvocation"] | components["schemas"]["CropImageToBoundingBoxInvocation"] | components["schemas"]["CropLatentsCoreInvocation"] | components["schemas"]["CvInpaintInvocation"] | components["schemas"]["DWOpenposeDetectionInvocation"] | components["schemas"]["DecodeInvisibleWatermarkInvocation"] | components["schemas"]["DenoiseLatentsInvocation"] | components["schemas"]["DenoiseLatentsMetaInvocation"] | components["schemas"]["DepthAnythingDepthEstimationInvocation"] | components["schemas"]["DivideInvocation"] | components["schemas"]["DynamicPromptInvocation"] | components["schemas"]["ESRGANInvocation"] | components["schemas"]["ExpandMaskWithFadeInvocation"] | components["schemas"]["FLUXLoRACollectionLoader"] | components["schemas"]["FaceIdentifierInvocation"] | components["schemas"]["FaceMaskInvocation"] | components["schemas"]["FaceOffInvocation"] | components["schemas"]["FloatBatchInvocation"] | components["schemas"]["FloatCollectionInvocation"] | components["schemas"]["FloatGenerator"] | components["schemas"]["FloatInvocation"] | components["schemas"]["FloatLinearRangeInvocation"] | components["schemas"]["FloatMathInvocation"] | components["schemas"]["FloatToIntegerInvocation"] | components["schemas"]["Flux2DenoiseInvocation"] | components["schemas"]["Flux2KleinLoRACollectionLoader"] | components["schemas"]["Flux2KleinLoRALoaderInvocation"] | components["schemas"]["Flux2KleinModelLoaderInvocation"] | components["schemas"]["Flux2KleinTextEncoderInvocation"] | components["schemas"]["Flux2VaeDecodeInvocation"] | components["schemas"]["Flux2VaeEncodeInvocation"] | components["schemas"]["FluxControlLoRALoaderInvocation"] | components["schemas"]["FluxControlNetInvocation"] | components["schemas"]["FluxDenoiseInvocation"] | components["schemas"]["FluxDenoiseLatentsMetaInvocation"] | components["schemas"]["FluxFillInvocation"] | components["schemas"]["FluxIPAdapterInvocation"] | components["schemas"]["FluxKontextConcatenateImagesInvocation"] | components["schemas"]["FluxKontextInvocation"] | components["schemas"]["FluxLoRALoaderInvocation"] | components["schemas"]["FluxModelLoaderInvocation"] | components["schemas"]["FluxReduxInvocation"] | components["schemas"]["FluxTextEncoderInvocation"] | components["schemas"]["FluxVaeDecodeInvocation"] | components["schemas"]["FluxVaeEncodeInvocation"] | components["schemas"]["FreeUInvocation"] | components["schemas"]["GeminiImageGenerationInvocation"] | components["schemas"]["GetMaskBoundingBoxInvocation"] | components["schemas"]["GroundingDinoInvocation"] | components["schemas"]["HEDEdgeDetectionInvocation"] | components["schemas"]["HeuristicResizeInvocation"] | components["schemas"]["IPAdapterInvocation"] | components["schemas"]["IdealSizeInvocation"] | components["schemas"]["IfInvocation"] | components["schemas"]["ImageBatchInvocation"] | components["schemas"]["ImageBlurInvocation"] | components["schemas"]["ImageChannelInvocation"] | components["schemas"]["ImageChannelMultiplyInvocation"] | components["schemas"]["ImageChannelOffsetInvocation"] | components["schemas"]["ImageCollectionInvocation"] | components["schemas"]["ImageConvertInvocation"] | components["schemas"]["ImageCropInvocation"] | components["schemas"]["ImageGenerator"] | components["schemas"]["ImageHueAdjustmentInvocation"] | components["schemas"]["ImageInverseLerpInvocation"] | components["schemas"]["ImageInvocation"] | components["schemas"]["ImageLerpInvocation"] | components["schemas"]["ImageMaskToTensorInvocation"] | components["schemas"]["ImageMultiplyInvocation"] | components["schemas"]["ImageNSFWBlurInvocation"] | components["schemas"]["ImageNoiseInvocation"] | components["schemas"]["ImagePanelLayoutInvocation"] | components["schemas"]["ImagePasteInvocation"] | components["schemas"]["ImageResizeInvocation"] | components["schemas"]["ImageScaleInvocation"] | components["schemas"]["ImageToLatentsInvocation"] | components["schemas"]["ImageWatermarkInvocation"] | components["schemas"]["InfillColorInvocation"] | components["schemas"]["InfillPatchMatchInvocation"] | components["schemas"]["InfillTileInvocation"] | components["schemas"]["IntegerBatchInvocation"] | components["schemas"]["IntegerCollectionInvocation"] | components["schemas"]["IntegerGenerator"] | components["schemas"]["IntegerInvocation"] | components["schemas"]["IntegerMathInvocation"] | components["schemas"]["InvertTensorMaskInvocation"] | components["schemas"]["InvokeAdjustImageHuePlusInvocation"] | components["schemas"]["InvokeEquivalentAchromaticLightnessInvocation"] | components["schemas"]["InvokeImageBlendInvocation"] | components["schemas"]["InvokeImageCompositorInvocation"] | components["schemas"]["InvokeImageDilateOrErodeInvocation"] | components["schemas"]["InvokeImageEnhanceInvocation"] | components["schemas"]["InvokeImageValueThresholdsInvocation"] | components["schemas"]["IterateInvocation"] | components["schemas"]["LaMaInfillInvocation"] | components["schemas"]["LatentsCollectionInvocation"] | components["schemas"]["LatentsInvocation"] | components["schemas"]["LatentsToImageInvocation"] | components["schemas"]["LineartAnimeEdgeDetectionInvocation"] | components["schemas"]["LineartEdgeDetectionInvocation"] | components["schemas"]["LlavaOnevisionVllmInvocation"] | components["schemas"]["LoRACollectionLoader"] | components["schemas"]["LoRALoaderInvocation"] | components["schemas"]["LoRASelectorInvocation"] | components["schemas"]["MLSDDetectionInvocation"] | components["schemas"]["MainModelLoaderInvocation"] | components["schemas"]["MaskCombineInvocation"] | components["schemas"]["MaskEdgeInvocation"] | components["schemas"]["MaskFromAlphaInvocation"] | components["schemas"]["MaskFromIDInvocation"] | components["schemas"]["MaskTensorToImageInvocation"] | components["schemas"]["MediaPipeFaceDetectionInvocation"] | components["schemas"]["MergeMetadataInvocation"] | components["schemas"]["MergeTilesToImageInvocation"] | components["schemas"]["MetadataFieldExtractorInvocation"] | components["schemas"]["MetadataFromImageInvocation"] | components["schemas"]["MetadataInvocation"] | components["schemas"]["MetadataItemInvocation"] | components["schemas"]["MetadataItemLinkedInvocation"] | components["schemas"]["MetadataToBoolCollectionInvocation"] | components["schemas"]["MetadataToBoolInvocation"] | components["schemas"]["MetadataToControlnetsInvocation"] | components["schemas"]["MetadataToFloatCollectionInvocation"] | components["schemas"]["MetadataToFloatInvocation"] | components["schemas"]["MetadataToIPAdaptersInvocation"] | components["schemas"]["MetadataToIntegerCollectionInvocation"] | components["schemas"]["MetadataToIntegerInvocation"] | components["schemas"]["MetadataToLorasCollectionInvocation"] | components["schemas"]["MetadataToLorasInvocation"] | components["schemas"]["MetadataToModelInvocation"] | components["schemas"]["MetadataToSDXLLorasInvocation"] | components["schemas"]["MetadataToSDXLModelInvocation"] | components["schemas"]["MetadataToSchedulerInvocation"] | components["schemas"]["MetadataToStringCollectionInvocation"] | components["schemas"]["MetadataToStringInvocation"] | components["schemas"]["MetadataToT2IAdaptersInvocation"] | components["schemas"]["MetadataToVAEInvocation"] | components["schemas"]["ModelIdentifierInvocation"] | components["schemas"]["MultiplyInvocation"] | components["schemas"]["NoiseInvocation"] | components["schemas"]["NormalMapInvocation"] | components["schemas"]["OpenAIImageGenerationInvocation"] | components["schemas"]["PBRMapsInvocation"] | components["schemas"]["PairTileImageInvocation"] | components["schemas"]["PasteImageIntoBoundingBoxInvocation"] | components["schemas"]["PiDiNetEdgeDetectionInvocation"] | components["schemas"]["PromptTemplateInvocation"] | components["schemas"]["PromptsFromFileInvocation"] | components["schemas"]["QwenImageDenoiseInvocation"] | components["schemas"]["QwenImageImageToLatentsInvocation"] | components["schemas"]["QwenImageLatentsToImageInvocation"] | components["schemas"]["QwenImageLoRACollectionLoader"] | components["schemas"]["QwenImageLoRALoaderInvocation"] | components["schemas"]["QwenImageModelLoaderInvocation"] | components["schemas"]["QwenImageTextEncoderInvocation"] | components["schemas"]["RandomFloatInvocation"] | components["schemas"]["RandomIntInvocation"] | components["schemas"]["RandomRangeInvocation"] | components["schemas"]["RangeInvocation"] | components["schemas"]["RangeOfSizeInvocation"] | components["schemas"]["RectangleMaskInvocation"] | components["schemas"]["ResizeLatentsInvocation"] | components["schemas"]["RoundInvocation"] | components["schemas"]["SD3DenoiseInvocation"] | components["schemas"]["SD3ImageToLatentsInvocation"] | components["schemas"]["SD3LatentsToImageInvocation"] | components["schemas"]["SDXLCompelPromptInvocation"] | components["schemas"]["SDXLLoRACollectionLoader"] | components["schemas"]["SDXLLoRALoaderInvocation"] | components["schemas"]["SDXLModelLoaderInvocation"] | components["schemas"]["SDXLRefinerCompelPromptInvocation"] | components["schemas"]["SDXLRefinerModelLoaderInvocation"] | components["schemas"]["SaveImageInvocation"] | components["schemas"]["ScaleLatentsInvocation"] | components["schemas"]["SchedulerInvocation"] | components["schemas"]["Sd3ModelLoaderInvocation"] | components["schemas"]["Sd3TextEncoderInvocation"] | components["schemas"]["SeamlessModeInvocation"] | components["schemas"]["SeedreamImageGenerationInvocation"] | components["schemas"]["SegmentAnythingInvocation"] | components["schemas"]["ShowImageInvocation"] | components["schemas"]["SpandrelImageToImageAutoscaleInvocation"] | components["schemas"]["SpandrelImageToImageInvocation"] | components["schemas"]["StringBatchInvocation"] | components["schemas"]["StringCollectionInvocation"] | components["schemas"]["StringGenerator"] | components["schemas"]["StringInvocation"] | components["schemas"]["StringJoinInvocation"] | components["schemas"]["StringJoinThreeInvocation"] | components["schemas"]["StringReplaceInvocation"] | components["schemas"]["StringSplitInvocation"] | components["schemas"]["StringSplitNegInvocation"] | components["schemas"]["SubtractInvocation"] | components["schemas"]["T2IAdapterInvocation"] | components["schemas"]["TextLLMInvocation"] | components["schemas"]["TileToPropertiesInvocation"] | components["schemas"]["TiledMultiDiffusionDenoiseLatents"] | components["schemas"]["UnsharpMaskInvocation"] | components["schemas"]["VAELoaderInvocation"] | components["schemas"]["ZImageControlInvocation"] | components["schemas"]["ZImageDenoiseInvocation"] | components["schemas"]["ZImageDenoiseMetaInvocation"] | components["schemas"]["ZImageImageToLatentsInvocation"] | components["schemas"]["ZImageLatentsToImageInvocation"] | components["schemas"]["ZImageLoRACollectionLoader"] | components["schemas"]["ZImageLoRALoaderInvocation"] | components["schemas"]["ZImageModelLoaderInvocation"] | components["schemas"]["ZImageSeedVarianceEnhancerInvocation"] | components["schemas"]["ZImageTextEncoderInvocation"];
+ invocation: components["schemas"]["AddInvocation"] | components["schemas"]["AlibabaCloudImageGenerationInvocation"] | components["schemas"]["AlphaMaskToTensorInvocation"] | components["schemas"]["AnimaDenoiseInvocation"] | components["schemas"]["AnimaImageToLatentsInvocation"] | components["schemas"]["AnimaLatentsToImageInvocation"] | components["schemas"]["AnimaLoRACollectionLoader"] | components["schemas"]["AnimaLoRALoaderInvocation"] | components["schemas"]["AnimaModelLoaderInvocation"] | components["schemas"]["AnimaTextEncoderInvocation"] | components["schemas"]["ApplyMaskTensorToImageInvocation"] | components["schemas"]["ApplyMaskToImageInvocation"] | components["schemas"]["BlankImageInvocation"] | components["schemas"]["BlendLatentsInvocation"] | components["schemas"]["BooleanCollectionInvocation"] | components["schemas"]["BooleanInvocation"] | components["schemas"]["BoundingBoxInvocation"] | components["schemas"]["CLIPSkipInvocation"] | components["schemas"]["CV2InfillInvocation"] | components["schemas"]["CalculateImageTilesEvenSplitInvocation"] | components["schemas"]["CalculateImageTilesInvocation"] | components["schemas"]["CalculateImageTilesMinimumOverlapInvocation"] | components["schemas"]["CannyEdgeDetectionInvocation"] | components["schemas"]["CanvasOutputInvocation"] | components["schemas"]["CanvasPasteBackInvocation"] | components["schemas"]["CanvasV2MaskAndCropInvocation"] | components["schemas"]["CenterPadCropInvocation"] | components["schemas"]["CogView4DenoiseInvocation"] | components["schemas"]["CogView4ImageToLatentsInvocation"] | components["schemas"]["CogView4LatentsToImageInvocation"] | components["schemas"]["CogView4ModelLoaderInvocation"] | components["schemas"]["CogView4TextEncoderInvocation"] | components["schemas"]["CollectInvocation"] | components["schemas"]["ColorCorrectInvocation"] | components["schemas"]["ColorInvocation"] | components["schemas"]["ColorMapInvocation"] | components["schemas"]["CompelInvocation"] | components["schemas"]["ConditioningCollectionInvocation"] | components["schemas"]["ConditioningInvocation"] | components["schemas"]["ContentShuffleInvocation"] | components["schemas"]["ControlNetInvocation"] | components["schemas"]["CoreMetadataInvocation"] | components["schemas"]["CreateDenoiseMaskInvocation"] | components["schemas"]["CreateGradientMaskInvocation"] | components["schemas"]["CropImageToBoundingBoxInvocation"] | components["schemas"]["CropLatentsCoreInvocation"] | components["schemas"]["CvInpaintInvocation"] | components["schemas"]["DWOpenposeDetectionInvocation"] | components["schemas"]["DecodeInvisibleWatermarkInvocation"] | components["schemas"]["DenoiseLatentsInvocation"] | components["schemas"]["DenoiseLatentsMetaInvocation"] | components["schemas"]["DepthAnythingDepthEstimationInvocation"] | components["schemas"]["DivideInvocation"] | components["schemas"]["DynamicPromptInvocation"] | components["schemas"]["ESRGANInvocation"] | components["schemas"]["ExpandMaskWithFadeInvocation"] | components["schemas"]["FLUXLoRACollectionLoader"] | components["schemas"]["FaceIdentifierInvocation"] | components["schemas"]["FaceMaskInvocation"] | components["schemas"]["FaceOffInvocation"] | components["schemas"]["FloatBatchInvocation"] | components["schemas"]["FloatCollectionInvocation"] | components["schemas"]["FloatGenerator"] | components["schemas"]["FloatInvocation"] | components["schemas"]["FloatLinearRangeInvocation"] | components["schemas"]["FloatMathInvocation"] | components["schemas"]["FloatToIntegerInvocation"] | components["schemas"]["Flux2DenoiseInvocation"] | components["schemas"]["Flux2KleinLoRACollectionLoader"] | components["schemas"]["Flux2KleinLoRALoaderInvocation"] | components["schemas"]["Flux2KleinModelLoaderInvocation"] | components["schemas"]["Flux2KleinTextEncoderInvocation"] | components["schemas"]["Flux2VaeDecodeInvocation"] | components["schemas"]["Flux2VaeEncodeInvocation"] | components["schemas"]["FluxControlLoRALoaderInvocation"] | components["schemas"]["FluxControlNetInvocation"] | components["schemas"]["FluxDenoiseInvocation"] | components["schemas"]["FluxDenoiseLatentsMetaInvocation"] | components["schemas"]["FluxFillInvocation"] | components["schemas"]["FluxIPAdapterInvocation"] | components["schemas"]["FluxKontextConcatenateImagesInvocation"] | components["schemas"]["FluxKontextInvocation"] | components["schemas"]["FluxLoRALoaderInvocation"] | components["schemas"]["FluxModelLoaderInvocation"] | components["schemas"]["FluxReduxInvocation"] | components["schemas"]["FluxTextEncoderInvocation"] | components["schemas"]["FluxVaeDecodeInvocation"] | components["schemas"]["FluxVaeEncodeInvocation"] | components["schemas"]["FreeUInvocation"] | components["schemas"]["GeminiImageGenerationInvocation"] | components["schemas"]["GetMaskBoundingBoxInvocation"] | components["schemas"]["GroundingDinoInvocation"] | components["schemas"]["HEDEdgeDetectionInvocation"] | components["schemas"]["HeuristicResizeInvocation"] | components["schemas"]["IPAdapterInvocation"] | components["schemas"]["IdealSizeInvocation"] | components["schemas"]["IfInvocation"] | components["schemas"]["ImageBatchInvocation"] | components["schemas"]["ImageBlurInvocation"] | components["schemas"]["ImageChannelInvocation"] | components["schemas"]["ImageChannelMultiplyInvocation"] | components["schemas"]["ImageChannelOffsetInvocation"] | components["schemas"]["ImageCollectionInvocation"] | components["schemas"]["ImageConvertInvocation"] | components["schemas"]["ImageCropInvocation"] | components["schemas"]["ImageGenerator"] | components["schemas"]["ImageHueAdjustmentInvocation"] | components["schemas"]["ImageInverseLerpInvocation"] | components["schemas"]["ImageInvocation"] | components["schemas"]["ImageLerpInvocation"] | components["schemas"]["ImageMaskToTensorInvocation"] | components["schemas"]["ImageMultiplyInvocation"] | components["schemas"]["ImageNSFWBlurInvocation"] | components["schemas"]["ImageNoiseInvocation"] | components["schemas"]["ImagePanelLayoutInvocation"] | components["schemas"]["ImagePasteInvocation"] | components["schemas"]["ImageResizeInvocation"] | components["schemas"]["ImageScaleInvocation"] | components["schemas"]["ImageToLatentsInvocation"] | components["schemas"]["ImageWatermarkInvocation"] | components["schemas"]["InfillColorInvocation"] | components["schemas"]["InfillPatchMatchInvocation"] | components["schemas"]["InfillTileInvocation"] | components["schemas"]["IntegerBatchInvocation"] | components["schemas"]["IntegerCollectionInvocation"] | components["schemas"]["IntegerGenerator"] | components["schemas"]["IntegerInvocation"] | components["schemas"]["IntegerMathInvocation"] | components["schemas"]["InvertTensorMaskInvocation"] | components["schemas"]["InvokeAdjustImageHuePlusInvocation"] | components["schemas"]["InvokeEquivalentAchromaticLightnessInvocation"] | components["schemas"]["InvokeImageBlendInvocation"] | components["schemas"]["InvokeImageCompositorInvocation"] | components["schemas"]["InvokeImageDilateOrErodeInvocation"] | components["schemas"]["InvokeImageEnhanceInvocation"] | components["schemas"]["InvokeImageValueThresholdsInvocation"] | components["schemas"]["IterateInvocation"] | components["schemas"]["LaMaInfillInvocation"] | components["schemas"]["LatentsCollectionInvocation"] | components["schemas"]["LatentsInvocation"] | components["schemas"]["LatentsToImageInvocation"] | components["schemas"]["LineartAnimeEdgeDetectionInvocation"] | components["schemas"]["LineartEdgeDetectionInvocation"] | components["schemas"]["LlavaOnevisionVllmInvocation"] | components["schemas"]["LoRACollectionLoader"] | components["schemas"]["LoRALoaderInvocation"] | components["schemas"]["LoRASelectorInvocation"] | components["schemas"]["MLSDDetectionInvocation"] | components["schemas"]["MainModelLoaderInvocation"] | components["schemas"]["MaskCombineInvocation"] | components["schemas"]["MaskEdgeInvocation"] | components["schemas"]["MaskFromAlphaInvocation"] | components["schemas"]["MaskFromIDInvocation"] | components["schemas"]["MaskTensorToImageInvocation"] | components["schemas"]["MediaPipeFaceDetectionInvocation"] | components["schemas"]["MergeMetadataInvocation"] | components["schemas"]["MergeTilesToImageInvocation"] | components["schemas"]["MetadataFieldExtractorInvocation"] | components["schemas"]["MetadataFromImageInvocation"] | components["schemas"]["MetadataInvocation"] | components["schemas"]["MetadataItemInvocation"] | components["schemas"]["MetadataItemLinkedInvocation"] | components["schemas"]["MetadataToBoolCollectionInvocation"] | components["schemas"]["MetadataToBoolInvocation"] | components["schemas"]["MetadataToControlnetsInvocation"] | components["schemas"]["MetadataToFloatCollectionInvocation"] | components["schemas"]["MetadataToFloatInvocation"] | components["schemas"]["MetadataToIPAdaptersInvocation"] | components["schemas"]["MetadataToIntegerCollectionInvocation"] | components["schemas"]["MetadataToIntegerInvocation"] | components["schemas"]["MetadataToLorasCollectionInvocation"] | components["schemas"]["MetadataToLorasInvocation"] | components["schemas"]["MetadataToModelInvocation"] | components["schemas"]["MetadataToSDXLLorasInvocation"] | components["schemas"]["MetadataToSDXLModelInvocation"] | components["schemas"]["MetadataToSchedulerInvocation"] | components["schemas"]["MetadataToStringCollectionInvocation"] | components["schemas"]["MetadataToStringInvocation"] | components["schemas"]["MetadataToT2IAdaptersInvocation"] | components["schemas"]["MetadataToVAEInvocation"] | components["schemas"]["ModelIdentifierInvocation"] | components["schemas"]["MultiplyInvocation"] | components["schemas"]["NoiseInvocation"] | components["schemas"]["NormalMapInvocation"] | components["schemas"]["OklabUnsharpMaskInvocation"] | components["schemas"]["OklchImageHueAdjustmentInvocation"] | components["schemas"]["OpenAIImageGenerationInvocation"] | components["schemas"]["PBRMapsInvocation"] | components["schemas"]["PairTileImageInvocation"] | components["schemas"]["PasteImageIntoBoundingBoxInvocation"] | components["schemas"]["PiDiNetEdgeDetectionInvocation"] | components["schemas"]["PromptTemplateInvocation"] | components["schemas"]["PromptsFromFileInvocation"] | components["schemas"]["QwenImageDenoiseInvocation"] | components["schemas"]["QwenImageImageToLatentsInvocation"] | components["schemas"]["QwenImageLatentsToImageInvocation"] | components["schemas"]["QwenImageLoRACollectionLoader"] | components["schemas"]["QwenImageLoRALoaderInvocation"] | components["schemas"]["QwenImageModelLoaderInvocation"] | components["schemas"]["QwenImageTextEncoderInvocation"] | components["schemas"]["RandomFloatInvocation"] | components["schemas"]["RandomIntInvocation"] | components["schemas"]["RandomRangeInvocation"] | components["schemas"]["RangeInvocation"] | components["schemas"]["RangeOfSizeInvocation"] | components["schemas"]["RectangleMaskInvocation"] | components["schemas"]["ResizeLatentsInvocation"] | components["schemas"]["RoundInvocation"] | components["schemas"]["SD3DenoiseInvocation"] | components["schemas"]["SD3ImageToLatentsInvocation"] | components["schemas"]["SD3LatentsToImageInvocation"] | components["schemas"]["SDXLCompelPromptInvocation"] | components["schemas"]["SDXLLoRACollectionLoader"] | components["schemas"]["SDXLLoRALoaderInvocation"] | components["schemas"]["SDXLModelLoaderInvocation"] | components["schemas"]["SDXLRefinerCompelPromptInvocation"] | components["schemas"]["SDXLRefinerModelLoaderInvocation"] | components["schemas"]["SaveImageInvocation"] | components["schemas"]["ScaleLatentsInvocation"] | components["schemas"]["SchedulerInvocation"] | components["schemas"]["Sd3ModelLoaderInvocation"] | components["schemas"]["Sd3TextEncoderInvocation"] | components["schemas"]["SeamlessModeInvocation"] | components["schemas"]["SeedreamImageGenerationInvocation"] | components["schemas"]["SegmentAnythingInvocation"] | components["schemas"]["ShowImageInvocation"] | components["schemas"]["SpandrelImageToImageAutoscaleInvocation"] | components["schemas"]["SpandrelImageToImageInvocation"] | components["schemas"]["StringBatchInvocation"] | components["schemas"]["StringCollectionInvocation"] | components["schemas"]["StringGenerator"] | components["schemas"]["StringInvocation"] | components["schemas"]["StringJoinInvocation"] | components["schemas"]["StringJoinThreeInvocation"] | components["schemas"]["StringReplaceInvocation"] | components["schemas"]["StringSplitInvocation"] | components["schemas"]["StringSplitNegInvocation"] | components["schemas"]["SubtractInvocation"] | components["schemas"]["T2IAdapterInvocation"] | components["schemas"]["TextLLMInvocation"] | components["schemas"]["TileToPropertiesInvocation"] | components["schemas"]["TiledMultiDiffusionDenoiseLatents"] | components["schemas"]["UnsharpMaskInvocation"] | components["schemas"]["VAELoaderInvocation"] | components["schemas"]["ZImageControlInvocation"] | components["schemas"]["ZImageDenoiseInvocation"] | components["schemas"]["ZImageDenoiseMetaInvocation"] | components["schemas"]["ZImageImageToLatentsInvocation"] | components["schemas"]["ZImageLatentsToImageInvocation"] | components["schemas"]["ZImageLoRACollectionLoader"] | components["schemas"]["ZImageLoRALoaderInvocation"] | components["schemas"]["ZImageModelLoaderInvocation"] | components["schemas"]["ZImageSeedVarianceEnhancerInvocation"] | components["schemas"]["ZImageTextEncoderInvocation"];
/**
* Invocation Source Id
* @description The ID of the prepared invocation's source node
@@ -15840,6 +15840,7 @@ export type components = {
img_conv: components["schemas"]["ImageOutput"];
img_crop: components["schemas"]["ImageOutput"];
img_hue_adjust: components["schemas"]["ImageOutput"];
+ img_hue_adjust_oklch: components["schemas"]["ImageOutput"];
img_ilerp: components["schemas"]["ImageOutput"];
img_lerp: components["schemas"]["ImageOutput"];
img_mul: components["schemas"]["ImageOutput"];
@@ -15974,6 +15975,7 @@ export type components = {
tiled_multi_diffusion_denoise_latents: components["schemas"]["LatentsOutput"];
tomask: components["schemas"]["ImageOutput"];
unsharp_mask: components["schemas"]["ImageOutput"];
+ unsharp_mask_oklab: components["schemas"]["ImageOutput"];
vae_loader: components["schemas"]["VAEOutput"];
z_image_control: components["schemas"]["ZImageControlOutput"];
z_image_denoise: components["schemas"]["LatentsOutput"];
@@ -16038,7 +16040,7 @@ export type components = {
* Invocation
* @description The ID of the invocation
*/
- invocation: components["schemas"]["AddInvocation"] | components["schemas"]["AlibabaCloudImageGenerationInvocation"] | components["schemas"]["AlphaMaskToTensorInvocation"] | components["schemas"]["AnimaDenoiseInvocation"] | components["schemas"]["AnimaImageToLatentsInvocation"] | components["schemas"]["AnimaLatentsToImageInvocation"] | components["schemas"]["AnimaLoRACollectionLoader"] | components["schemas"]["AnimaLoRALoaderInvocation"] | components["schemas"]["AnimaModelLoaderInvocation"] | components["schemas"]["AnimaTextEncoderInvocation"] | components["schemas"]["ApplyMaskTensorToImageInvocation"] | components["schemas"]["ApplyMaskToImageInvocation"] | components["schemas"]["BlankImageInvocation"] | components["schemas"]["BlendLatentsInvocation"] | components["schemas"]["BooleanCollectionInvocation"] | components["schemas"]["BooleanInvocation"] | components["schemas"]["BoundingBoxInvocation"] | components["schemas"]["CLIPSkipInvocation"] | components["schemas"]["CV2InfillInvocation"] | components["schemas"]["CalculateImageTilesEvenSplitInvocation"] | components["schemas"]["CalculateImageTilesInvocation"] | components["schemas"]["CalculateImageTilesMinimumOverlapInvocation"] | components["schemas"]["CannyEdgeDetectionInvocation"] | components["schemas"]["CanvasOutputInvocation"] | components["schemas"]["CanvasPasteBackInvocation"] | components["schemas"]["CanvasV2MaskAndCropInvocation"] | components["schemas"]["CenterPadCropInvocation"] | components["schemas"]["CogView4DenoiseInvocation"] | components["schemas"]["CogView4ImageToLatentsInvocation"] | components["schemas"]["CogView4LatentsToImageInvocation"] | components["schemas"]["CogView4ModelLoaderInvocation"] | components["schemas"]["CogView4TextEncoderInvocation"] | components["schemas"]["CollectInvocation"] | components["schemas"]["ColorCorrectInvocation"] | components["schemas"]["ColorInvocation"] | components["schemas"]["ColorMapInvocation"] | components["schemas"]["CompelInvocation"] | components["schemas"]["ConditioningCollectionInvocation"] | components["schemas"]["ConditioningInvocation"] | components["schemas"]["ContentShuffleInvocation"] | components["schemas"]["ControlNetInvocation"] | components["schemas"]["CoreMetadataInvocation"] | components["schemas"]["CreateDenoiseMaskInvocation"] | components["schemas"]["CreateGradientMaskInvocation"] | components["schemas"]["CropImageToBoundingBoxInvocation"] | components["schemas"]["CropLatentsCoreInvocation"] | components["schemas"]["CvInpaintInvocation"] | components["schemas"]["DWOpenposeDetectionInvocation"] | components["schemas"]["DecodeInvisibleWatermarkInvocation"] | components["schemas"]["DenoiseLatentsInvocation"] | components["schemas"]["DenoiseLatentsMetaInvocation"] | components["schemas"]["DepthAnythingDepthEstimationInvocation"] | components["schemas"]["DivideInvocation"] | components["schemas"]["DynamicPromptInvocation"] | components["schemas"]["ESRGANInvocation"] | components["schemas"]["ExpandMaskWithFadeInvocation"] | components["schemas"]["FLUXLoRACollectionLoader"] | components["schemas"]["FaceIdentifierInvocation"] | components["schemas"]["FaceMaskInvocation"] | components["schemas"]["FaceOffInvocation"] | components["schemas"]["FloatBatchInvocation"] | components["schemas"]["FloatCollectionInvocation"] | components["schemas"]["FloatGenerator"] | components["schemas"]["FloatInvocation"] | components["schemas"]["FloatLinearRangeInvocation"] | components["schemas"]["FloatMathInvocation"] | components["schemas"]["FloatToIntegerInvocation"] | components["schemas"]["Flux2DenoiseInvocation"] | components["schemas"]["Flux2KleinLoRACollectionLoader"] | components["schemas"]["Flux2KleinLoRALoaderInvocation"] | components["schemas"]["Flux2KleinModelLoaderInvocation"] | components["schemas"]["Flux2KleinTextEncoderInvocation"] | components["schemas"]["Flux2VaeDecodeInvocation"] | components["schemas"]["Flux2VaeEncodeInvocation"] | components["schemas"]["FluxControlLoRALoaderInvocation"] | components["schemas"]["FluxControlNetInvocation"] | components["schemas"]["FluxDenoiseInvocation"] | components["schemas"]["FluxDenoiseLatentsMetaInvocation"] | components["schemas"]["FluxFillInvocation"] | components["schemas"]["FluxIPAdapterInvocation"] | components["schemas"]["FluxKontextConcatenateImagesInvocation"] | components["schemas"]["FluxKontextInvocation"] | components["schemas"]["FluxLoRALoaderInvocation"] | components["schemas"]["FluxModelLoaderInvocation"] | components["schemas"]["FluxReduxInvocation"] | components["schemas"]["FluxTextEncoderInvocation"] | components["schemas"]["FluxVaeDecodeInvocation"] | components["schemas"]["FluxVaeEncodeInvocation"] | components["schemas"]["FreeUInvocation"] | components["schemas"]["GeminiImageGenerationInvocation"] | components["schemas"]["GetMaskBoundingBoxInvocation"] | components["schemas"]["GroundingDinoInvocation"] | components["schemas"]["HEDEdgeDetectionInvocation"] | components["schemas"]["HeuristicResizeInvocation"] | components["schemas"]["IPAdapterInvocation"] | components["schemas"]["IdealSizeInvocation"] | components["schemas"]["IfInvocation"] | components["schemas"]["ImageBatchInvocation"] | components["schemas"]["ImageBlurInvocation"] | components["schemas"]["ImageChannelInvocation"] | components["schemas"]["ImageChannelMultiplyInvocation"] | components["schemas"]["ImageChannelOffsetInvocation"] | components["schemas"]["ImageCollectionInvocation"] | components["schemas"]["ImageConvertInvocation"] | components["schemas"]["ImageCropInvocation"] | components["schemas"]["ImageGenerator"] | components["schemas"]["ImageHueAdjustmentInvocation"] | components["schemas"]["ImageInverseLerpInvocation"] | components["schemas"]["ImageInvocation"] | components["schemas"]["ImageLerpInvocation"] | components["schemas"]["ImageMaskToTensorInvocation"] | components["schemas"]["ImageMultiplyInvocation"] | components["schemas"]["ImageNSFWBlurInvocation"] | components["schemas"]["ImageNoiseInvocation"] | components["schemas"]["ImagePanelLayoutInvocation"] | components["schemas"]["ImagePasteInvocation"] | components["schemas"]["ImageResizeInvocation"] | components["schemas"]["ImageScaleInvocation"] | components["schemas"]["ImageToLatentsInvocation"] | components["schemas"]["ImageWatermarkInvocation"] | components["schemas"]["InfillColorInvocation"] | components["schemas"]["InfillPatchMatchInvocation"] | components["schemas"]["InfillTileInvocation"] | components["schemas"]["IntegerBatchInvocation"] | components["schemas"]["IntegerCollectionInvocation"] | components["schemas"]["IntegerGenerator"] | components["schemas"]["IntegerInvocation"] | components["schemas"]["IntegerMathInvocation"] | components["schemas"]["InvertTensorMaskInvocation"] | components["schemas"]["InvokeAdjustImageHuePlusInvocation"] | components["schemas"]["InvokeEquivalentAchromaticLightnessInvocation"] | components["schemas"]["InvokeImageBlendInvocation"] | components["schemas"]["InvokeImageCompositorInvocation"] | components["schemas"]["InvokeImageDilateOrErodeInvocation"] | components["schemas"]["InvokeImageEnhanceInvocation"] | components["schemas"]["InvokeImageValueThresholdsInvocation"] | components["schemas"]["IterateInvocation"] | components["schemas"]["LaMaInfillInvocation"] | components["schemas"]["LatentsCollectionInvocation"] | components["schemas"]["LatentsInvocation"] | components["schemas"]["LatentsToImageInvocation"] | components["schemas"]["LineartAnimeEdgeDetectionInvocation"] | components["schemas"]["LineartEdgeDetectionInvocation"] | components["schemas"]["LlavaOnevisionVllmInvocation"] | components["schemas"]["LoRACollectionLoader"] | components["schemas"]["LoRALoaderInvocation"] | components["schemas"]["LoRASelectorInvocation"] | components["schemas"]["MLSDDetectionInvocation"] | components["schemas"]["MainModelLoaderInvocation"] | components["schemas"]["MaskCombineInvocation"] | components["schemas"]["MaskEdgeInvocation"] | components["schemas"]["MaskFromAlphaInvocation"] | components["schemas"]["MaskFromIDInvocation"] | components["schemas"]["MaskTensorToImageInvocation"] | components["schemas"]["MediaPipeFaceDetectionInvocation"] | components["schemas"]["MergeMetadataInvocation"] | components["schemas"]["MergeTilesToImageInvocation"] | components["schemas"]["MetadataFieldExtractorInvocation"] | components["schemas"]["MetadataFromImageInvocation"] | components["schemas"]["MetadataInvocation"] | components["schemas"]["MetadataItemInvocation"] | components["schemas"]["MetadataItemLinkedInvocation"] | components["schemas"]["MetadataToBoolCollectionInvocation"] | components["schemas"]["MetadataToBoolInvocation"] | components["schemas"]["MetadataToControlnetsInvocation"] | components["schemas"]["MetadataToFloatCollectionInvocation"] | components["schemas"]["MetadataToFloatInvocation"] | components["schemas"]["MetadataToIPAdaptersInvocation"] | components["schemas"]["MetadataToIntegerCollectionInvocation"] | components["schemas"]["MetadataToIntegerInvocation"] | components["schemas"]["MetadataToLorasCollectionInvocation"] | components["schemas"]["MetadataToLorasInvocation"] | components["schemas"]["MetadataToModelInvocation"] | components["schemas"]["MetadataToSDXLLorasInvocation"] | components["schemas"]["MetadataToSDXLModelInvocation"] | components["schemas"]["MetadataToSchedulerInvocation"] | components["schemas"]["MetadataToStringCollectionInvocation"] | components["schemas"]["MetadataToStringInvocation"] | components["schemas"]["MetadataToT2IAdaptersInvocation"] | components["schemas"]["MetadataToVAEInvocation"] | components["schemas"]["ModelIdentifierInvocation"] | components["schemas"]["MultiplyInvocation"] | components["schemas"]["NoiseInvocation"] | components["schemas"]["NormalMapInvocation"] | components["schemas"]["OpenAIImageGenerationInvocation"] | components["schemas"]["PBRMapsInvocation"] | components["schemas"]["PairTileImageInvocation"] | components["schemas"]["PasteImageIntoBoundingBoxInvocation"] | components["schemas"]["PiDiNetEdgeDetectionInvocation"] | components["schemas"]["PromptTemplateInvocation"] | components["schemas"]["PromptsFromFileInvocation"] | components["schemas"]["QwenImageDenoiseInvocation"] | components["schemas"]["QwenImageImageToLatentsInvocation"] | components["schemas"]["QwenImageLatentsToImageInvocation"] | components["schemas"]["QwenImageLoRACollectionLoader"] | components["schemas"]["QwenImageLoRALoaderInvocation"] | components["schemas"]["QwenImageModelLoaderInvocation"] | components["schemas"]["QwenImageTextEncoderInvocation"] | components["schemas"]["RandomFloatInvocation"] | components["schemas"]["RandomIntInvocation"] | components["schemas"]["RandomRangeInvocation"] | components["schemas"]["RangeInvocation"] | components["schemas"]["RangeOfSizeInvocation"] | components["schemas"]["RectangleMaskInvocation"] | components["schemas"]["ResizeLatentsInvocation"] | components["schemas"]["RoundInvocation"] | components["schemas"]["SD3DenoiseInvocation"] | components["schemas"]["SD3ImageToLatentsInvocation"] | components["schemas"]["SD3LatentsToImageInvocation"] | components["schemas"]["SDXLCompelPromptInvocation"] | components["schemas"]["SDXLLoRACollectionLoader"] | components["schemas"]["SDXLLoRALoaderInvocation"] | components["schemas"]["SDXLModelLoaderInvocation"] | components["schemas"]["SDXLRefinerCompelPromptInvocation"] | components["schemas"]["SDXLRefinerModelLoaderInvocation"] | components["schemas"]["SaveImageInvocation"] | components["schemas"]["ScaleLatentsInvocation"] | components["schemas"]["SchedulerInvocation"] | components["schemas"]["Sd3ModelLoaderInvocation"] | components["schemas"]["Sd3TextEncoderInvocation"] | components["schemas"]["SeamlessModeInvocation"] | components["schemas"]["SeedreamImageGenerationInvocation"] | components["schemas"]["SegmentAnythingInvocation"] | components["schemas"]["ShowImageInvocation"] | components["schemas"]["SpandrelImageToImageAutoscaleInvocation"] | components["schemas"]["SpandrelImageToImageInvocation"] | components["schemas"]["StringBatchInvocation"] | components["schemas"]["StringCollectionInvocation"] | components["schemas"]["StringGenerator"] | components["schemas"]["StringInvocation"] | components["schemas"]["StringJoinInvocation"] | components["schemas"]["StringJoinThreeInvocation"] | components["schemas"]["StringReplaceInvocation"] | components["schemas"]["StringSplitInvocation"] | components["schemas"]["StringSplitNegInvocation"] | components["schemas"]["SubtractInvocation"] | components["schemas"]["T2IAdapterInvocation"] | components["schemas"]["TextLLMInvocation"] | components["schemas"]["TileToPropertiesInvocation"] | components["schemas"]["TiledMultiDiffusionDenoiseLatents"] | components["schemas"]["UnsharpMaskInvocation"] | components["schemas"]["VAELoaderInvocation"] | components["schemas"]["ZImageControlInvocation"] | components["schemas"]["ZImageDenoiseInvocation"] | components["schemas"]["ZImageDenoiseMetaInvocation"] | components["schemas"]["ZImageImageToLatentsInvocation"] | components["schemas"]["ZImageLatentsToImageInvocation"] | components["schemas"]["ZImageLoRACollectionLoader"] | components["schemas"]["ZImageLoRALoaderInvocation"] | components["schemas"]["ZImageModelLoaderInvocation"] | components["schemas"]["ZImageSeedVarianceEnhancerInvocation"] | components["schemas"]["ZImageTextEncoderInvocation"];
+ invocation: components["schemas"]["AddInvocation"] | components["schemas"]["AlibabaCloudImageGenerationInvocation"] | components["schemas"]["AlphaMaskToTensorInvocation"] | components["schemas"]["AnimaDenoiseInvocation"] | components["schemas"]["AnimaImageToLatentsInvocation"] | components["schemas"]["AnimaLatentsToImageInvocation"] | components["schemas"]["AnimaLoRACollectionLoader"] | components["schemas"]["AnimaLoRALoaderInvocation"] | components["schemas"]["AnimaModelLoaderInvocation"] | components["schemas"]["AnimaTextEncoderInvocation"] | components["schemas"]["ApplyMaskTensorToImageInvocation"] | components["schemas"]["ApplyMaskToImageInvocation"] | components["schemas"]["BlankImageInvocation"] | components["schemas"]["BlendLatentsInvocation"] | components["schemas"]["BooleanCollectionInvocation"] | components["schemas"]["BooleanInvocation"] | components["schemas"]["BoundingBoxInvocation"] | components["schemas"]["CLIPSkipInvocation"] | components["schemas"]["CV2InfillInvocation"] | components["schemas"]["CalculateImageTilesEvenSplitInvocation"] | components["schemas"]["CalculateImageTilesInvocation"] | components["schemas"]["CalculateImageTilesMinimumOverlapInvocation"] | components["schemas"]["CannyEdgeDetectionInvocation"] | components["schemas"]["CanvasOutputInvocation"] | components["schemas"]["CanvasPasteBackInvocation"] | components["schemas"]["CanvasV2MaskAndCropInvocation"] | components["schemas"]["CenterPadCropInvocation"] | components["schemas"]["CogView4DenoiseInvocation"] | components["schemas"]["CogView4ImageToLatentsInvocation"] | components["schemas"]["CogView4LatentsToImageInvocation"] | components["schemas"]["CogView4ModelLoaderInvocation"] | components["schemas"]["CogView4TextEncoderInvocation"] | components["schemas"]["CollectInvocation"] | components["schemas"]["ColorCorrectInvocation"] | components["schemas"]["ColorInvocation"] | components["schemas"]["ColorMapInvocation"] | components["schemas"]["CompelInvocation"] | components["schemas"]["ConditioningCollectionInvocation"] | components["schemas"]["ConditioningInvocation"] | components["schemas"]["ContentShuffleInvocation"] | components["schemas"]["ControlNetInvocation"] | components["schemas"]["CoreMetadataInvocation"] | components["schemas"]["CreateDenoiseMaskInvocation"] | components["schemas"]["CreateGradientMaskInvocation"] | components["schemas"]["CropImageToBoundingBoxInvocation"] | components["schemas"]["CropLatentsCoreInvocation"] | components["schemas"]["CvInpaintInvocation"] | components["schemas"]["DWOpenposeDetectionInvocation"] | components["schemas"]["DecodeInvisibleWatermarkInvocation"] | components["schemas"]["DenoiseLatentsInvocation"] | components["schemas"]["DenoiseLatentsMetaInvocation"] | components["schemas"]["DepthAnythingDepthEstimationInvocation"] | components["schemas"]["DivideInvocation"] | components["schemas"]["DynamicPromptInvocation"] | components["schemas"]["ESRGANInvocation"] | components["schemas"]["ExpandMaskWithFadeInvocation"] | components["schemas"]["FLUXLoRACollectionLoader"] | components["schemas"]["FaceIdentifierInvocation"] | components["schemas"]["FaceMaskInvocation"] | components["schemas"]["FaceOffInvocation"] | components["schemas"]["FloatBatchInvocation"] | components["schemas"]["FloatCollectionInvocation"] | components["schemas"]["FloatGenerator"] | components["schemas"]["FloatInvocation"] | components["schemas"]["FloatLinearRangeInvocation"] | components["schemas"]["FloatMathInvocation"] | components["schemas"]["FloatToIntegerInvocation"] | components["schemas"]["Flux2DenoiseInvocation"] | components["schemas"]["Flux2KleinLoRACollectionLoader"] | components["schemas"]["Flux2KleinLoRALoaderInvocation"] | components["schemas"]["Flux2KleinModelLoaderInvocation"] | components["schemas"]["Flux2KleinTextEncoderInvocation"] | components["schemas"]["Flux2VaeDecodeInvocation"] | components["schemas"]["Flux2VaeEncodeInvocation"] | components["schemas"]["FluxControlLoRALoaderInvocation"] | components["schemas"]["FluxControlNetInvocation"] | components["schemas"]["FluxDenoiseInvocation"] | components["schemas"]["FluxDenoiseLatentsMetaInvocation"] | components["schemas"]["FluxFillInvocation"] | components["schemas"]["FluxIPAdapterInvocation"] | components["schemas"]["FluxKontextConcatenateImagesInvocation"] | components["schemas"]["FluxKontextInvocation"] | components["schemas"]["FluxLoRALoaderInvocation"] | components["schemas"]["FluxModelLoaderInvocation"] | components["schemas"]["FluxReduxInvocation"] | components["schemas"]["FluxTextEncoderInvocation"] | components["schemas"]["FluxVaeDecodeInvocation"] | components["schemas"]["FluxVaeEncodeInvocation"] | components["schemas"]["FreeUInvocation"] | components["schemas"]["GeminiImageGenerationInvocation"] | components["schemas"]["GetMaskBoundingBoxInvocation"] | components["schemas"]["GroundingDinoInvocation"] | components["schemas"]["HEDEdgeDetectionInvocation"] | components["schemas"]["HeuristicResizeInvocation"] | components["schemas"]["IPAdapterInvocation"] | components["schemas"]["IdealSizeInvocation"] | components["schemas"]["IfInvocation"] | components["schemas"]["ImageBatchInvocation"] | components["schemas"]["ImageBlurInvocation"] | components["schemas"]["ImageChannelInvocation"] | components["schemas"]["ImageChannelMultiplyInvocation"] | components["schemas"]["ImageChannelOffsetInvocation"] | components["schemas"]["ImageCollectionInvocation"] | components["schemas"]["ImageConvertInvocation"] | components["schemas"]["ImageCropInvocation"] | components["schemas"]["ImageGenerator"] | components["schemas"]["ImageHueAdjustmentInvocation"] | components["schemas"]["ImageInverseLerpInvocation"] | components["schemas"]["ImageInvocation"] | components["schemas"]["ImageLerpInvocation"] | components["schemas"]["ImageMaskToTensorInvocation"] | components["schemas"]["ImageMultiplyInvocation"] | components["schemas"]["ImageNSFWBlurInvocation"] | components["schemas"]["ImageNoiseInvocation"] | components["schemas"]["ImagePanelLayoutInvocation"] | components["schemas"]["ImagePasteInvocation"] | components["schemas"]["ImageResizeInvocation"] | components["schemas"]["ImageScaleInvocation"] | components["schemas"]["ImageToLatentsInvocation"] | components["schemas"]["ImageWatermarkInvocation"] | components["schemas"]["InfillColorInvocation"] | components["schemas"]["InfillPatchMatchInvocation"] | components["schemas"]["InfillTileInvocation"] | components["schemas"]["IntegerBatchInvocation"] | components["schemas"]["IntegerCollectionInvocation"] | components["schemas"]["IntegerGenerator"] | components["schemas"]["IntegerInvocation"] | components["schemas"]["IntegerMathInvocation"] | components["schemas"]["InvertTensorMaskInvocation"] | components["schemas"]["InvokeAdjustImageHuePlusInvocation"] | components["schemas"]["InvokeEquivalentAchromaticLightnessInvocation"] | components["schemas"]["InvokeImageBlendInvocation"] | components["schemas"]["InvokeImageCompositorInvocation"] | components["schemas"]["InvokeImageDilateOrErodeInvocation"] | components["schemas"]["InvokeImageEnhanceInvocation"] | components["schemas"]["InvokeImageValueThresholdsInvocation"] | components["schemas"]["IterateInvocation"] | components["schemas"]["LaMaInfillInvocation"] | components["schemas"]["LatentsCollectionInvocation"] | components["schemas"]["LatentsInvocation"] | components["schemas"]["LatentsToImageInvocation"] | components["schemas"]["LineartAnimeEdgeDetectionInvocation"] | components["schemas"]["LineartEdgeDetectionInvocation"] | components["schemas"]["LlavaOnevisionVllmInvocation"] | components["schemas"]["LoRACollectionLoader"] | components["schemas"]["LoRALoaderInvocation"] | components["schemas"]["LoRASelectorInvocation"] | components["schemas"]["MLSDDetectionInvocation"] | components["schemas"]["MainModelLoaderInvocation"] | components["schemas"]["MaskCombineInvocation"] | components["schemas"]["MaskEdgeInvocation"] | components["schemas"]["MaskFromAlphaInvocation"] | components["schemas"]["MaskFromIDInvocation"] | components["schemas"]["MaskTensorToImageInvocation"] | components["schemas"]["MediaPipeFaceDetectionInvocation"] | components["schemas"]["MergeMetadataInvocation"] | components["schemas"]["MergeTilesToImageInvocation"] | components["schemas"]["MetadataFieldExtractorInvocation"] | components["schemas"]["MetadataFromImageInvocation"] | components["schemas"]["MetadataInvocation"] | components["schemas"]["MetadataItemInvocation"] | components["schemas"]["MetadataItemLinkedInvocation"] | components["schemas"]["MetadataToBoolCollectionInvocation"] | components["schemas"]["MetadataToBoolInvocation"] | components["schemas"]["MetadataToControlnetsInvocation"] | components["schemas"]["MetadataToFloatCollectionInvocation"] | components["schemas"]["MetadataToFloatInvocation"] | components["schemas"]["MetadataToIPAdaptersInvocation"] | components["schemas"]["MetadataToIntegerCollectionInvocation"] | components["schemas"]["MetadataToIntegerInvocation"] | components["schemas"]["MetadataToLorasCollectionInvocation"] | components["schemas"]["MetadataToLorasInvocation"] | components["schemas"]["MetadataToModelInvocation"] | components["schemas"]["MetadataToSDXLLorasInvocation"] | components["schemas"]["MetadataToSDXLModelInvocation"] | components["schemas"]["MetadataToSchedulerInvocation"] | components["schemas"]["MetadataToStringCollectionInvocation"] | components["schemas"]["MetadataToStringInvocation"] | components["schemas"]["MetadataToT2IAdaptersInvocation"] | components["schemas"]["MetadataToVAEInvocation"] | components["schemas"]["ModelIdentifierInvocation"] | components["schemas"]["MultiplyInvocation"] | components["schemas"]["NoiseInvocation"] | components["schemas"]["NormalMapInvocation"] | components["schemas"]["OklabUnsharpMaskInvocation"] | components["schemas"]["OklchImageHueAdjustmentInvocation"] | components["schemas"]["OpenAIImageGenerationInvocation"] | components["schemas"]["PBRMapsInvocation"] | components["schemas"]["PairTileImageInvocation"] | components["schemas"]["PasteImageIntoBoundingBoxInvocation"] | components["schemas"]["PiDiNetEdgeDetectionInvocation"] | components["schemas"]["PromptTemplateInvocation"] | components["schemas"]["PromptsFromFileInvocation"] | components["schemas"]["QwenImageDenoiseInvocation"] | components["schemas"]["QwenImageImageToLatentsInvocation"] | components["schemas"]["QwenImageLatentsToImageInvocation"] | components["schemas"]["QwenImageLoRACollectionLoader"] | components["schemas"]["QwenImageLoRALoaderInvocation"] | components["schemas"]["QwenImageModelLoaderInvocation"] | components["schemas"]["QwenImageTextEncoderInvocation"] | components["schemas"]["RandomFloatInvocation"] | components["schemas"]["RandomIntInvocation"] | components["schemas"]["RandomRangeInvocation"] | components["schemas"]["RangeInvocation"] | components["schemas"]["RangeOfSizeInvocation"] | components["schemas"]["RectangleMaskInvocation"] | components["schemas"]["ResizeLatentsInvocation"] | components["schemas"]["RoundInvocation"] | components["schemas"]["SD3DenoiseInvocation"] | components["schemas"]["SD3ImageToLatentsInvocation"] | components["schemas"]["SD3LatentsToImageInvocation"] | components["schemas"]["SDXLCompelPromptInvocation"] | components["schemas"]["SDXLLoRACollectionLoader"] | components["schemas"]["SDXLLoRALoaderInvocation"] | components["schemas"]["SDXLModelLoaderInvocation"] | components["schemas"]["SDXLRefinerCompelPromptInvocation"] | components["schemas"]["SDXLRefinerModelLoaderInvocation"] | components["schemas"]["SaveImageInvocation"] | components["schemas"]["ScaleLatentsInvocation"] | components["schemas"]["SchedulerInvocation"] | components["schemas"]["Sd3ModelLoaderInvocation"] | components["schemas"]["Sd3TextEncoderInvocation"] | components["schemas"]["SeamlessModeInvocation"] | components["schemas"]["SeedreamImageGenerationInvocation"] | components["schemas"]["SegmentAnythingInvocation"] | components["schemas"]["ShowImageInvocation"] | components["schemas"]["SpandrelImageToImageAutoscaleInvocation"] | components["schemas"]["SpandrelImageToImageInvocation"] | components["schemas"]["StringBatchInvocation"] | components["schemas"]["StringCollectionInvocation"] | components["schemas"]["StringGenerator"] | components["schemas"]["StringInvocation"] | components["schemas"]["StringJoinInvocation"] | components["schemas"]["StringJoinThreeInvocation"] | components["schemas"]["StringReplaceInvocation"] | components["schemas"]["StringSplitInvocation"] | components["schemas"]["StringSplitNegInvocation"] | components["schemas"]["SubtractInvocation"] | components["schemas"]["T2IAdapterInvocation"] | components["schemas"]["TextLLMInvocation"] | components["schemas"]["TileToPropertiesInvocation"] | components["schemas"]["TiledMultiDiffusionDenoiseLatents"] | components["schemas"]["UnsharpMaskInvocation"] | components["schemas"]["VAELoaderInvocation"] | components["schemas"]["ZImageControlInvocation"] | components["schemas"]["ZImageDenoiseInvocation"] | components["schemas"]["ZImageDenoiseMetaInvocation"] | components["schemas"]["ZImageImageToLatentsInvocation"] | components["schemas"]["ZImageLatentsToImageInvocation"] | components["schemas"]["ZImageLoRACollectionLoader"] | components["schemas"]["ZImageLoRALoaderInvocation"] | components["schemas"]["ZImageModelLoaderInvocation"] | components["schemas"]["ZImageSeedVarianceEnhancerInvocation"] | components["schemas"]["ZImageTextEncoderInvocation"];
/**
* Invocation Source Id
* @description The ID of the prepared invocation's source node
@@ -16113,7 +16115,7 @@ export type components = {
* Invocation
* @description The ID of the invocation
*/
- invocation: components["schemas"]["AddInvocation"] | components["schemas"]["AlibabaCloudImageGenerationInvocation"] | components["schemas"]["AlphaMaskToTensorInvocation"] | components["schemas"]["AnimaDenoiseInvocation"] | components["schemas"]["AnimaImageToLatentsInvocation"] | components["schemas"]["AnimaLatentsToImageInvocation"] | components["schemas"]["AnimaLoRACollectionLoader"] | components["schemas"]["AnimaLoRALoaderInvocation"] | components["schemas"]["AnimaModelLoaderInvocation"] | components["schemas"]["AnimaTextEncoderInvocation"] | components["schemas"]["ApplyMaskTensorToImageInvocation"] | components["schemas"]["ApplyMaskToImageInvocation"] | components["schemas"]["BlankImageInvocation"] | components["schemas"]["BlendLatentsInvocation"] | components["schemas"]["BooleanCollectionInvocation"] | components["schemas"]["BooleanInvocation"] | components["schemas"]["BoundingBoxInvocation"] | components["schemas"]["CLIPSkipInvocation"] | components["schemas"]["CV2InfillInvocation"] | components["schemas"]["CalculateImageTilesEvenSplitInvocation"] | components["schemas"]["CalculateImageTilesInvocation"] | components["schemas"]["CalculateImageTilesMinimumOverlapInvocation"] | components["schemas"]["CannyEdgeDetectionInvocation"] | components["schemas"]["CanvasOutputInvocation"] | components["schemas"]["CanvasPasteBackInvocation"] | components["schemas"]["CanvasV2MaskAndCropInvocation"] | components["schemas"]["CenterPadCropInvocation"] | components["schemas"]["CogView4DenoiseInvocation"] | components["schemas"]["CogView4ImageToLatentsInvocation"] | components["schemas"]["CogView4LatentsToImageInvocation"] | components["schemas"]["CogView4ModelLoaderInvocation"] | components["schemas"]["CogView4TextEncoderInvocation"] | components["schemas"]["CollectInvocation"] | components["schemas"]["ColorCorrectInvocation"] | components["schemas"]["ColorInvocation"] | components["schemas"]["ColorMapInvocation"] | components["schemas"]["CompelInvocation"] | components["schemas"]["ConditioningCollectionInvocation"] | components["schemas"]["ConditioningInvocation"] | components["schemas"]["ContentShuffleInvocation"] | components["schemas"]["ControlNetInvocation"] | components["schemas"]["CoreMetadataInvocation"] | components["schemas"]["CreateDenoiseMaskInvocation"] | components["schemas"]["CreateGradientMaskInvocation"] | components["schemas"]["CropImageToBoundingBoxInvocation"] | components["schemas"]["CropLatentsCoreInvocation"] | components["schemas"]["CvInpaintInvocation"] | components["schemas"]["DWOpenposeDetectionInvocation"] | components["schemas"]["DecodeInvisibleWatermarkInvocation"] | components["schemas"]["DenoiseLatentsInvocation"] | components["schemas"]["DenoiseLatentsMetaInvocation"] | components["schemas"]["DepthAnythingDepthEstimationInvocation"] | components["schemas"]["DivideInvocation"] | components["schemas"]["DynamicPromptInvocation"] | components["schemas"]["ESRGANInvocation"] | components["schemas"]["ExpandMaskWithFadeInvocation"] | components["schemas"]["FLUXLoRACollectionLoader"] | components["schemas"]["FaceIdentifierInvocation"] | components["schemas"]["FaceMaskInvocation"] | components["schemas"]["FaceOffInvocation"] | components["schemas"]["FloatBatchInvocation"] | components["schemas"]["FloatCollectionInvocation"] | components["schemas"]["FloatGenerator"] | components["schemas"]["FloatInvocation"] | components["schemas"]["FloatLinearRangeInvocation"] | components["schemas"]["FloatMathInvocation"] | components["schemas"]["FloatToIntegerInvocation"] | components["schemas"]["Flux2DenoiseInvocation"] | components["schemas"]["Flux2KleinLoRACollectionLoader"] | components["schemas"]["Flux2KleinLoRALoaderInvocation"] | components["schemas"]["Flux2KleinModelLoaderInvocation"] | components["schemas"]["Flux2KleinTextEncoderInvocation"] | components["schemas"]["Flux2VaeDecodeInvocation"] | components["schemas"]["Flux2VaeEncodeInvocation"] | components["schemas"]["FluxControlLoRALoaderInvocation"] | components["schemas"]["FluxControlNetInvocation"] | components["schemas"]["FluxDenoiseInvocation"] | components["schemas"]["FluxDenoiseLatentsMetaInvocation"] | components["schemas"]["FluxFillInvocation"] | components["schemas"]["FluxIPAdapterInvocation"] | components["schemas"]["FluxKontextConcatenateImagesInvocation"] | components["schemas"]["FluxKontextInvocation"] | components["schemas"]["FluxLoRALoaderInvocation"] | components["schemas"]["FluxModelLoaderInvocation"] | components["schemas"]["FluxReduxInvocation"] | components["schemas"]["FluxTextEncoderInvocation"] | components["schemas"]["FluxVaeDecodeInvocation"] | components["schemas"]["FluxVaeEncodeInvocation"] | components["schemas"]["FreeUInvocation"] | components["schemas"]["GeminiImageGenerationInvocation"] | components["schemas"]["GetMaskBoundingBoxInvocation"] | components["schemas"]["GroundingDinoInvocation"] | components["schemas"]["HEDEdgeDetectionInvocation"] | components["schemas"]["HeuristicResizeInvocation"] | components["schemas"]["IPAdapterInvocation"] | components["schemas"]["IdealSizeInvocation"] | components["schemas"]["IfInvocation"] | components["schemas"]["ImageBatchInvocation"] | components["schemas"]["ImageBlurInvocation"] | components["schemas"]["ImageChannelInvocation"] | components["schemas"]["ImageChannelMultiplyInvocation"] | components["schemas"]["ImageChannelOffsetInvocation"] | components["schemas"]["ImageCollectionInvocation"] | components["schemas"]["ImageConvertInvocation"] | components["schemas"]["ImageCropInvocation"] | components["schemas"]["ImageGenerator"] | components["schemas"]["ImageHueAdjustmentInvocation"] | components["schemas"]["ImageInverseLerpInvocation"] | components["schemas"]["ImageInvocation"] | components["schemas"]["ImageLerpInvocation"] | components["schemas"]["ImageMaskToTensorInvocation"] | components["schemas"]["ImageMultiplyInvocation"] | components["schemas"]["ImageNSFWBlurInvocation"] | components["schemas"]["ImageNoiseInvocation"] | components["schemas"]["ImagePanelLayoutInvocation"] | components["schemas"]["ImagePasteInvocation"] | components["schemas"]["ImageResizeInvocation"] | components["schemas"]["ImageScaleInvocation"] | components["schemas"]["ImageToLatentsInvocation"] | components["schemas"]["ImageWatermarkInvocation"] | components["schemas"]["InfillColorInvocation"] | components["schemas"]["InfillPatchMatchInvocation"] | components["schemas"]["InfillTileInvocation"] | components["schemas"]["IntegerBatchInvocation"] | components["schemas"]["IntegerCollectionInvocation"] | components["schemas"]["IntegerGenerator"] | components["schemas"]["IntegerInvocation"] | components["schemas"]["IntegerMathInvocation"] | components["schemas"]["InvertTensorMaskInvocation"] | components["schemas"]["InvokeAdjustImageHuePlusInvocation"] | components["schemas"]["InvokeEquivalentAchromaticLightnessInvocation"] | components["schemas"]["InvokeImageBlendInvocation"] | components["schemas"]["InvokeImageCompositorInvocation"] | components["schemas"]["InvokeImageDilateOrErodeInvocation"] | components["schemas"]["InvokeImageEnhanceInvocation"] | components["schemas"]["InvokeImageValueThresholdsInvocation"] | components["schemas"]["IterateInvocation"] | components["schemas"]["LaMaInfillInvocation"] | components["schemas"]["LatentsCollectionInvocation"] | components["schemas"]["LatentsInvocation"] | components["schemas"]["LatentsToImageInvocation"] | components["schemas"]["LineartAnimeEdgeDetectionInvocation"] | components["schemas"]["LineartEdgeDetectionInvocation"] | components["schemas"]["LlavaOnevisionVllmInvocation"] | components["schemas"]["LoRACollectionLoader"] | components["schemas"]["LoRALoaderInvocation"] | components["schemas"]["LoRASelectorInvocation"] | components["schemas"]["MLSDDetectionInvocation"] | components["schemas"]["MainModelLoaderInvocation"] | components["schemas"]["MaskCombineInvocation"] | components["schemas"]["MaskEdgeInvocation"] | components["schemas"]["MaskFromAlphaInvocation"] | components["schemas"]["MaskFromIDInvocation"] | components["schemas"]["MaskTensorToImageInvocation"] | components["schemas"]["MediaPipeFaceDetectionInvocation"] | components["schemas"]["MergeMetadataInvocation"] | components["schemas"]["MergeTilesToImageInvocation"] | components["schemas"]["MetadataFieldExtractorInvocation"] | components["schemas"]["MetadataFromImageInvocation"] | components["schemas"]["MetadataInvocation"] | components["schemas"]["MetadataItemInvocation"] | components["schemas"]["MetadataItemLinkedInvocation"] | components["schemas"]["MetadataToBoolCollectionInvocation"] | components["schemas"]["MetadataToBoolInvocation"] | components["schemas"]["MetadataToControlnetsInvocation"] | components["schemas"]["MetadataToFloatCollectionInvocation"] | components["schemas"]["MetadataToFloatInvocation"] | components["schemas"]["MetadataToIPAdaptersInvocation"] | components["schemas"]["MetadataToIntegerCollectionInvocation"] | components["schemas"]["MetadataToIntegerInvocation"] | components["schemas"]["MetadataToLorasCollectionInvocation"] | components["schemas"]["MetadataToLorasInvocation"] | components["schemas"]["MetadataToModelInvocation"] | components["schemas"]["MetadataToSDXLLorasInvocation"] | components["schemas"]["MetadataToSDXLModelInvocation"] | components["schemas"]["MetadataToSchedulerInvocation"] | components["schemas"]["MetadataToStringCollectionInvocation"] | components["schemas"]["MetadataToStringInvocation"] | components["schemas"]["MetadataToT2IAdaptersInvocation"] | components["schemas"]["MetadataToVAEInvocation"] | components["schemas"]["ModelIdentifierInvocation"] | components["schemas"]["MultiplyInvocation"] | components["schemas"]["NoiseInvocation"] | components["schemas"]["NormalMapInvocation"] | components["schemas"]["OpenAIImageGenerationInvocation"] | components["schemas"]["PBRMapsInvocation"] | components["schemas"]["PairTileImageInvocation"] | components["schemas"]["PasteImageIntoBoundingBoxInvocation"] | components["schemas"]["PiDiNetEdgeDetectionInvocation"] | components["schemas"]["PromptTemplateInvocation"] | components["schemas"]["PromptsFromFileInvocation"] | components["schemas"]["QwenImageDenoiseInvocation"] | components["schemas"]["QwenImageImageToLatentsInvocation"] | components["schemas"]["QwenImageLatentsToImageInvocation"] | components["schemas"]["QwenImageLoRACollectionLoader"] | components["schemas"]["QwenImageLoRALoaderInvocation"] | components["schemas"]["QwenImageModelLoaderInvocation"] | components["schemas"]["QwenImageTextEncoderInvocation"] | components["schemas"]["RandomFloatInvocation"] | components["schemas"]["RandomIntInvocation"] | components["schemas"]["RandomRangeInvocation"] | components["schemas"]["RangeInvocation"] | components["schemas"]["RangeOfSizeInvocation"] | components["schemas"]["RectangleMaskInvocation"] | components["schemas"]["ResizeLatentsInvocation"] | components["schemas"]["RoundInvocation"] | components["schemas"]["SD3DenoiseInvocation"] | components["schemas"]["SD3ImageToLatentsInvocation"] | components["schemas"]["SD3LatentsToImageInvocation"] | components["schemas"]["SDXLCompelPromptInvocation"] | components["schemas"]["SDXLLoRACollectionLoader"] | components["schemas"]["SDXLLoRALoaderInvocation"] | components["schemas"]["SDXLModelLoaderInvocation"] | components["schemas"]["SDXLRefinerCompelPromptInvocation"] | components["schemas"]["SDXLRefinerModelLoaderInvocation"] | components["schemas"]["SaveImageInvocation"] | components["schemas"]["ScaleLatentsInvocation"] | components["schemas"]["SchedulerInvocation"] | components["schemas"]["Sd3ModelLoaderInvocation"] | components["schemas"]["Sd3TextEncoderInvocation"] | components["schemas"]["SeamlessModeInvocation"] | components["schemas"]["SeedreamImageGenerationInvocation"] | components["schemas"]["SegmentAnythingInvocation"] | components["schemas"]["ShowImageInvocation"] | components["schemas"]["SpandrelImageToImageAutoscaleInvocation"] | components["schemas"]["SpandrelImageToImageInvocation"] | components["schemas"]["StringBatchInvocation"] | components["schemas"]["StringCollectionInvocation"] | components["schemas"]["StringGenerator"] | components["schemas"]["StringInvocation"] | components["schemas"]["StringJoinInvocation"] | components["schemas"]["StringJoinThreeInvocation"] | components["schemas"]["StringReplaceInvocation"] | components["schemas"]["StringSplitInvocation"] | components["schemas"]["StringSplitNegInvocation"] | components["schemas"]["SubtractInvocation"] | components["schemas"]["T2IAdapterInvocation"] | components["schemas"]["TextLLMInvocation"] | components["schemas"]["TileToPropertiesInvocation"] | components["schemas"]["TiledMultiDiffusionDenoiseLatents"] | components["schemas"]["UnsharpMaskInvocation"] | components["schemas"]["VAELoaderInvocation"] | components["schemas"]["ZImageControlInvocation"] | components["schemas"]["ZImageDenoiseInvocation"] | components["schemas"]["ZImageDenoiseMetaInvocation"] | components["schemas"]["ZImageImageToLatentsInvocation"] | components["schemas"]["ZImageLatentsToImageInvocation"] | components["schemas"]["ZImageLoRACollectionLoader"] | components["schemas"]["ZImageLoRALoaderInvocation"] | components["schemas"]["ZImageModelLoaderInvocation"] | components["schemas"]["ZImageSeedVarianceEnhancerInvocation"] | components["schemas"]["ZImageTextEncoderInvocation"];
+ invocation: components["schemas"]["AddInvocation"] | components["schemas"]["AlibabaCloudImageGenerationInvocation"] | components["schemas"]["AlphaMaskToTensorInvocation"] | components["schemas"]["AnimaDenoiseInvocation"] | components["schemas"]["AnimaImageToLatentsInvocation"] | components["schemas"]["AnimaLatentsToImageInvocation"] | components["schemas"]["AnimaLoRACollectionLoader"] | components["schemas"]["AnimaLoRALoaderInvocation"] | components["schemas"]["AnimaModelLoaderInvocation"] | components["schemas"]["AnimaTextEncoderInvocation"] | components["schemas"]["ApplyMaskTensorToImageInvocation"] | components["schemas"]["ApplyMaskToImageInvocation"] | components["schemas"]["BlankImageInvocation"] | components["schemas"]["BlendLatentsInvocation"] | components["schemas"]["BooleanCollectionInvocation"] | components["schemas"]["BooleanInvocation"] | components["schemas"]["BoundingBoxInvocation"] | components["schemas"]["CLIPSkipInvocation"] | components["schemas"]["CV2InfillInvocation"] | components["schemas"]["CalculateImageTilesEvenSplitInvocation"] | components["schemas"]["CalculateImageTilesInvocation"] | components["schemas"]["CalculateImageTilesMinimumOverlapInvocation"] | components["schemas"]["CannyEdgeDetectionInvocation"] | components["schemas"]["CanvasOutputInvocation"] | components["schemas"]["CanvasPasteBackInvocation"] | components["schemas"]["CanvasV2MaskAndCropInvocation"] | components["schemas"]["CenterPadCropInvocation"] | components["schemas"]["CogView4DenoiseInvocation"] | components["schemas"]["CogView4ImageToLatentsInvocation"] | components["schemas"]["CogView4LatentsToImageInvocation"] | components["schemas"]["CogView4ModelLoaderInvocation"] | components["schemas"]["CogView4TextEncoderInvocation"] | components["schemas"]["CollectInvocation"] | components["schemas"]["ColorCorrectInvocation"] | components["schemas"]["ColorInvocation"] | components["schemas"]["ColorMapInvocation"] | components["schemas"]["CompelInvocation"] | components["schemas"]["ConditioningCollectionInvocation"] | components["schemas"]["ConditioningInvocation"] | components["schemas"]["ContentShuffleInvocation"] | components["schemas"]["ControlNetInvocation"] | components["schemas"]["CoreMetadataInvocation"] | components["schemas"]["CreateDenoiseMaskInvocation"] | components["schemas"]["CreateGradientMaskInvocation"] | components["schemas"]["CropImageToBoundingBoxInvocation"] | components["schemas"]["CropLatentsCoreInvocation"] | components["schemas"]["CvInpaintInvocation"] | components["schemas"]["DWOpenposeDetectionInvocation"] | components["schemas"]["DecodeInvisibleWatermarkInvocation"] | components["schemas"]["DenoiseLatentsInvocation"] | components["schemas"]["DenoiseLatentsMetaInvocation"] | components["schemas"]["DepthAnythingDepthEstimationInvocation"] | components["schemas"]["DivideInvocation"] | components["schemas"]["DynamicPromptInvocation"] | components["schemas"]["ESRGANInvocation"] | components["schemas"]["ExpandMaskWithFadeInvocation"] | components["schemas"]["FLUXLoRACollectionLoader"] | components["schemas"]["FaceIdentifierInvocation"] | components["schemas"]["FaceMaskInvocation"] | components["schemas"]["FaceOffInvocation"] | components["schemas"]["FloatBatchInvocation"] | components["schemas"]["FloatCollectionInvocation"] | components["schemas"]["FloatGenerator"] | components["schemas"]["FloatInvocation"] | components["schemas"]["FloatLinearRangeInvocation"] | components["schemas"]["FloatMathInvocation"] | components["schemas"]["FloatToIntegerInvocation"] | components["schemas"]["Flux2DenoiseInvocation"] | components["schemas"]["Flux2KleinLoRACollectionLoader"] | components["schemas"]["Flux2KleinLoRALoaderInvocation"] | components["schemas"]["Flux2KleinModelLoaderInvocation"] | components["schemas"]["Flux2KleinTextEncoderInvocation"] | components["schemas"]["Flux2VaeDecodeInvocation"] | components["schemas"]["Flux2VaeEncodeInvocation"] | components["schemas"]["FluxControlLoRALoaderInvocation"] | components["schemas"]["FluxControlNetInvocation"] | components["schemas"]["FluxDenoiseInvocation"] | components["schemas"]["FluxDenoiseLatentsMetaInvocation"] | components["schemas"]["FluxFillInvocation"] | components["schemas"]["FluxIPAdapterInvocation"] | components["schemas"]["FluxKontextConcatenateImagesInvocation"] | components["schemas"]["FluxKontextInvocation"] | components["schemas"]["FluxLoRALoaderInvocation"] | components["schemas"]["FluxModelLoaderInvocation"] | components["schemas"]["FluxReduxInvocation"] | components["schemas"]["FluxTextEncoderInvocation"] | components["schemas"]["FluxVaeDecodeInvocation"] | components["schemas"]["FluxVaeEncodeInvocation"] | components["schemas"]["FreeUInvocation"] | components["schemas"]["GeminiImageGenerationInvocation"] | components["schemas"]["GetMaskBoundingBoxInvocation"] | components["schemas"]["GroundingDinoInvocation"] | components["schemas"]["HEDEdgeDetectionInvocation"] | components["schemas"]["HeuristicResizeInvocation"] | components["schemas"]["IPAdapterInvocation"] | components["schemas"]["IdealSizeInvocation"] | components["schemas"]["IfInvocation"] | components["schemas"]["ImageBatchInvocation"] | components["schemas"]["ImageBlurInvocation"] | components["schemas"]["ImageChannelInvocation"] | components["schemas"]["ImageChannelMultiplyInvocation"] | components["schemas"]["ImageChannelOffsetInvocation"] | components["schemas"]["ImageCollectionInvocation"] | components["schemas"]["ImageConvertInvocation"] | components["schemas"]["ImageCropInvocation"] | components["schemas"]["ImageGenerator"] | components["schemas"]["ImageHueAdjustmentInvocation"] | components["schemas"]["ImageInverseLerpInvocation"] | components["schemas"]["ImageInvocation"] | components["schemas"]["ImageLerpInvocation"] | components["schemas"]["ImageMaskToTensorInvocation"] | components["schemas"]["ImageMultiplyInvocation"] | components["schemas"]["ImageNSFWBlurInvocation"] | components["schemas"]["ImageNoiseInvocation"] | components["schemas"]["ImagePanelLayoutInvocation"] | components["schemas"]["ImagePasteInvocation"] | components["schemas"]["ImageResizeInvocation"] | components["schemas"]["ImageScaleInvocation"] | components["schemas"]["ImageToLatentsInvocation"] | components["schemas"]["ImageWatermarkInvocation"] | components["schemas"]["InfillColorInvocation"] | components["schemas"]["InfillPatchMatchInvocation"] | components["schemas"]["InfillTileInvocation"] | components["schemas"]["IntegerBatchInvocation"] | components["schemas"]["IntegerCollectionInvocation"] | components["schemas"]["IntegerGenerator"] | components["schemas"]["IntegerInvocation"] | components["schemas"]["IntegerMathInvocation"] | components["schemas"]["InvertTensorMaskInvocation"] | components["schemas"]["InvokeAdjustImageHuePlusInvocation"] | components["schemas"]["InvokeEquivalentAchromaticLightnessInvocation"] | components["schemas"]["InvokeImageBlendInvocation"] | components["schemas"]["InvokeImageCompositorInvocation"] | components["schemas"]["InvokeImageDilateOrErodeInvocation"] | components["schemas"]["InvokeImageEnhanceInvocation"] | components["schemas"]["InvokeImageValueThresholdsInvocation"] | components["schemas"]["IterateInvocation"] | components["schemas"]["LaMaInfillInvocation"] | components["schemas"]["LatentsCollectionInvocation"] | components["schemas"]["LatentsInvocation"] | components["schemas"]["LatentsToImageInvocation"] | components["schemas"]["LineartAnimeEdgeDetectionInvocation"] | components["schemas"]["LineartEdgeDetectionInvocation"] | components["schemas"]["LlavaOnevisionVllmInvocation"] | components["schemas"]["LoRACollectionLoader"] | components["schemas"]["LoRALoaderInvocation"] | components["schemas"]["LoRASelectorInvocation"] | components["schemas"]["MLSDDetectionInvocation"] | components["schemas"]["MainModelLoaderInvocation"] | components["schemas"]["MaskCombineInvocation"] | components["schemas"]["MaskEdgeInvocation"] | components["schemas"]["MaskFromAlphaInvocation"] | components["schemas"]["MaskFromIDInvocation"] | components["schemas"]["MaskTensorToImageInvocation"] | components["schemas"]["MediaPipeFaceDetectionInvocation"] | components["schemas"]["MergeMetadataInvocation"] | components["schemas"]["MergeTilesToImageInvocation"] | components["schemas"]["MetadataFieldExtractorInvocation"] | components["schemas"]["MetadataFromImageInvocation"] | components["schemas"]["MetadataInvocation"] | components["schemas"]["MetadataItemInvocation"] | components["schemas"]["MetadataItemLinkedInvocation"] | components["schemas"]["MetadataToBoolCollectionInvocation"] | components["schemas"]["MetadataToBoolInvocation"] | components["schemas"]["MetadataToControlnetsInvocation"] | components["schemas"]["MetadataToFloatCollectionInvocation"] | components["schemas"]["MetadataToFloatInvocation"] | components["schemas"]["MetadataToIPAdaptersInvocation"] | components["schemas"]["MetadataToIntegerCollectionInvocation"] | components["schemas"]["MetadataToIntegerInvocation"] | components["schemas"]["MetadataToLorasCollectionInvocation"] | components["schemas"]["MetadataToLorasInvocation"] | components["schemas"]["MetadataToModelInvocation"] | components["schemas"]["MetadataToSDXLLorasInvocation"] | components["schemas"]["MetadataToSDXLModelInvocation"] | components["schemas"]["MetadataToSchedulerInvocation"] | components["schemas"]["MetadataToStringCollectionInvocation"] | components["schemas"]["MetadataToStringInvocation"] | components["schemas"]["MetadataToT2IAdaptersInvocation"] | components["schemas"]["MetadataToVAEInvocation"] | components["schemas"]["ModelIdentifierInvocation"] | components["schemas"]["MultiplyInvocation"] | components["schemas"]["NoiseInvocation"] | components["schemas"]["NormalMapInvocation"] | components["schemas"]["OklabUnsharpMaskInvocation"] | components["schemas"]["OklchImageHueAdjustmentInvocation"] | components["schemas"]["OpenAIImageGenerationInvocation"] | components["schemas"]["PBRMapsInvocation"] | components["schemas"]["PairTileImageInvocation"] | components["schemas"]["PasteImageIntoBoundingBoxInvocation"] | components["schemas"]["PiDiNetEdgeDetectionInvocation"] | components["schemas"]["PromptTemplateInvocation"] | components["schemas"]["PromptsFromFileInvocation"] | components["schemas"]["QwenImageDenoiseInvocation"] | components["schemas"]["QwenImageImageToLatentsInvocation"] | components["schemas"]["QwenImageLatentsToImageInvocation"] | components["schemas"]["QwenImageLoRACollectionLoader"] | components["schemas"]["QwenImageLoRALoaderInvocation"] | components["schemas"]["QwenImageModelLoaderInvocation"] | components["schemas"]["QwenImageTextEncoderInvocation"] | components["schemas"]["RandomFloatInvocation"] | components["schemas"]["RandomIntInvocation"] | components["schemas"]["RandomRangeInvocation"] | components["schemas"]["RangeInvocation"] | components["schemas"]["RangeOfSizeInvocation"] | components["schemas"]["RectangleMaskInvocation"] | components["schemas"]["ResizeLatentsInvocation"] | components["schemas"]["RoundInvocation"] | components["schemas"]["SD3DenoiseInvocation"] | components["schemas"]["SD3ImageToLatentsInvocation"] | components["schemas"]["SD3LatentsToImageInvocation"] | components["schemas"]["SDXLCompelPromptInvocation"] | components["schemas"]["SDXLLoRACollectionLoader"] | components["schemas"]["SDXLLoRALoaderInvocation"] | components["schemas"]["SDXLModelLoaderInvocation"] | components["schemas"]["SDXLRefinerCompelPromptInvocation"] | components["schemas"]["SDXLRefinerModelLoaderInvocation"] | components["schemas"]["SaveImageInvocation"] | components["schemas"]["ScaleLatentsInvocation"] | components["schemas"]["SchedulerInvocation"] | components["schemas"]["Sd3ModelLoaderInvocation"] | components["schemas"]["Sd3TextEncoderInvocation"] | components["schemas"]["SeamlessModeInvocation"] | components["schemas"]["SeedreamImageGenerationInvocation"] | components["schemas"]["SegmentAnythingInvocation"] | components["schemas"]["ShowImageInvocation"] | components["schemas"]["SpandrelImageToImageAutoscaleInvocation"] | components["schemas"]["SpandrelImageToImageInvocation"] | components["schemas"]["StringBatchInvocation"] | components["schemas"]["StringCollectionInvocation"] | components["schemas"]["StringGenerator"] | components["schemas"]["StringInvocation"] | components["schemas"]["StringJoinInvocation"] | components["schemas"]["StringJoinThreeInvocation"] | components["schemas"]["StringReplaceInvocation"] | components["schemas"]["StringSplitInvocation"] | components["schemas"]["StringSplitNegInvocation"] | components["schemas"]["SubtractInvocation"] | components["schemas"]["T2IAdapterInvocation"] | components["schemas"]["TextLLMInvocation"] | components["schemas"]["TileToPropertiesInvocation"] | components["schemas"]["TiledMultiDiffusionDenoiseLatents"] | components["schemas"]["UnsharpMaskInvocation"] | components["schemas"]["VAELoaderInvocation"] | components["schemas"]["ZImageControlInvocation"] | components["schemas"]["ZImageDenoiseInvocation"] | components["schemas"]["ZImageDenoiseMetaInvocation"] | components["schemas"]["ZImageImageToLatentsInvocation"] | components["schemas"]["ZImageLatentsToImageInvocation"] | components["schemas"]["ZImageLoRACollectionLoader"] | components["schemas"]["ZImageLoRALoaderInvocation"] | components["schemas"]["ZImageModelLoaderInvocation"] | components["schemas"]["ZImageSeedVarianceEnhancerInvocation"] | components["schemas"]["ZImageTextEncoderInvocation"];
/**
* Invocation Source Id
* @description The ID of the prepared invocation's source node
@@ -24095,6 +24097,112 @@ export type components = {
*/
items: components["schemas"]["ImageDTO"][];
};
+ /**
+ * Unsharp Mask (Oklab)
+ * @description Applies an unsharp mask filter to an image in the Oklab color space
+ */
+ OklabUnsharpMaskInvocation: {
+ /**
+ * @description The board to save the image to
+ * @default null
+ */
+ board?: components["schemas"]["BoardField"] | null;
+ /**
+ * @description Optional metadata to be saved with the image
+ * @default null
+ */
+ metadata?: components["schemas"]["MetadataField"] | null;
+ /**
+ * Id
+ * @description The id of this instance of an invocation. Must be unique among all instances of invocations.
+ */
+ id: string;
+ /**
+ * Is Intermediate
+ * @description Whether or not this is an intermediate invocation.
+ * @default false
+ */
+ is_intermediate?: boolean;
+ /**
+ * Use Cache
+ * @description Whether or not to use the cache
+ * @default true
+ */
+ use_cache?: boolean;
+ /**
+ * @description The image to use
+ * @default null
+ */
+ image?: components["schemas"]["ImageField"] | null;
+ /**
+ * Radius
+ * @description Unsharp mask radius
+ * @default 2
+ */
+ radius?: number;
+ /**
+ * Strength
+ * @description Unsharp mask strength
+ * @default 50
+ */
+ strength?: number;
+ /**
+ * type
+ * @default unsharp_mask_oklab
+ * @constant
+ */
+ type: "unsharp_mask_oklab";
+ };
+ /**
+ * Adjust Image Hue (Oklch)
+ * @description Adjusts the hue of an image in Oklch space.
+ */
+ OklchImageHueAdjustmentInvocation: {
+ /**
+ * @description The board to save the image to
+ * @default null
+ */
+ board?: components["schemas"]["BoardField"] | null;
+ /**
+ * @description Optional metadata to be saved with the image
+ * @default null
+ */
+ metadata?: components["schemas"]["MetadataField"] | null;
+ /**
+ * Id
+ * @description The id of this instance of an invocation. Must be unique among all instances of invocations.
+ */
+ id: string;
+ /**
+ * Is Intermediate
+ * @description Whether or not this is an intermediate invocation.
+ * @default false
+ */
+ is_intermediate?: boolean;
+ /**
+ * Use Cache
+ * @description Whether or not to use the cache
+ * @default true
+ */
+ use_cache?: boolean;
+ /**
+ * @description The image to adjust
+ * @default null
+ */
+ image?: components["schemas"]["ImageField"] | null;
+ /**
+ * Hue
+ * @description The degrees by which to rotate the hue, 0-360
+ * @default 0
+ */
+ hue?: number;
+ /**
+ * type
+ * @default img_hue_adjust_oklch
+ * @constant
+ */
+ type: "img_hue_adjust_oklch";
+ };
/**
* OpenAI Image Generation
* @description Generate images using an OpenAI-hosted external model.
diff --git a/invokeai/invocation_api/__init__.py b/invokeai/invocation_api/__init__.py
index 3efc01f887..7cc5e065fd 100644
--- a/invokeai/invocation_api/__init__.py
+++ b/invokeai/invocation_api/__init__.py
@@ -80,6 +80,45 @@ from invokeai.app.services.image_records.image_records_common import ImageCatego
from invokeai.app.services.shared.invocation_context import InvocationContext
from invokeai.app.services.workflow_records.workflow_records_common import WorkflowWithoutID
from invokeai.app.util.misc import SEED_MAX, get_random_seed
+from invokeai.backend.image_util.color_conversion import (
+ gamut_clip_tensor,
+ hsl_from_linear_srgb,
+ hsl_from_srgb,
+ lab_from_linear_srgb,
+ lab_from_srgb,
+ lab_from_xyz,
+ linear_srgb_from_hsl,
+ linear_srgb_from_lab,
+ linear_srgb_from_oklab,
+ linear_srgb_from_oklch,
+ linear_srgb_from_srgb,
+ linear_srgb_from_xyz,
+ okhsl_from_srgb,
+ okhsv_from_srgb,
+ oklab_from_linear_srgb,
+ oklab_from_oklch,
+ oklab_from_srgb,
+ oklab_from_xyz,
+ oklch_from_linear_srgb,
+ oklch_from_oklab,
+ oklch_from_srgb,
+ oklch_from_xyz,
+ srgb_from_hsl,
+ srgb_from_lab,
+ srgb_from_linear_srgb,
+ srgb_from_okhsl,
+ srgb_from_okhsv,
+ srgb_from_oklab,
+ srgb_from_oklch,
+ srgb_from_xyz,
+ xyz_d50_to_d65,
+ xyz_d65_to_d50,
+ xyz_from_lab,
+ xyz_from_linear_srgb,
+ xyz_from_oklab,
+ xyz_from_oklch,
+ xyz_from_srgb,
+)
from invokeai.backend.model_manager.configs.factory import AnyModelConfig, ModelConfigFactory
from invokeai.backend.model_manager.load.load_base import LoadedModel
from invokeai.backend.model_manager.taxonomy import (
@@ -207,6 +246,44 @@ __all__ = [
# invokeai.app.util.misc
"SEED_MAX",
"get_random_seed",
+ # invokeai.backend.image_util.color_conversion
+ "linear_srgb_from_srgb",
+ "srgb_from_linear_srgb",
+ "oklab_from_srgb",
+ "oklab_from_linear_srgb",
+ "oklab_from_xyz",
+ "srgb_from_oklab",
+ "linear_srgb_from_oklab",
+ "oklch_from_linear_srgb",
+ "oklch_from_srgb",
+ "oklch_from_oklab",
+ "oklch_from_xyz",
+ "oklab_from_oklch",
+ "linear_srgb_from_oklch",
+ "srgb_from_oklch",
+ "xyz_from_linear_srgb",
+ "linear_srgb_from_xyz",
+ "xyz_from_srgb",
+ "srgb_from_xyz",
+ "xyz_d65_to_d50",
+ "xyz_d50_to_d65",
+ "xyz_from_oklab",
+ "xyz_from_oklch",
+ "lab_from_linear_srgb",
+ "linear_srgb_from_lab",
+ "lab_from_srgb",
+ "srgb_from_lab",
+ "lab_from_xyz",
+ "xyz_from_lab",
+ "hsl_from_linear_srgb",
+ "hsl_from_srgb",
+ "linear_srgb_from_hsl",
+ "srgb_from_hsl",
+ "okhsl_from_srgb",
+ "srgb_from_okhsl",
+ "okhsv_from_srgb",
+ "srgb_from_okhsv",
+ "gamut_clip_tensor",
# invokeai.backend.model_manager.taxonomy
"BaseModelType",
"ModelType",
diff --git a/tests/app/invocations/test_image.py b/tests/app/invocations/test_image.py
new file mode 100644
index 0000000000..7c0036d3db
--- /dev/null
+++ b/tests/app/invocations/test_image.py
@@ -0,0 +1,403 @@
+import importlib.util
+from pathlib import Path
+from types import SimpleNamespace
+from unittest.mock import MagicMock
+
+import numpy
+import torch
+from PIL import Image, ImageFilter
+
+from invokeai.app.invocations.image import ImageField, OklabUnsharpMaskInvocation, OklchImageHueAdjustmentInvocation
+from invokeai.backend.image_util.color_conversion import (
+ linear_srgb_from_oklab,
+ linear_srgb_from_oklch,
+ linear_srgb_from_srgb,
+ okhsl_from_srgb,
+ oklab_from_linear_srgb,
+ oklch_from_oklab,
+ srgb_from_hsl,
+ srgb_from_linear_srgb,
+ srgb_from_okhsl,
+)
+
+_COMPOSITION_NODES_SPEC = importlib.util.spec_from_file_location(
+ "invokeai.app.invocations.composition_nodes",
+ Path(__file__).resolve().parents[3] / "invokeai/app/invocations/composition-nodes.py",
+)
+assert _COMPOSITION_NODES_SPEC is not None
+assert _COMPOSITION_NODES_SPEC.loader is not None
+composition_nodes = importlib.util.module_from_spec(_COMPOSITION_NODES_SPEC)
+_COMPOSITION_NODES_SPEC.loader.exec_module(composition_nodes)
+InvokeAdjustImageHuePlusInvocation = composition_nodes.InvokeAdjustImageHuePlusInvocation
+InvokeImageBlendInvocation = composition_nodes.InvokeImageBlendInvocation
+
+
+def _build_context(input_image: Image.Image) -> MagicMock:
+ context = MagicMock()
+ context.images.get_pil.return_value = input_image
+ context.images.save.side_effect = lambda image: SimpleNamespace(
+ image_name="out", width=image.width, height=image.height
+ )
+ return context
+
+
+def _max_abs_diff_uint8(left: Image.Image, right: Image.Image) -> int:
+ left_arr = numpy.asarray(left, dtype=numpy.int16)
+ right_arr = numpy.asarray(right, dtype=numpy.int16)
+ return int(numpy.abs(left_arr - right_arr).max())
+
+
+def test_oklab_unsharp_mask_invocation_preserves_alpha_and_sharpens_lightness_only() -> None:
+ input_image = Image.new("RGBA", (3, 1))
+ input_image.putdata(
+ [
+ (255, 0, 0, 32),
+ (0, 255, 0, 128),
+ (0, 0, 255, 224),
+ ]
+ )
+
+ context = _build_context(input_image)
+
+ invocation = OklabUnsharpMaskInvocation(image=ImageField(image_name="in"), radius=1.0, strength=50.0)
+ output = invocation.invoke(context)
+ saved_image = context.images.save.call_args.kwargs["image"]
+
+ assert output.image.image_name == "out"
+ assert output.width == 3
+ assert output.height == 1
+ assert numpy.asarray(saved_image.getchannel("A")).reshape(-1).tolist() == [32, 128, 224]
+
+ rgb = torch.from_numpy(numpy.asarray(input_image.convert("RGB"), dtype=numpy.float32) / 255.0).permute(2, 0, 1)
+ blurred_rgb = torch.from_numpy(
+ numpy.asarray(input_image.convert("RGB").filter(ImageFilter.GaussianBlur(radius=1.0)), dtype=numpy.float32)
+ / 255.0
+ ).permute(2, 0, 1)
+
+ rgb_unsharp = torch.clamp(rgb + (rgb - blurred_rgb) * 0.5, 0.0, 1.0)
+ rgb_oklab = oklab_from_linear_srgb(linear_srgb_from_srgb(rgb))
+ blurred_oklab = oklab_from_linear_srgb(linear_srgb_from_srgb(blurred_rgb))
+ expected_oklab = rgb_oklab.clone()
+ expected_oklab[0, ...] = torch.clamp(
+ rgb_oklab[0, ...] + (rgb_oklab[0, ...] - blurred_oklab[0, ...]) * 0.5,
+ -1.0,
+ 1.0,
+ )
+ oklab_unsharp = srgb_from_linear_srgb(linear_srgb_from_oklab(expected_oklab))
+
+ assert not torch.allclose(oklab_unsharp, rgb_unsharp, atol=1e-3)
+ assert numpy.allclose(
+ numpy.asarray(saved_image.convert("RGB"), dtype=numpy.float32) / 255.0,
+ oklab_unsharp.permute(1, 2, 0).numpy(),
+ atol=1 / 255.0,
+ )
+
+
+def test_oklch_hue_adjustment_invocation_preserves_alpha_and_rotates_hue_in_oklch() -> None:
+ input_image = Image.new("RGBA", (2, 1))
+ input_image.putdata(
+ [
+ (210, 80, 30, 64),
+ (40, 160, 220, 192),
+ ]
+ )
+
+ context = _build_context(input_image)
+
+ invocation = OklchImageHueAdjustmentInvocation(image=ImageField(image_name="in"), hue=180)
+ output = invocation.invoke(context)
+ saved_image = context.images.save.call_args.kwargs["image"]
+
+ rgb = torch.from_numpy(numpy.asarray(input_image.convert("RGB"), dtype=numpy.float32) / 255.0).permute(2, 0, 1)
+ oklch = oklch_from_oklab(oklab_from_linear_srgb(linear_srgb_from_srgb(rgb)))
+ rotated_oklch = oklch.clone()
+ rotated_oklch[2, ...] = (rotated_oklch[2, ...] + 180.0) % 360.0
+ expected_rgb = srgb_from_linear_srgb(linear_srgb_from_oklch(rotated_oklch))
+
+ assert output.image.image_name == "out"
+ assert output.width == 2
+ assert output.height == 1
+ assert numpy.asarray(saved_image.getchannel("A")).reshape(-1).tolist() == [64, 192]
+ assert numpy.allclose(
+ numpy.asarray(saved_image.convert("RGB"), dtype=numpy.float32) / 255.0,
+ expected_rgb.permute(1, 2, 0).numpy(),
+ atol=1 / 255.0,
+ )
+
+
+def test_oklab_unsharp_mask_invocation_zero_strength_returns_original_image() -> None:
+ input_image = Image.new("RGBA", (2, 2))
+ input_image.putdata(
+ [
+ (12, 34, 56, 78),
+ (90, 123, 45, 67),
+ (210, 40, 80, 90),
+ (255, 200, 10, 255),
+ ]
+ )
+ context = _build_context(input_image)
+
+ invocation = OklabUnsharpMaskInvocation(image=ImageField(image_name="in"), radius=1.5, strength=0.0)
+ invocation.invoke(context)
+ saved_image = context.images.save.call_args.kwargs["image"]
+
+ assert _max_abs_diff_uint8(saved_image, input_image) <= 1
+
+
+def test_oklab_unsharp_mask_invocation_does_not_introduce_color_on_grayscale_image() -> None:
+ input_image = Image.new("RGB", (3, 1))
+ input_image.putdata([(32, 32, 32), (128, 128, 128), (224, 224, 224)])
+ context = _build_context(input_image)
+
+ invocation = OklabUnsharpMaskInvocation(image=ImageField(image_name="in"), radius=1.0, strength=80.0)
+ invocation.invoke(context)
+ saved_image = context.images.save.call_args.kwargs["image"]
+ saved_rgb = numpy.asarray(saved_image.convert("RGB"), dtype=numpy.uint8)
+
+ assert numpy.abs(saved_rgb[..., 0].astype(numpy.int16) - saved_rgb[..., 1].astype(numpy.int16)).max() <= 1
+ assert numpy.abs(saved_rgb[..., 1].astype(numpy.int16) - saved_rgb[..., 2].astype(numpy.int16)).max() <= 1
+
+
+def test_oklab_unsharp_mask_invocation_clips_extreme_values_to_valid_rgb_range() -> None:
+ input_image = Image.new("RGB", (3, 1))
+ input_image.putdata([(255, 255, 255), (0, 0, 0), (255, 255, 255)])
+ context = _build_context(input_image)
+
+ invocation = OklabUnsharpMaskInvocation(image=ImageField(image_name="in"), radius=2.0, strength=500.0)
+ invocation.invoke(context)
+ saved_rgb = numpy.asarray(context.images.save.call_args.kwargs["image"].convert("RGB"), dtype=numpy.uint8)
+
+ assert saved_rgb.min() >= 0
+ assert saved_rgb.max() <= 255
+
+
+def test_oklch_hue_adjustment_invocation_wraps_hue_values_and_supports_rgb_input() -> None:
+ input_image = Image.new("RGB", (2, 1))
+ input_image.putdata([(210, 80, 30), (40, 160, 220)])
+
+ base_context = _build_context(input_image)
+ zero_output = OklchImageHueAdjustmentInvocation(image=ImageField(image_name="in"), hue=0).invoke(base_context)
+ zero_saved = base_context.images.save.call_args.kwargs["image"]
+
+ full_turn_context = _build_context(input_image)
+ full_turn_output = OklchImageHueAdjustmentInvocation(image=ImageField(image_name="in"), hue=360).invoke(
+ full_turn_context
+ )
+ full_turn_saved = full_turn_context.images.save.call_args.kwargs["image"]
+
+ negative_context = _build_context(input_image)
+ OklchImageHueAdjustmentInvocation(image=ImageField(image_name="in"), hue=-180).invoke(negative_context)
+ negative_saved = negative_context.images.save.call_args.kwargs["image"]
+
+ positive_context = _build_context(input_image)
+ OklchImageHueAdjustmentInvocation(image=ImageField(image_name="in"), hue=180).invoke(positive_context)
+ positive_saved = positive_context.images.save.call_args.kwargs["image"]
+
+ assert zero_output.width == 2
+ assert zero_output.height == 1
+ assert full_turn_output.width == 2
+ assert full_turn_output.height == 1
+ assert _max_abs_diff_uint8(zero_saved, input_image) <= 1
+ assert _max_abs_diff_uint8(full_turn_saved, input_image) <= 1
+ assert _max_abs_diff_uint8(negative_saved, positive_saved) <= 1
+
+
+def test_new_oklab_nodes_preserve_alpha_for_non_rgba_alpha_modes() -> None:
+ la_image = Image.new("LA", (2, 1))
+ la_image.putdata([(32, 64), (192, 224)])
+
+ unsharp_context = _build_context(la_image)
+ OklabUnsharpMaskInvocation(image=ImageField(image_name="in"), radius=1.0, strength=25.0).invoke(unsharp_context)
+ unsharp_saved = unsharp_context.images.save.call_args.kwargs["image"]
+
+ hue_context = _build_context(la_image)
+ OklchImageHueAdjustmentInvocation(image=ImageField(image_name="in"), hue=45).invoke(hue_context)
+ hue_saved = hue_context.images.save.call_args.kwargs["image"]
+
+ assert unsharp_saved.mode == "LA"
+ assert hue_saved.mode == "LA"
+ assert numpy.asarray(unsharp_saved.getchannel("A")).reshape(-1).tolist() == [64, 224]
+ assert numpy.asarray(hue_saved.getchannel("A")).reshape(-1).tolist() == [64, 224]
+
+
+def test_hue_adjust_plus_oklch_uses_degree_based_oklch_contract() -> None:
+ input_image = Image.new("RGB", (2, 1))
+ input_image.putdata([(210, 80, 30), (40, 160, 220)])
+
+ context = _build_context(input_image)
+ invocation = InvokeAdjustImageHuePlusInvocation(
+ image=ImageField(image_name="in"),
+ space="*Oklch / Oklab",
+ degrees=180.0,
+ ok_adaptive_gamut=0.0,
+ )
+
+ output = invocation.invoke(context)
+ saved_image = context.images.save.call_args.args[0]
+
+ rgb = torch.from_numpy(numpy.asarray(input_image, dtype=numpy.float32) / 255.0).permute(2, 0, 1)
+ oklch = oklch_from_oklab(oklab_from_linear_srgb(linear_srgb_from_srgb(rgb)))
+ rotated_oklch = oklch.clone()
+ rotated_oklch[2, ...] = (rotated_oklch[2, ...] + 180.0) % 360.0
+ expected_rgb = srgb_from_linear_srgb(linear_srgb_from_oklch(rotated_oklch))
+
+ assert output.width == 2
+ assert output.height == 1
+ assert numpy.allclose(
+ numpy.asarray(saved_image.convert("RGB"), dtype=numpy.float32) / 255.0,
+ expected_rgb.permute(1, 2, 0).numpy(),
+ atol=1 / 255.0,
+ )
+
+
+def test_hue_adjust_plus_hsv_uses_degree_hue_contract() -> None:
+ input_image = Image.new("RGB", (2, 1))
+ input_image.putdata([(210, 80, 30), (40, 160, 220)])
+
+ context = _build_context(input_image)
+ invocation = InvokeAdjustImageHuePlusInvocation(
+ image=ImageField(image_name="in"),
+ space="HSV / HSL / RGB",
+ degrees=90.0,
+ )
+
+ output = invocation.invoke(context)
+ saved_image = context.images.save.call_args.args[0]
+
+ hsv = numpy.asarray(input_image.convert("HSV"), dtype=numpy.float32) / 255.0
+ hsv[..., 0] = ((hsv[..., 0] * 360.0) + 90.0) % 360.0 / 360.0
+ expected_rgb = Image.fromarray((hsv * 255.0).astype(numpy.uint8), mode="HSV").convert("RGB")
+
+ assert output.width == 2
+ assert output.height == 1
+ assert _max_abs_diff_uint8(saved_image.convert("RGB"), expected_rgb) <= 1
+
+
+def test_hue_adjust_plus_okhsl_uses_degree_hue_contract() -> None:
+ input_image = Image.new("RGB", (2, 1))
+ input_image.putdata([(210, 80, 30), (40, 160, 220)])
+
+ context = _build_context(input_image)
+ invocation = InvokeAdjustImageHuePlusInvocation(
+ image=ImageField(image_name="in"),
+ space="Okhsl",
+ degrees=90.0,
+ ok_adaptive_gamut=0.0,
+ )
+
+ output = invocation.invoke(context)
+ saved_image = context.images.save.call_args.args[0]
+
+ rgb = torch.from_numpy(numpy.asarray(input_image, dtype=numpy.float32) / 255.0).permute(2, 0, 1)
+ okhsl = okhsl_from_srgb(rgb)
+ rotated_okhsl = okhsl.clone()
+ rotated_okhsl[0, ...] = (rotated_okhsl[0, ...] + 90.0) % 360.0
+ expected_rgb = srgb_from_okhsl(rotated_okhsl)
+
+ assert output.width == 2
+ assert output.height == 1
+ assert numpy.allclose(
+ numpy.asarray(saved_image.convert("RGB"), dtype=numpy.float32) / 255.0,
+ expected_rgb.permute(1, 2, 0).numpy(),
+ atol=1 / 255.0,
+ )
+
+
+def test_image_blend_oklch_subtract_wraps_hue_in_degrees() -> None:
+ invocation = InvokeImageBlendInvocation(
+ layer_upper=ImageField(image_name="upper"),
+ layer_base=ImageField(image_name="base"),
+ blend_mode="Subtract",
+ color_space="Oklch (Oklab)",
+ opacity=1.0,
+ adaptive_gamut=0.0,
+ )
+
+ upper_oklch = torch.tensor([[[0.0]], [[0.0]], [[20.0]]], dtype=torch.float32)
+ lower_oklch = torch.tensor([[[0.6]], [[0.18]], [[350.0]]], dtype=torch.float32)
+ expected_linear_srgb = linear_srgb_from_oklch(torch.tensor([[[0.6]], [[0.18]], [[330.0]]], dtype=torch.float32))
+
+ blank_rgb = torch.zeros((3, 1, 1), dtype=torch.float32)
+ blank_alpha = torch.ones((1, 1), dtype=torch.float32)
+ image_tensors = (
+ blank_rgb,
+ blank_rgb,
+ blank_rgb,
+ blank_rgb,
+ blank_alpha,
+ blank_alpha,
+ None,
+ None,
+ None,
+ None,
+ None,
+ None,
+ None,
+ None,
+ None,
+ None,
+ None,
+ None,
+ None,
+ upper_oklch,
+ lower_oklch,
+ None,
+ None,
+ None,
+ None,
+ )
+
+ blended = invocation.apply_blend(image_tensors)
+
+ assert torch.allclose(blended, expected_linear_srgb, atol=1e-5)
+
+
+def test_image_blend_hsl_subtract_wraps_hue_in_degrees() -> None:
+ invocation = InvokeImageBlendInvocation(
+ layer_upper=ImageField(image_name="upper"),
+ layer_base=ImageField(image_name="base"),
+ blend_mode="Subtract",
+ color_space="HSL (RGB)",
+ opacity=1.0,
+ adaptive_gamut=0.0,
+ )
+
+ upper_hsl = torch.tensor([[[20.0]], [[0.0]], [[0.0]]], dtype=torch.float32)
+ lower_hsl = torch.tensor([[[350.0]], [[1.0]], [[0.5]]], dtype=torch.float32)
+ expected_linear_srgb = linear_srgb_from_srgb(
+ srgb_from_hsl(torch.tensor([[[330.0]], [[1.0]], [[0.5]]], dtype=torch.float32))
+ )
+
+ blank_rgb = torch.zeros((3, 1, 1), dtype=torch.float32)
+ blank_alpha = torch.ones((1, 1), dtype=torch.float32)
+ image_tensors = (
+ blank_rgb,
+ blank_rgb,
+ blank_rgb,
+ blank_rgb,
+ blank_alpha,
+ blank_alpha,
+ None,
+ None,
+ None,
+ upper_hsl,
+ lower_hsl,
+ None,
+ None,
+ None,
+ None,
+ None,
+ None,
+ None,
+ None,
+ None,
+ None,
+ None,
+ None,
+ None,
+ None,
+ )
+
+ blended = invocation.apply_blend(image_tensors)
+
+ assert torch.allclose(blended, expected_linear_srgb, atol=1e-5)
diff --git a/tests/backend/image_util/test_color_conversion.py b/tests/backend/image_util/test_color_conversion.py
new file mode 100644
index 0000000000..ce186bff3a
--- /dev/null
+++ b/tests/backend/image_util/test_color_conversion.py
@@ -0,0 +1,620 @@
+import pytest
+import torch
+
+from invokeai.backend.image_util import color_conversion
+from invokeai.invocation_api import (
+ hsl_from_linear_srgb,
+ hsl_from_srgb,
+ lab_from_linear_srgb,
+ lab_from_srgb,
+ lab_from_xyz,
+ linear_srgb_from_hsl,
+ linear_srgb_from_lab,
+ linear_srgb_from_oklab,
+ linear_srgb_from_oklch,
+ linear_srgb_from_srgb,
+ linear_srgb_from_xyz,
+ okhsl_from_srgb,
+ okhsv_from_srgb,
+ oklab_from_linear_srgb,
+ oklab_from_oklch,
+ oklab_from_srgb,
+ oklab_from_xyz,
+ oklch_from_linear_srgb,
+ oklch_from_oklab,
+ oklch_from_srgb,
+ oklch_from_xyz,
+ srgb_from_hsl,
+ srgb_from_lab,
+ srgb_from_linear_srgb,
+ srgb_from_okhsl,
+ srgb_from_okhsv,
+ srgb_from_oklab,
+ srgb_from_oklch,
+ srgb_from_xyz,
+ xyz_d50_to_d65,
+ xyz_d65_to_d50,
+ xyz_from_lab,
+ xyz_from_linear_srgb,
+ xyz_from_oklab,
+ xyz_from_oklch,
+ xyz_from_srgb,
+)
+
+
+def test_srgb_oklab_round_trip() -> None:
+ srgb = torch.tensor(
+ [
+ [[0.0, 1.0], [1.0, 0.1]],
+ [[0.0, 1.0], [0.0, 0.6]],
+ [[0.0, 1.0], [0.0, 0.9]],
+ ],
+ dtype=torch.float32,
+ )
+
+ round_tripped = srgb_from_linear_srgb(linear_srgb_from_oklab(oklab_from_linear_srgb(linear_srgb_from_srgb(srgb))))
+
+ assert torch.allclose(round_tripped, srgb, atol=1e-5)
+
+
+def test_oklab_from_srgb_matches_explicit_conversion_path() -> None:
+ srgb = torch.tensor(
+ [
+ [[0.0, 1.0], [1.0, 0.1]],
+ [[0.0, 1.0], [0.0, 0.6]],
+ [[0.0, 1.0], [0.0, 0.9]],
+ ],
+ dtype=torch.float32,
+ )
+
+ direct = oklab_from_srgb(srgb)
+ via_linear_srgb = oklab_from_linear_srgb(linear_srgb_from_srgb(srgb))
+
+ assert torch.allclose(direct, via_linear_srgb, atol=1e-6)
+
+
+def test_srgb_from_oklab_matches_explicit_conversion_path() -> None:
+ oklab = torch.tensor(
+ [
+ [[0.6, 0.4]],
+ [[0.2, -0.1]],
+ [[0.1, 0.05]],
+ ],
+ dtype=torch.float32,
+ )
+
+ direct = srgb_from_oklab(oklab)
+ via_linear_srgb = srgb_from_linear_srgb(linear_srgb_from_oklab(oklab))
+
+ assert torch.allclose(direct, via_linear_srgb, atol=1e-6)
+
+
+def test_oklab_from_pure_srgb_red_matches_reference_value() -> None:
+ srgb_red = torch.tensor([[[1.0]], [[0.0]], [[0.0]]], dtype=torch.float32)
+
+ oklab_red = oklab_from_linear_srgb(linear_srgb_from_srgb(srgb_red))
+
+ assert torch.allclose(
+ oklab_red[:, 0, 0],
+ torch.tensor([0.62795536, 0.22486306, 0.1258463], dtype=torch.float32),
+ atol=1e-6,
+ )
+
+
+def test_oklab_oklch_round_trip() -> None:
+ oklab = torch.tensor(
+ [
+ [[0.6, 0.4]],
+ [[0.2, -0.1]],
+ [[0.1, 0.05]],
+ ],
+ dtype=torch.float32,
+ )
+
+ round_tripped = oklab_from_oklch(oklch_from_oklab(oklab))
+
+ assert torch.allclose(round_tripped, oklab, atol=1e-6)
+
+
+def test_oklch_from_linear_srgb_matches_explicit_conversion_path() -> None:
+ linear_srgb = torch.tensor(
+ [
+ [[0.1, 0.9]],
+ [[0.4, 0.2]],
+ [[0.7, 0.3]],
+ ],
+ dtype=torch.float32,
+ )
+
+ direct = oklch_from_linear_srgb(linear_srgb)
+ via_oklab = oklch_from_oklab(oklab_from_linear_srgb(linear_srgb))
+
+ assert torch.allclose(direct, via_oklab, atol=1e-6)
+
+
+def test_oklch_from_srgb_and_back_round_trip() -> None:
+ srgb = torch.tensor(
+ [
+ [[0.2, 0.9]],
+ [[0.4, 0.3]],
+ [[0.8, 0.1]],
+ ],
+ dtype=torch.float32,
+ )
+
+ direct_round_trip = srgb_from_oklch(oklch_from_srgb(srgb))
+ explicit_round_trip = srgb_from_linear_srgb(
+ linear_srgb_from_oklch(oklch_from_oklab(oklab_from_linear_srgb(linear_srgb_from_srgb(srgb))))
+ )
+
+ assert torch.allclose(direct_round_trip, srgb, atol=1e-5)
+ assert torch.allclose(explicit_round_trip, srgb, atol=1e-5)
+
+
+def test_linear_srgb_from_oklch_matches_oklab_path() -> None:
+ oklch = torch.tensor(
+ [
+ [[0.7, 0.5]],
+ [[0.12, 0.04]],
+ [[30.0, 210.0]],
+ ],
+ dtype=torch.float32,
+ )
+
+ direct = linear_srgb_from_oklch(oklch)
+ via_oklab = linear_srgb_from_oklab(oklab_from_oklch(oklch))
+
+ assert torch.allclose(direct, via_oklab, atol=1e-6)
+ assert direct.shape == (3, 1, 2)
+
+
+def test_hsl_srgb_round_trip() -> None:
+ srgb = torch.tensor(
+ [
+ [[0.0, 1.0], [0.25, 0.9]],
+ [[0.2, 0.8], [0.75, 0.1]],
+ [[1.0, 0.1], [0.5, 0.4]],
+ ],
+ dtype=torch.float32,
+ )
+
+ round_tripped = srgb_from_hsl(hsl_from_srgb(srgb))
+
+ assert torch.allclose(round_tripped, srgb, atol=1e-5)
+
+
+def test_hsl_hue_is_expressed_in_degrees() -> None:
+ srgb = torch.tensor(
+ [
+ [[1.0, 0.0, 0.0]],
+ [[0.0, 1.0, 0.0]],
+ [[0.0, 0.0, 1.0]],
+ ],
+ dtype=torch.float32,
+ )
+
+ hsl = hsl_from_srgb(srgb)
+
+ assert torch.allclose(hsl[0, 0, :], torch.tensor([0.0, 120.0, 240.0]), atol=1e-3)
+ assert torch.allclose(hsl[1, 0, :], torch.tensor([1.0, 1.0, 1.0]), atol=1e-6)
+ assert torch.allclose(hsl[2, 0, :], torch.tensor([0.5, 0.5, 0.5]), atol=1e-6)
+
+
+def test_hsl_from_grayscale_has_zero_saturation() -> None:
+ srgb = torch.tensor(
+ [
+ [[0.1, 0.8]],
+ [[0.1, 0.8]],
+ [[0.1, 0.8]],
+ ],
+ dtype=torch.float32,
+ )
+
+ hsl = hsl_from_srgb(srgb)
+
+ assert torch.allclose(hsl[1, ...], torch.zeros_like(hsl[1, ...]), atol=1e-6)
+
+
+def test_hsl_from_linear_srgb_matches_explicit_conversion_path() -> None:
+ linear_srgb = torch.tensor(
+ [
+ [[0.0, 1.0], [0.25, 0.8]],
+ [[0.2, 0.8], [0.75, 0.1]],
+ [[1.0, 0.1], [0.5, 0.4]],
+ ],
+ dtype=torch.float32,
+ )
+
+ direct = hsl_from_linear_srgb(linear_srgb)
+ via_srgb = hsl_from_srgb(srgb_from_linear_srgb(linear_srgb))
+
+ assert torch.allclose(direct, via_srgb, atol=1e-6)
+
+
+def test_linear_srgb_from_hsl_matches_explicit_conversion_path() -> None:
+ hsl = torch.tensor(
+ [
+ [[0.0, 216.0], [90.0, 324.0]],
+ [[1.0, 0.25], [0.75, 0.1]],
+ [[0.5, 0.4], [0.2, 0.8]],
+ ],
+ dtype=torch.float32,
+ )
+
+ direct = linear_srgb_from_hsl(hsl)
+ via_srgb = linear_srgb_from_srgb(srgb_from_hsl(hsl))
+
+ assert torch.allclose(direct, via_srgb, atol=1e-6)
+
+
+def test_srgb_from_hsl_wraps_degree_hue_values() -> None:
+ hsl = torch.tensor(
+ [
+ [[360.0, -120.0]],
+ [[1.0, 1.0]],
+ [[0.5, 0.5]],
+ ],
+ dtype=torch.float32,
+ )
+
+ rgb = srgb_from_hsl(hsl)
+
+ assert torch.allclose(rgb[:, 0, 0], torch.tensor([1.0, 0.0, 0.0]), atol=1e-5)
+ assert torch.allclose(rgb[:, 0, 1], torch.tensor([0.0, 0.0, 1.0]), atol=1e-5)
+
+
+def test_okhsl_srgb_round_trip() -> None:
+ srgb = torch.tensor(
+ [
+ [[0.05, 0.95], [0.2, 0.8]],
+ [[0.4, 0.2], [0.6, 0.1]],
+ [[0.9, 0.05], [0.3, 0.7]],
+ ],
+ dtype=torch.float32,
+ )
+
+ round_tripped = srgb_from_okhsl(okhsl_from_srgb(srgb))
+
+ assert torch.allclose(round_tripped, srgb, atol=5e-4)
+
+
+def test_okhsl_and_okhsv_hue_are_expressed_in_degrees() -> None:
+ srgb = torch.tensor(
+ [
+ [[1.0, 0.0, 0.0]],
+ [[0.0, 1.0, 0.0]],
+ [[0.0, 0.0, 1.0]],
+ ],
+ dtype=torch.float32,
+ )
+
+ okhsl = okhsl_from_srgb(srgb)
+ okhsv = okhsv_from_srgb(srgb)
+
+ assert torch.allclose(okhsl[0, 0, :], torch.tensor([29.2473, 142.4848, 264.0487]), atol=2e-2)
+ assert torch.allclose(okhsv[0, 0, :], torch.tensor([29.2473, 142.4848, 264.0487]), atol=2e-2)
+ assert torch.allclose(okhsl[1, 0, :], torch.tensor([1.0, 1.0, 1.0]), atol=1e-6)
+ assert torch.allclose(okhsv[1, 0, :], torch.tensor([1.0, 1.0, 1.0]), atol=1e-6)
+
+
+def test_okhsl_and_okhsv_srgb_round_trip() -> None:
+ srgb = torch.tensor(
+ [
+ [[0.05, 0.95], [0.2, 0.8]],
+ [[0.4, 0.2], [0.6, 0.1]],
+ [[0.9, 0.05], [0.3, 0.7]],
+ ],
+ dtype=torch.float32,
+ )
+
+ okhsl_round_tripped = srgb_from_okhsl(okhsl_from_srgb(srgb))
+ okhsv_round_tripped = srgb_from_okhsv(okhsv_from_srgb(srgb))
+
+ assert torch.allclose(okhsl_round_tripped, srgb, atol=5e-4)
+ assert torch.allclose(okhsv_round_tripped, srgb, atol=5e-4)
+
+
+def test_okhsl_and_okhsv_outputs_keep_hue_in_degrees_and_other_channels_in_unit_range() -> None:
+ srgb = torch.tensor(
+ [
+ [[0.0, 1.0]],
+ [[1.0, 0.0]],
+ [[0.5, 0.25]],
+ ],
+ dtype=torch.float32,
+ )
+
+ okhsl = okhsl_from_srgb(srgb)
+ okhsv = okhsv_from_srgb(srgb)
+
+ assert torch.all(okhsl[0, ...] >= 0.0)
+ assert torch.all(okhsl[0, ...] <= 360.0)
+ assert torch.all(okhsl[1:, ...] >= 0.0)
+ assert torch.all(okhsl[1:, ...] <= 1.0)
+ assert torch.all(okhsv[0, ...] >= 0.0)
+ assert torch.all(okhsv[0, ...] <= 360.0)
+ assert torch.all(okhsv[1:, ...] >= 0.0)
+ assert torch.all(okhsv[1:, ...] <= 1.0)
+
+
+def test_okhsl_and_okhsv_wrap_degree_hue_values() -> None:
+ okhsl = torch.tensor([[[389.2473]], [[1.0]], [[0.5681]]], dtype=torch.float32)
+ okhsl_wrapped = torch.tensor([[[29.2473]], [[1.0]], [[0.5681]]], dtype=torch.float32)
+ okhsv = torch.tensor([[[389.2473]], [[1.0]], [[1.0]]], dtype=torch.float32)
+ okhsv_wrapped = torch.tensor([[[29.2473]], [[1.0]], [[1.0]]], dtype=torch.float32)
+
+ assert torch.allclose(srgb_from_okhsl(okhsl), srgb_from_okhsl(okhsl_wrapped), atol=1e-5)
+ assert torch.allclose(srgb_from_okhsv(okhsv), srgb_from_okhsv(okhsv_wrapped), atol=1e-5)
+
+
+def test_linear_srgb_xyz_round_trip() -> None:
+ linear_srgb = torch.tensor(
+ [
+ [[0.0, 1.0], [0.25, 0.8]],
+ [[0.2, 0.8], [0.75, 0.1]],
+ [[1.0, 0.1], [0.5, 0.4]],
+ ],
+ dtype=torch.float32,
+ )
+
+ round_tripped = linear_srgb_from_xyz(xyz_from_linear_srgb(linear_srgb))
+
+ assert torch.allclose(round_tripped, linear_srgb, atol=5e-5)
+
+
+def test_oklab_from_xyz_matches_explicit_conversion_path() -> None:
+ xyz = torch.tensor(
+ [
+ [[0.4124, 0.9505]],
+ [[0.2126, 1.0]],
+ [[0.0193, 1.0888]],
+ ],
+ dtype=torch.float32,
+ )
+
+ direct = oklab_from_xyz(xyz)
+ via_linear_srgb = oklab_from_linear_srgb(linear_srgb_from_xyz(xyz))
+
+ assert torch.allclose(direct, via_linear_srgb, atol=1e-6)
+
+
+def test_xyz_from_oklab_matches_explicit_conversion_path() -> None:
+ oklab = torch.tensor(
+ [
+ [[0.6, 0.4]],
+ [[0.2, -0.1]],
+ [[0.1, 0.05]],
+ ],
+ dtype=torch.float32,
+ )
+
+ direct = xyz_from_oklab(oklab)
+ via_linear_srgb = xyz_from_linear_srgb(linear_srgb_from_oklab(oklab))
+
+ assert torch.allclose(direct, via_linear_srgb, atol=1e-6)
+
+
+def test_oklch_from_xyz_matches_explicit_conversion_path() -> None:
+ xyz = torch.tensor(
+ [
+ [[0.4124, 0.9505]],
+ [[0.2126, 1.0]],
+ [[0.0193, 1.0888]],
+ ],
+ dtype=torch.float32,
+ )
+
+ direct = oklch_from_xyz(xyz)
+ via_oklab = oklch_from_oklab(oklab_from_xyz(xyz))
+
+ assert torch.allclose(direct, via_oklab, atol=1e-6)
+
+
+def test_xyz_from_oklch_matches_explicit_conversion_path() -> None:
+ oklch = torch.tensor(
+ [
+ [[0.7, 0.5]],
+ [[0.12, 0.04]],
+ [[30.0, 210.0]],
+ ],
+ dtype=torch.float32,
+ )
+
+ direct = xyz_from_oklch(oklch)
+ via_oklab = xyz_from_oklab(oklab_from_oklch(oklch))
+
+ assert torch.allclose(direct, via_oklab, atol=1e-6)
+
+
+def test_lab_from_linear_srgb_matches_explicit_conversion_path() -> None:
+ linear_srgb = torch.tensor(
+ [
+ [[0.0, 1.0], [0.25, 0.8]],
+ [[0.2, 0.8], [0.75, 0.1]],
+ [[1.0, 0.1], [0.5, 0.4]],
+ ],
+ dtype=torch.float32,
+ )
+
+ direct = lab_from_linear_srgb(linear_srgb)
+ via_xyz = lab_from_xyz(xyz_from_linear_srgb(linear_srgb))
+
+ assert torch.allclose(direct, via_xyz, atol=1e-6)
+
+
+def test_linear_srgb_from_lab_matches_explicit_conversion_path() -> None:
+ lab = torch.tensor(
+ [
+ [[0.0, 100.0], [50.0, 75.0]],
+ [[0.0, 0.0], [10.0, -20.0]],
+ [[0.0, 0.0], [-5.0, 30.0]],
+ ],
+ dtype=torch.float32,
+ )
+
+ direct = linear_srgb_from_lab(lab)
+ via_xyz = linear_srgb_from_xyz(xyz_from_lab(lab))
+
+ assert torch.allclose(direct, via_xyz, atol=1e-6)
+
+
+def test_srgb_xyz_round_trip() -> None:
+ srgb = torch.tensor(
+ [
+ [[0.0, 1.0], [0.25, 0.8]],
+ [[0.2, 0.8], [0.75, 0.1]],
+ [[1.0, 0.1], [0.5, 0.4]],
+ ],
+ dtype=torch.float32,
+ )
+
+ round_tripped = srgb_from_xyz(xyz_from_srgb(srgb))
+
+ assert torch.allclose(round_tripped, srgb, atol=5e-4)
+
+
+def test_lab_from_srgb_and_back_round_trip() -> None:
+ srgb = torch.tensor(
+ [
+ [[0.0, 1.0], [0.25, 0.8]],
+ [[0.2, 0.8], [0.75, 0.1]],
+ [[1.0, 0.1], [0.5, 0.4]],
+ ],
+ dtype=torch.float32,
+ )
+
+ round_tripped = srgb_from_lab(lab_from_srgb(srgb))
+
+ assert torch.allclose(round_tripped, srgb, atol=5e-4)
+
+
+def test_xyz_lab_round_trip_for_d65_and_d50() -> None:
+ xyz = torch.tensor(
+ [
+ [[0.4124, 0.9505]],
+ [[0.2126, 1.0]],
+ [[0.0193, 1.0888]],
+ ],
+ dtype=torch.float32,
+ )
+
+ round_tripped_d65 = xyz_from_lab(lab_from_xyz(xyz, reference_illuminant="D65"), reference_illuminant="D65")
+ round_tripped_d50 = xyz_from_lab(lab_from_xyz(xyz, reference_illuminant="D50"), reference_illuminant="D50")
+
+ assert torch.allclose(round_tripped_d65, xyz, atol=1e-4)
+ assert torch.allclose(round_tripped_d50, xyz, atol=1e-4)
+
+
+def test_xyz_d65_to_d50_maps_reference_white() -> None:
+ xyz_d65 = torch.tensor([[[0.950489]], [[1.0]], [[1.088840]]], dtype=torch.float32)
+
+ xyz_d50 = xyz_d65_to_d50(xyz_d65)
+
+ assert torch.allclose(xyz_d50[:, 0, 0], torch.tensor([0.964212, 1.0, 0.825188]), atol=5e-4)
+
+
+def test_xyz_d50_to_d65_round_trip() -> None:
+ xyz_d65 = torch.tensor(
+ [
+ [[0.4124, 0.9505]],
+ [[0.2126, 1.0]],
+ [[0.0193, 1.0888]],
+ ],
+ dtype=torch.float32,
+ )
+
+ round_tripped = xyz_d50_to_d65(xyz_d65_to_d50(xyz_d65))
+
+ assert torch.allclose(round_tripped, xyz_d65, atol=1e-5)
+
+
+def test_lab_from_srgb_d50_matches_adapted_xyz_path() -> None:
+ srgb = torch.tensor(
+ [
+ [[0.0, 1.0], [0.25, 0.8]],
+ [[0.2, 0.8], [0.75, 0.1]],
+ [[1.0, 0.1], [0.5, 0.4]],
+ ],
+ dtype=torch.float32,
+ )
+
+ direct = lab_from_srgb(srgb, reference_illuminant="D50")
+ via_xyz = lab_from_xyz(xyz_d65_to_d50(xyz_from_srgb(srgb)), reference_illuminant="D50")
+
+ assert torch.allclose(direct, via_xyz, atol=1e-4)
+
+
+def test_lab_from_xyz_matches_reference_white_and_black() -> None:
+ xyz = torch.tensor(
+ [
+ [[0.0, 0.950489]],
+ [[0.0, 1.0]],
+ [[0.0, 1.088840]],
+ ],
+ dtype=torch.float32,
+ )
+
+ lab = lab_from_xyz(xyz, reference_illuminant="D65")
+
+ assert torch.allclose(lab[:, 0, 0], torch.tensor([0.0, 0.0, 0.0]), atol=1e-4)
+ assert torch.allclose(lab[:, 0, 1], torch.tensor([100.0, 0.0, 0.0]), atol=1e-3)
+
+
+def test_invalid_tensor_shape_raises_value_error() -> None:
+ with pytest.raises(ValueError, match="3xHxW"):
+ oklab_from_srgb(torch.zeros((2, 2), dtype=torch.float32))
+
+
+def test_invalid_reference_illuminant_raises_value_error() -> None:
+ xyz = torch.ones((3, 1, 1), dtype=torch.float32)
+
+ with pytest.raises(ValueError, match="Unsupported reference_illuminant"):
+ lab_from_xyz(xyz, reference_illuminant="E")
+
+
+def test_okhsl_from_srgb_forwards_steps_parameters(monkeypatch: pytest.MonkeyPatch) -> None:
+ recorded: dict[str, int] = {}
+
+ def fake_get_cs_tensor(
+ l_tensor: torch.Tensor, units_ab_tensor: torch.Tensor, steps: int = 1, steps_outer: int = 1
+ ) -> torch.Tensor:
+ recorded["steps"] = steps
+ recorded["steps_outer"] = steps_outer
+ return torch.ones((3, *l_tensor.shape), dtype=l_tensor.dtype, device=l_tensor.device)
+
+ monkeypatch.setattr(color_conversion, "_get_cs_tensor", fake_get_cs_tensor)
+
+ srgb = torch.tensor(
+ [
+ [[0.2, 0.9]],
+ [[0.4, 0.3]],
+ [[0.8, 0.1]],
+ ],
+ dtype=torch.float32,
+ )
+
+ color_conversion.okhsl_from_srgb(srgb, steps=3, steps_outer=4)
+
+ assert recorded == {"steps": 3, "steps_outer": 4}
+
+
+def test_public_hsl_okhsl_okhsv_conversions_preserve_dtype_and_device() -> None:
+ srgb = torch.tensor(
+ [
+ [[0.05, 0.95], [0.2, 0.8]],
+ [[0.4, 0.2], [0.6, 0.1]],
+ [[0.9, 0.05], [0.3, 0.7]],
+ ],
+ dtype=torch.float64,
+ )
+
+ hsl = hsl_from_srgb(srgb)
+ okhsl = okhsl_from_srgb(srgb)
+ okhsv = okhsv_from_srgb(srgb)
+ srgb_from_plain_hsl = srgb_from_hsl(hsl)
+ srgb_from_perceptual_hsl = srgb_from_okhsl(okhsl)
+ srgb_from_perceptual_hsv = srgb_from_okhsv(okhsv)
+
+ for output in (hsl, okhsl, okhsv, srgb_from_plain_hsl, srgb_from_perceptual_hsl, srgb_from_perceptual_hsv):
+ assert output.dtype == srgb.dtype
+ assert output.device == srgb.device