ui: Make patchmatch downscale options optional

This commit is contained in:
blessedcoolant 2023-09-02 08:36:01 +12:00
parent a36cf2f1dd
commit 469fc49a2f
2 changed files with 19 additions and 4 deletions

View File

@ -14,7 +14,7 @@ from invokeai.backend.image_util.patchmatch import PatchMatch
from ..models.image import ImageCategory, ResourceOrigin from ..models.image import ImageCategory, ResourceOrigin
from .baseinvocation import BaseInvocation, InputField, InvocationContext, invocation from .baseinvocation import BaseInvocation, InputField, InvocationContext, invocation
from .image import PIL_RESAMPLING_MODES, PIL_RESAMPLING_MAP from .image import PIL_RESAMPLING_MAP, PIL_RESAMPLING_MODES
def infill_methods() -> list[str]: def infill_methods() -> list[str]:
@ -194,8 +194,10 @@ class InfillPatchMatchInvocation(BaseInvocation):
"""Infills transparent areas of an image using the PatchMatch algorithm""" """Infills transparent areas of an image using the PatchMatch algorithm"""
image: ImageField = InputField(description="The image to infill") image: ImageField = InputField(description="The image to infill")
downscale: float = InputField(default=2.0, gt=0, description="Run patchmatch on downscaled image to speedup infill") downscale: Optional[float] = InputField(
resample_mode: PIL_RESAMPLING_MODES = InputField(default="bicubic", description="The resampling mode") default=2.0, gt=0, description="Run patchmatch on downscaled image to speedup infill"
)
resample_mode: Optional[PIL_RESAMPLING_MODES] = InputField(default="bicubic", description="The resampling mode")
def invoke(self, context: InvocationContext) -> ImageOutput: def invoke(self, context: InvocationContext) -> ImageOutput:
image = context.services.images.get_pil_image(self.image.image_name).convert("RGBA") image = context.services.images.get_pil_image(self.image.image_name).convert("RGBA")
@ -221,7 +223,7 @@ class InfillPatchMatchInvocation(BaseInvocation):
) )
infilled.paste(image, (0, 0), mask=image.split()[-1]) infilled.paste(image, (0, 0), mask=image.split()[-1])
#image.paste(infilled, (0, 0), mask=image.split()[-1]) # image.paste(infilled, (0, 0), mask=image.split()[-1])
image_dto = context.services.images.create( image_dto = context.services.images.create(
image=infilled, image=infilled,

View File

@ -3519,6 +3519,19 @@ export type components = {
* @description The image to infill * @description The image to infill
*/ */
image?: components["schemas"]["ImageField"]; image?: components["schemas"]["ImageField"];
/**
* Downscale
* @description Run patchmatch on downscaled image to speedup infill
* @default 2
*/
downscale?: number;
/**
* Resample Mode
* @description The resampling mode
* @default bicubic
* @enum {string}
*/
resample_mode?: "nearest" | "box" | "bilinear" | "hamming" | "bicubic" | "lanczos";
/** /**
* Type * Type
* @default infill_patchmatch * @default infill_patchmatch