From f91fd276242a0c92b301e99d02982d30f7b712c3 Mon Sep 17 00:00:00 2001 From: Kyle Schouviller Date: Sat, 5 Nov 2022 14:47:53 -0700 Subject: [PATCH] Bug fix for inpaint size --- ldm/invoke/generator/inpaint.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ldm/invoke/generator/inpaint.py b/ldm/invoke/generator/inpaint.py index f3dd060cfb..d8a471350f 100644 --- a/ldm/invoke/generator/inpaint.py +++ b/ldm/invoke/generator/inpaint.py @@ -160,6 +160,9 @@ class Inpaint(Img2Img): the time you call it. kwargs are 'init_latent' and 'strength' """ + self.inpaint_width = inpaint_width + self.inpaint_height = inpaint_height + if isinstance(init_image, PIL.Image.Image): self.pil_image = init_image @@ -253,10 +256,6 @@ class Inpaint(Img2Img): 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) if seam_size > 0: result = self.seam_paint( @@ -323,6 +322,10 @@ class Inpaint(Img2Img): def sample_to_image(self, samples)->Image.Image: gen_result = super().sample_to_image(samples).convert('RGB') + # Resize if necessary + if self.inpaint_width and self.inpaint_height: + gen_result = gen_result.resize(self.pil_image.size) + if self.pil_image is None or self.pil_mask is None: return gen_result