revert and disable auto-formatting of invocations

This commit is contained in:
Lincoln Stein 2023-03-03 14:59:17 -05:00
parent dd4a1c998b
commit 6477e31c1e
6 changed files with 25 additions and 50 deletions

View File

@ -26,45 +26,18 @@ class TextToImageInvocation(BaseInvocation):
# Inputs # Inputs
# TODO: consider making prompt optional to enable providing prompt through a link # TODO: consider making prompt optional to enable providing prompt through a link
# fmt: off
prompt: Optional[str] = Field(description="The prompt to generate an image from") prompt: Optional[str] = Field(description="The prompt to generate an image from")
seed: int = Field( seed: int = Field(default=-1,ge=-1, le=np.iinfo(np.uint32).max, description="The seed to use (-1 for a random seed)", )
default=-1, steps: int = Field(default=10, gt=0, description="The number of steps to use to generate the image")
ge=-1, width: int = Field(default=512, multiple_of=64, gt=0, description="The width of the resulting image", )
le=np.iinfo(np.uint32).max, height: int = Field(default=512, multiple_of=64, gt=0, description="The height of the resulting image", )
description="The seed to use (-1 for a random seed)", cfg_scale: float = Field(default=7.5, gt=0, description="The Classifier-Free Guidance, higher values may result in a result closer to the prompt", )
) sampler_name: SAMPLER_NAME_VALUES = Field(default="k_lms", description="The sampler to use" )
steps: int = Field( seamless: bool = Field(default=False, description="Whether or not to generate an image that can tile without seams", )
default=10, gt=0, description="The number of steps to use to generate the image"
)
width: int = Field(
default=512,
multiple_of=64,
gt=0,
description="The width of the resulting image",
)
height: int = Field(
default=512,
multiple_of=64,
gt=0,
description="The height of the resulting image",
)
cfg_scale: float = Field(
default=7.5,
gt=0,
description="The Classifier-Free Guidance, higher values may result in a result closer to the prompt",
)
sampler_name: SAMPLER_NAME_VALUES = Field(
default="k_lms", description="The sampler to use"
)
seamless: bool = Field(
default=False,
description="Whether or not to generate an image that can tile without seams",
)
model: str = Field(default="", description="The model to use (currently ignored)") model: str = Field(default="", description="The model to use (currently ignored)")
progress_images: bool = Field( progress_images: bool = Field(default=False, description="Whether or not to produce progress images during generation", )
default=False, # fmt: on
description="Whether or not to produce progress images during generation",
)
# TODO: pass this an emitter method or something? or a session for dispatching? # TODO: pass this an emitter method or something? or a session for dispatching?
def dispatch_progress( def dispatch_progress(

View File

@ -260,13 +260,14 @@ class LerpInvocation(BaseInvocation):
class InverseLerpInvocation(BaseInvocation): class InverseLerpInvocation(BaseInvocation):
"""Inverse linear interpolation of all pixels of an image""" """Inverse linear interpolation of all pixels of an image"""
#fmt: off
type: Literal["ilerp"] = "ilerp" type: Literal["ilerp"] = "ilerp"
# 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 input value") min: int = Field(default=0, ge=0, le=255, description="The minimum input value")
max: int = Field(default=255, ge=0, le=255, description="The maximum input value") max: int = Field(default=255, ge=0, le=255, description="The maximum input 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(

View File

@ -7,7 +7,8 @@ from .baseinvocation import BaseInvocationOutput
class PromptOutput(BaseInvocationOutput): class PromptOutput(BaseInvocationOutput):
"""Base class for invocations that output a prompt""" """Base class for invocations that output a prompt"""
#fmt: off
type: Literal["prompt"] = "prompt" type: Literal["prompt"] = "prompt"
prompt: str = Field(default=None, description="The output prompt") prompt: str = Field(default=None, description="The output prompt")
#fmt: on

View File

@ -11,14 +11,13 @@ from .image import ImageField, ImageOutput
class RestoreFaceInvocation(BaseInvocation): class RestoreFaceInvocation(BaseInvocation):
"""Restores faces in an image.""" """Restores faces in an image."""
#fmt: off
type: Literal["restore_face"] = "restore_face" type: Literal["restore_face"] = "restore_face"
# Inputs # Inputs
image: Union[ImageField, None] = Field(description="The input image") image: Union[ImageField, None] = Field(description="The input image")
strength: float = Field( strength: float = Field(default=0.75, gt=0, le=1, description="The strength of the restoration" )
default=0.75, gt=0, le=1, description="The strength of the restoration" #fmt: on
)
def invoke(self, context: InvocationContext) -> ImageOutput: def invoke(self, context: InvocationContext) -> ImageOutput:
image = context.services.images.get( image = context.services.images.get(

View File

@ -13,13 +13,14 @@ from .image import ImageField, ImageOutput
class UpscaleInvocation(BaseInvocation): class UpscaleInvocation(BaseInvocation):
"""Upscales an image.""" """Upscales an image."""
#fmt: off
type: Literal["upscale"] = "upscale" type: Literal["upscale"] = "upscale"
# Inputs # Inputs
image: Union[ImageField, None] = Field(description="The input image", default=None) image: Union[ImageField, None] = Field(description="The input image", default=None)
strength: float = Field(default=0.75, gt=0, le=1, description="The strength") strength: float = Field(default=0.75, gt=0, le=1, description="The strength")
level: Literal[2, 4] = Field(default=2, description="The upscale level") level: Literal[2, 4] = Field(default=2, description="The upscale level")
#fmt: on
def invoke(self, context: InvocationContext) -> ImageOutput: def invoke(self, context: InvocationContext) -> ImageOutput:
image = context.services.images.get( image = context.services.images.get(

View File

@ -9,13 +9,13 @@ T = TypeVar("T", bound=BaseModel)
class PaginatedResults(GenericModel, Generic[T]): class PaginatedResults(GenericModel, Generic[T]):
"""Paginated results""" """Paginated results"""
#fmt: off
items: list[T] = Field(description="Items") items: list[T] = Field(description="Items")
page: int = Field(description="Current Page") page: int = Field(description="Current Page")
pages: int = Field(description="Total number of pages") pages: int = Field(description="Total number of pages")
per_page: int = Field(description="Number of items per page") per_page: int = Field(description="Number of items per page")
total: int = Field(description="Total number of items in result") total: int = Field(description="Total number of items in result")
#fmt: on
class ItemStorageABC(ABC, Generic[T]): class ItemStorageABC(ABC, Generic[T]):
_on_changed_callbacks: list[Callable[[T], None]] _on_changed_callbacks: list[Callable[[T], None]]