Skip to content

Commit 140d58b

Browse files
committed
Merge pull request #14966 from light-and-ray/avoid_doble_upscaling_in_inpaint
[bug] avoid doble upscaling in inpaint
1 parent 532c340 commit 140d58b

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

modules/processing.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,18 @@ def uncrop(image, dest_size, paste_loc):
7474

7575
def apply_overlay(image, paste_loc, overlay):
7676
if overlay is None:
77-
return image
77+
return image, image.copy()
7878

7979
if paste_loc is not None:
8080
image = uncrop(image, (overlay.width, overlay.height), paste_loc)
8181

82+
original_denoised_image = image.copy()
83+
8284
image = image.convert('RGBA')
8385
image.alpha_composite(overlay)
8486
image = image.convert('RGB')
8587

86-
return image
88+
return image, original_denoised_image
8789

8890
def create_binary_mask(image, round=True):
8991
if image.mode == 'RGBA' and image.getextrema()[-1] != (255, 255):
@@ -1021,20 +1023,15 @@ def infotext(index=0, use_main_prompt=False):
10211023

10221024
if p.color_corrections is not None and i < len(p.color_corrections):
10231025
if save_samples and opts.save_images_before_color_correction:
1024-
image_without_cc = apply_overlay(image, p.paste_to, overlay_image)
1026+
image_without_cc, _ = apply_overlay(image, p.paste_to, overlay_image)
10251027
images.save_image(image_without_cc, p.outpath_samples, "", p.seeds[i], p.prompts[i], opts.samples_format, info=infotext(i), p=p, suffix="-before-color-correction")
10261028
image = apply_color_correction(p.color_corrections[i], image)
10271029

10281030
# If the intention is to show the output from the model
10291031
# that is being composited over the original image,
10301032
# we need to keep the original image around
10311033
# and use it in the composite step.
1032-
original_denoised_image = image.copy()
1033-
1034-
if p.paste_to is not None:
1035-
original_denoised_image = uncrop(original_denoised_image, (overlay_image.width, overlay_image.height), p.paste_to)
1036-
1037-
image = apply_overlay(image, p.paste_to, overlay_image)
1034+
image, original_denoised_image = apply_overlay(image, p.paste_to, overlay_image)
10381035

10391036
if p.scripts is not None:
10401037
pp = scripts.PostprocessImageArgs(image)

0 commit comments

Comments
 (0)