mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Merge branch 'main' into bugfix/fix-scripts
This commit is contained in:
commit
eab32bce6c
@ -72,5 +72,7 @@ class BaseInvocation(ABC, BaseModel):
|
|||||||
def invoke(self, context: InvocationContext) -> BaseInvocationOutput:
|
def invoke(self, context: InvocationContext) -> BaseInvocationOutput:
|
||||||
"""Invoke with provided context and return outputs."""
|
"""Invoke with provided context and return outputs."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
#fmt: off
|
||||||
id: str = Field(description="The id of this node. Must be unique among all nodes.")
|
id: str = Field(description="The id of this node. Must be unique among all nodes.")
|
||||||
|
#fmt: on
|
||||||
|
@ -14,14 +14,13 @@ from .image import ImageField, ImageOutput
|
|||||||
|
|
||||||
class CvInpaintInvocation(BaseInvocation):
|
class CvInpaintInvocation(BaseInvocation):
|
||||||
"""Simple inpaint using opencv."""
|
"""Simple inpaint using opencv."""
|
||||||
|
#fmt: off
|
||||||
type: Literal["cv_inpaint"] = "cv_inpaint"
|
type: Literal["cv_inpaint"] = "cv_inpaint"
|
||||||
|
|
||||||
# Inputs
|
# Inputs
|
||||||
image: ImageField = Field(default=None, description="The image to inpaint")
|
image: ImageField = Field(default=None, description="The image to inpaint")
|
||||||
mask: ImageField = Field(
|
mask: ImageField = Field(default=None, description="The mask to use when inpainting")
|
||||||
default=None, description="The mask to use when inpainting"
|
#fmt: on
|
||||||
)
|
|
||||||
|
|
||||||
def invoke(self, context: InvocationContext) -> ImageOutput:
|
def invoke(self, context: InvocationContext) -> ImageOutput:
|
||||||
image = context.services.images.get(
|
image = context.services.images.get(
|
||||||
|
@ -23,29 +23,28 @@ class ImageField(BaseModel):
|
|||||||
|
|
||||||
class ImageOutput(BaseInvocationOutput):
|
class ImageOutput(BaseInvocationOutput):
|
||||||
"""Base class for invocations that output an image"""
|
"""Base class for invocations that output an image"""
|
||||||
|
#fmt: off
|
||||||
type: Literal["image"] = "image"
|
type: Literal["image"] = "image"
|
||||||
|
image: ImageField = Field(default=None, description="The output image")
|
||||||
image: ImageField = Field(default=None, description="The output image")
|
#fmt: on
|
||||||
|
|
||||||
|
|
||||||
class MaskOutput(BaseInvocationOutput):
|
class MaskOutput(BaseInvocationOutput):
|
||||||
"""Base class for invocations that output a mask"""
|
"""Base class for invocations that output a mask"""
|
||||||
|
#fmt: off
|
||||||
type: Literal["mask"] = "mask"
|
type: Literal["mask"] = "mask"
|
||||||
|
mask: ImageField = Field(default=None, description="The output mask")
|
||||||
mask: ImageField = Field(default=None, description="The output mask")
|
#fomt: on
|
||||||
|
|
||||||
|
|
||||||
# TODO: this isn't really necessary anymore
|
# TODO: this isn't really necessary anymore
|
||||||
class LoadImageInvocation(BaseInvocation):
|
class LoadImageInvocation(BaseInvocation):
|
||||||
"""Load an image from a filename and provide it as output."""
|
"""Load an image from a filename and provide it as output."""
|
||||||
|
#fmt: off
|
||||||
type: Literal["load_image"] = "load_image"
|
type: Literal["load_image"] = "load_image"
|
||||||
|
|
||||||
# Inputs
|
# Inputs
|
||||||
image_type: ImageType = Field(description="The type of the image")
|
image_type: ImageType = Field(description="The type of the image")
|
||||||
image_name: str = Field(description="The name of the image")
|
image_name: str = Field(description="The name of the image")
|
||||||
|
#fmt: on
|
||||||
|
|
||||||
def invoke(self, context: InvocationContext) -> ImageOutput:
|
def invoke(self, context: InvocationContext) -> ImageOutput:
|
||||||
return ImageOutput(
|
return ImageOutput(
|
||||||
@ -79,17 +78,16 @@ class ShowImageInvocation(BaseInvocation):
|
|||||||
|
|
||||||
class CropImageInvocation(BaseInvocation):
|
class CropImageInvocation(BaseInvocation):
|
||||||
"""Crops an image to a specified box. The box can be outside of the image."""
|
"""Crops an image to a specified box. The box can be outside of the image."""
|
||||||
|
#fmt: off
|
||||||
type: Literal["crop"] = "crop"
|
type: Literal["crop"] = "crop"
|
||||||
|
|
||||||
# Inputs
|
# Inputs
|
||||||
image: ImageField = Field(default=None, description="The image to crop")
|
image: ImageField = Field(default=None, description="The image to crop")
|
||||||
x: int = Field(default=0, description="The left x coordinate of the crop rectangle")
|
x: int = Field(default=0, description="The left x coordinate of the crop rectangle")
|
||||||
y: int = Field(default=0, description="The top y coordinate of the crop rectangle")
|
y: int = Field(default=0, description="The top y coordinate of the crop rectangle")
|
||||||
width: int = Field(default=512, gt=0, description="The width of the crop rectangle")
|
width: int = Field(default=512, gt=0, description="The width of the crop rectangle")
|
||||||
height: int = Field(
|
height: int = Field(default=512, gt=0, description="The height of the crop rectangle")
|
||||||
default=512, gt=0, description="The height of the crop rectangle"
|
#fmt: on
|
||||||
)
|
|
||||||
|
|
||||||
def invoke(self, context: InvocationContext) -> ImageOutput:
|
def invoke(self, context: InvocationContext) -> ImageOutput:
|
||||||
image = context.services.images.get(
|
image = context.services.images.get(
|
||||||
@ -113,21 +111,16 @@ class CropImageInvocation(BaseInvocation):
|
|||||||
|
|
||||||
class PasteImageInvocation(BaseInvocation):
|
class PasteImageInvocation(BaseInvocation):
|
||||||
"""Pastes an image into another image."""
|
"""Pastes an image into another image."""
|
||||||
|
#fmt: off
|
||||||
type: Literal["paste"] = "paste"
|
type: Literal["paste"] = "paste"
|
||||||
|
|
||||||
# Inputs
|
# Inputs
|
||||||
base_image: ImageField = Field(default=None, description="The base image")
|
base_image: ImageField = Field(default=None, description="The base image")
|
||||||
image: ImageField = Field(default=None, description="The image to paste")
|
image: ImageField = Field(default=None, description="The image to paste")
|
||||||
mask: Optional[ImageField] = Field(
|
mask: Optional[ImageField] = Field(default=None, description="The mask to use when pasting")
|
||||||
default=None, description="The mask to use when pasting"
|
x: int = Field(default=0, description="The left x coordinate at which to paste the image")
|
||||||
)
|
y: int = Field(default=0, description="The top y coordinate at which to paste the image")
|
||||||
x: int = Field(
|
#fmt: on
|
||||||
default=0, description="The left x coordinate at which to paste the image"
|
|
||||||
)
|
|
||||||
y: int = Field(
|
|
||||||
default=0, description="The top y coordinate at which to paste the image"
|
|
||||||
)
|
|
||||||
|
|
||||||
def invoke(self, context: InvocationContext) -> ImageOutput:
|
def invoke(self, context: InvocationContext) -> ImageOutput:
|
||||||
base_image = context.services.images.get(
|
base_image = context.services.images.get(
|
||||||
@ -168,14 +161,13 @@ class PasteImageInvocation(BaseInvocation):
|
|||||||
|
|
||||||
class MaskFromAlphaInvocation(BaseInvocation):
|
class MaskFromAlphaInvocation(BaseInvocation):
|
||||||
"""Extracts the alpha channel of an image as a mask."""
|
"""Extracts the alpha channel of an image as a mask."""
|
||||||
|
#fmt: off
|
||||||
type: Literal["tomask"] = "tomask"
|
type: Literal["tomask"] = "tomask"
|
||||||
|
|
||||||
# Inputs
|
# Inputs
|
||||||
image: ImageField = Field(
|
image: ImageField = Field(default=None, description="The image to create the mask from")
|
||||||
default=None, description="The image to create the mask from"
|
invert: bool = Field(default=False, description="Whether or not to invert the mask")
|
||||||
)
|
#fmt: on
|
||||||
invert: bool = Field(default=False, description="Whether or not to invert the mask")
|
|
||||||
|
|
||||||
def invoke(self, context: InvocationContext) -> MaskOutput:
|
def invoke(self, context: InvocationContext) -> MaskOutput:
|
||||||
image = context.services.images.get(
|
image = context.services.images.get(
|
||||||
@ -197,15 +189,15 @@ class MaskFromAlphaInvocation(BaseInvocation):
|
|||||||
class BlurInvocation(BaseInvocation):
|
class BlurInvocation(BaseInvocation):
|
||||||
"""Blurs an image"""
|
"""Blurs an image"""
|
||||||
|
|
||||||
|
#fmt: off
|
||||||
type: Literal["blur"] = "blur"
|
type: Literal["blur"] = "blur"
|
||||||
|
|
||||||
# Inputs
|
# Inputs
|
||||||
image: ImageField = Field(default=None, description="The image to blur")
|
image: ImageField = Field(default=None, description="The image to blur")
|
||||||
radius: float = Field(default=8.0, ge=0, description="The blur radius")
|
radius: float = Field(default=8.0, ge=0, description="The blur radius")
|
||||||
blur_type: Literal["gaussian", "box"] = Field(
|
blur_type: Literal["gaussian", "box"] = Field(default="gaussian", description="The type of blur")
|
||||||
default="gaussian", description="The type of blur"
|
#fmt: on
|
||||||
)
|
|
||||||
|
|
||||||
def invoke(self, context: InvocationContext) -> ImageOutput:
|
def invoke(self, context: InvocationContext) -> ImageOutput:
|
||||||
image = context.services.images.get(
|
image = context.services.images.get(
|
||||||
self.image.image_type, self.image.image_name
|
self.image.image_type, self.image.image_name
|
||||||
@ -230,13 +222,14 @@ class BlurInvocation(BaseInvocation):
|
|||||||
|
|
||||||
class LerpInvocation(BaseInvocation):
|
class LerpInvocation(BaseInvocation):
|
||||||
"""Linear interpolation of all pixels of an image"""
|
"""Linear interpolation of all pixels of an image"""
|
||||||
|
#fmt: off
|
||||||
type: Literal["lerp"] = "lerp"
|
type: Literal["lerp"] = "lerp"
|
||||||
|
|
||||||
# Inputs
|
# Inputs
|
||||||
image: ImageField = Field(default=None, description="The image to lerp")
|
image: ImageField = Field(default=None, description="The image to lerp")
|
||||||
min: int = Field(default=0, ge=0, le=255, description="The minimum output value")
|
min: int = Field(default=0, ge=0, le=255, description="The minimum output value")
|
||||||
max: int = Field(default=255, ge=0, le=255, description="The maximum output value")
|
max: int = Field(default=255, ge=0, le=255, description="The maximum output value")
|
||||||
|
#fmt: on
|
||||||
|
|
||||||
def invoke(self, context: InvocationContext) -> ImageOutput:
|
def invoke(self, context: InvocationContext) -> ImageOutput:
|
||||||
image = context.services.images.get(
|
image = context.services.images.get(
|
||||||
|
Loading…
Reference in New Issue
Block a user