@@ -74,16 +74,18 @@ def uncrop(image, dest_size, paste_loc):
74
74
75
75
def apply_overlay (image , paste_loc , overlay ):
76
76
if overlay is None :
77
- return image
77
+ return image , image . copy ()
78
78
79
79
if paste_loc is not None :
80
80
image = uncrop (image , (overlay .width , overlay .height ), paste_loc )
81
81
82
+ original_denoised_image = image .copy ()
83
+
82
84
image = image .convert ('RGBA' )
83
85
image .alpha_composite (overlay )
84
86
image = image .convert ('RGB' )
85
87
86
- return image
88
+ return image , original_denoised_image
87
89
88
90
def create_binary_mask (image , round = True ):
89
91
if image .mode == 'RGBA' and image .getextrema ()[- 1 ] != (255 , 255 ):
@@ -1021,20 +1023,15 @@ def infotext(index=0, use_main_prompt=False):
1021
1023
1022
1024
if p .color_corrections is not None and i < len (p .color_corrections ):
1023
1025
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 )
1025
1027
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" )
1026
1028
image = apply_color_correction (p .color_corrections [i ], image )
1027
1029
1028
1030
# If the intention is to show the output from the model
1029
1031
# that is being composited over the original image,
1030
1032
# we need to keep the original image around
1031
1033
# 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 )
1038
1035
1039
1036
if p .scripts is not None :
1040
1037
pp = scripts .PostprocessImageArgs (image )
0 commit comments