mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2024-12-29 19:05:05 +08:00
add img2img_upscaler_preserve_colors
option
This commit is contained in:
parent
ad4fac2f8e
commit
56d79f6dc2
@ -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:
|
||||
|
@ -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."),
|
||||
}))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user