mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Add inpaint size options to inpaint at a larger size than the actual inpaint image, then scale back down for recombination
This commit is contained in:
parent
6eeb2107b3
commit
09e41e8f76
@ -299,6 +299,9 @@ class Generate:
|
|||||||
upscale = None,
|
upscale = None,
|
||||||
# this is specific to inpainting and causes more extreme inpainting
|
# this is specific to inpainting and causes more extreme inpainting
|
||||||
inpaint_replace = 0.0,
|
inpaint_replace = 0.0,
|
||||||
|
# This controls the size at which inpaint occurs (scaled up for inpaint, then back down for the result)
|
||||||
|
inpaint_width = None,
|
||||||
|
inpaint_height = None,
|
||||||
# This will help match inpainted areas to the original image more smoothly
|
# This will help match inpainted areas to the original image more smoothly
|
||||||
mask_blur_radius: int = 8,
|
mask_blur_radius: int = 8,
|
||||||
# Set this True to handle KeyboardInterrupt internally
|
# Set this True to handle KeyboardInterrupt internally
|
||||||
@ -490,7 +493,9 @@ class Generate:
|
|||||||
seam_strength = seam_strength,
|
seam_strength = seam_strength,
|
||||||
seam_steps = seam_steps,
|
seam_steps = seam_steps,
|
||||||
tile_size = tile_size,
|
tile_size = tile_size,
|
||||||
force_outpaint = force_outpaint
|
force_outpaint = force_outpaint,
|
||||||
|
inpaint_width = inpaint_width,
|
||||||
|
inpaint_height = inpaint_height
|
||||||
)
|
)
|
||||||
|
|
||||||
if init_color:
|
if init_color:
|
||||||
|
@ -150,7 +150,10 @@ class Inpaint(Img2Img):
|
|||||||
seam_steps: int = 10,
|
seam_steps: int = 10,
|
||||||
tile_size: int = 32,
|
tile_size: int = 32,
|
||||||
step_callback=None,
|
step_callback=None,
|
||||||
inpaint_replace=False, **kwargs):
|
inpaint_replace=False,
|
||||||
|
inpaint_width=None,
|
||||||
|
inpaint_height=None,
|
||||||
|
**kwargs):
|
||||||
"""
|
"""
|
||||||
Returns a function returning an image derived from the prompt and
|
Returns a function returning an image derived from the prompt and
|
||||||
the initial image + mask. Return value depends on the seed at
|
the initial image + mask. Return value depends on the seed at
|
||||||
@ -168,11 +171,20 @@ class Inpaint(Img2Img):
|
|||||||
)
|
)
|
||||||
init_filled.paste(init_image, (0,0), init_image.split()[-1])
|
init_filled.paste(init_image, (0,0), init_image.split()[-1])
|
||||||
|
|
||||||
|
# Resize if requested for inpainting
|
||||||
|
if inpaint_width and inpaint_height:
|
||||||
|
init_filled = init_filled.resize((inpaint_width, inpaint_height))
|
||||||
|
|
||||||
# Create init tensor
|
# Create init tensor
|
||||||
init_image = self._image_to_tensor(init_filled.convert('RGB'))
|
init_image = self._image_to_tensor(init_filled.convert('RGB'))
|
||||||
|
|
||||||
if isinstance(mask_image, PIL.Image.Image):
|
if isinstance(mask_image, PIL.Image.Image):
|
||||||
self.pil_mask = mask_image
|
self.pil_mask = mask_image
|
||||||
|
|
||||||
|
# Resize if requested for inpainting
|
||||||
|
if inpaint_width and inpaint_height:
|
||||||
|
mask_image = mask_image.resize((inpaint_width, inpaint_height))
|
||||||
|
|
||||||
mask_image = mask_image.resize(
|
mask_image = mask_image.resize(
|
||||||
(
|
(
|
||||||
mask_image.width // downsampling,
|
mask_image.width // downsampling,
|
||||||
@ -241,6 +253,10 @@ class Inpaint(Img2Img):
|
|||||||
|
|
||||||
result = self.sample_to_image(samples)
|
result = self.sample_to_image(samples)
|
||||||
|
|
||||||
|
# Resize if necessary
|
||||||
|
if inpaint_width and inpaint_height:
|
||||||
|
result = result.resize(self.pil_image.size)
|
||||||
|
|
||||||
# Seam paint if this is our first pass (seam_size set to 0 during seam painting)
|
# Seam paint if this is our first pass (seam_size set to 0 during seam painting)
|
||||||
if seam_size > 0:
|
if seam_size > 0:
|
||||||
result = self.seam_paint(
|
result = self.seam_paint(
|
||||||
|
Loading…
Reference in New Issue
Block a user