diff --git a/modules/processing.py b/modules/processing.py index f1bbf7706..80e6dece7 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -67,7 +67,7 @@ def uncrop(image, dest_size, paste_loc): base_image = Image.new('RGBA', dest_size) factor_x = w // image.size[0] factor_y = h // image.size[1] - image = images.resize_image(1, image, w, h, preserve_colors=True) + image = images.resize_image(1, image, w, h, preserve_colors=shared.opts.img2img_upscaler_preserve_colors) paste_x = max(x - factor_x, 0) paste_y = max(y - factor_y, 0) base_image.paste(image, (paste_x, paste_y)) @@ -1683,7 +1683,7 @@ class StableDiffusionProcessingImg2Img(StableDiffusionProcessing): image = images.flatten(img, opts.img2img_background_color) if crop_region is None and self.resize_mode != 3: - image = images.resize_image(self.resize_mode, image, self.width, self.height, preserve_colors=True) + image = images.resize_image(self.resize_mode, image, self.width, self.height, preserve_colors=shared.opts.img2img_upscaler_preserve_colors) if image_mask is not None: if self.mask_for_overlay.size != (image.width, image.height): @@ -1696,7 +1696,7 @@ class StableDiffusionProcessingImg2Img(StableDiffusionProcessing): # crop_region is not None if we are doing inpaint full res if crop_region is not None: image = image.crop(crop_region) - image = images.resize_image(2, image, self.width, self.height, preserve_colors=True) + image = images.resize_image(2, image, self.width, self.height, preserve_colors=shared.opts.img2img_upscaler_preserve_colors) if image_mask is not None: if self.inpainting_fill != 1: diff --git a/modules/shared_options.py b/modules/shared_options.py index 15331d4b5..256669aa5 100644 --- a/modules/shared_options.py +++ b/modules/shared_options.py @@ -103,6 +103,7 @@ options_templates.update(options_section(('upscaling', "Upscaling", "postprocess "DAT_tile": OptionInfo(192, "Tile size for DAT upscalers.", gr.Slider, {"minimum": 0, "maximum": 512, "step": 16}).info("0 = no tiling"), "DAT_tile_overlap": OptionInfo(8, "Tile overlap for DAT upscalers.", gr.Slider, {"minimum": 0, "maximum": 48, "step": 1}).info("Low values = visible seam"), "upscaler_for_img2img": OptionInfo(None, "Upscaler for img2img", gr.Dropdown, lambda: {"choices": [x.name for x in shared.sd_upscalers]}), + "img2img_upscaler_preserve_colors": OptionInfo(False, "Preserve colors in upscaler for img2img"), "set_scale_by_when_changing_upscaler": OptionInfo(False, "Automatically set the Scale by factor based on the name of the selected Upscaler."), }))