mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-08-04 11:12:35 +00:00
Revert "Merge pull request #7931 from space-nuko/img2img-enhance"
This reverts commit4268759370
, reversing changes made to1b63afbedc
.
This commit is contained in:
@@ -15,7 +15,6 @@ import warnings
|
||||
import gradio as gr
|
||||
import gradio.routes
|
||||
import gradio.utils
|
||||
from gradio.events import Releaseable
|
||||
import numpy as np
|
||||
from PIL import Image, PngImagePlugin
|
||||
from modules.call_queue import wrap_gradio_gpu_call, wrap_queued_call, wrap_gradio_call
|
||||
@@ -128,26 +127,6 @@ def calc_resolution_hires(enable, width, height, hr_scale, hr_resize_x, hr_resiz
|
||||
return f"resize: from <span class='resolution'>{p.width}x{p.height}</span> to <span class='resolution'>{p.hr_resize_x or p.hr_upscale_to_x}x{p.hr_resize_y or p.hr_upscale_to_y}</span>"
|
||||
|
||||
|
||||
def calc_resolution_img2img(mode, scale, resize_x, resize_y, resize_mode, *i2i_images):
|
||||
init_img = None
|
||||
if mode in {0, 1, 3, 4}:
|
||||
init_img = i2i_images[mode]
|
||||
elif mode == 2:
|
||||
init_img = i2i_images[mode]["image"]
|
||||
|
||||
if not init_img:
|
||||
return ""
|
||||
|
||||
if scale > 1:
|
||||
width = int(init_img.width * scale)
|
||||
height = int(init_img.height * scale)
|
||||
else:
|
||||
width = resize_x
|
||||
height = resize_y
|
||||
|
||||
return f"resize: from <span class='resolution'>{init_img.width}x{init_img.height}</span> to <span class='resolution'>{width}x{height}</span>"
|
||||
|
||||
|
||||
def apply_styles(prompt, prompt_neg, styles):
|
||||
prompt = shared.prompt_styles.apply_styles_to_prompt(prompt, styles)
|
||||
prompt_neg = shared.prompt_styles.apply_negative_styles_to_prompt(prompt_neg, styles)
|
||||
@@ -756,7 +735,7 @@ def create_ui():
|
||||
)
|
||||
|
||||
with FormRow():
|
||||
resize_mode = gr.Radio(label="Resize mode", elem_id="resize_mode", choices=["Just resize", "Crop and resize", "Resize and fill"], type="index", value="Just resize")
|
||||
resize_mode = gr.Radio(label="Resize mode", elem_id="resize_mode", choices=["Just resize", "Crop and resize", "Resize and fill", "Just resize (latent upscale)"], type="index", value="Just resize")
|
||||
|
||||
for category in ordered_ui_categories():
|
||||
if category == "sampler":
|
||||
@@ -765,13 +744,8 @@ def create_ui():
|
||||
elif category == "dimensions":
|
||||
with FormRow():
|
||||
with gr.Column(elem_id="img2img_column_size", scale=4):
|
||||
with FormRow(variant="compact"):
|
||||
final_resolution = FormHTML(value="", elem_id="img2img_finalres", label="Upscaled resolution", interactive=False)
|
||||
with FormRow(variant="compact"):
|
||||
scale = gr.Slider(minimum=1.0, maximum=4.0, step=0.05, label="Upscale by", value=1.0, elem_id="img2img_scale")
|
||||
with FormRow(variant="compact"):
|
||||
width = gr.Slider(minimum=64, maximum=2048, step=8, label="Width", value=512, elem_id="img2img_width")
|
||||
height = gr.Slider(minimum=64, maximum=2048, step=8, label="Height", value=512, elem_id="img2img_height")
|
||||
width = gr.Slider(minimum=64, maximum=2048, step=8, label="Width", value=512, elem_id="img2img_width")
|
||||
height = gr.Slider(minimum=64, maximum=2048, step=8, label="Height", value=512, elem_id="img2img_height")
|
||||
|
||||
with gr.Column(elem_id="img2img_dimensions_row", scale=1, elem_classes="dimensions-tools"):
|
||||
res_switch_btn = ToolButton(value=switch_values_symbol, elem_id="img2img_res_switch_btn")
|
||||
@@ -786,9 +760,7 @@ def create_ui():
|
||||
with FormRow():
|
||||
cfg_scale = gr.Slider(minimum=1.0, maximum=30.0, step=0.5, label='CFG Scale', value=7.0, elem_id="img2img_cfg_scale")
|
||||
image_cfg_scale = gr.Slider(minimum=0, maximum=3.0, step=0.05, label='Image CFG Scale', value=1.5, elem_id="img2img_image_cfg_scale", visible=shared.sd_model and shared.sd_model.cond_stage_key == "edit")
|
||||
with FormRow():
|
||||
upscaler = gr.Dropdown(label="Upscaler", elem_id="img2img_upscaler", choices=[*shared.latent_upscale_modes, *[x.name for x in shared.sd_upscalers]], value=shared.latent_upscale_default_mode)
|
||||
denoising_strength = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, label='Denoising strength', value=0.75, elem_id="img2img_denoising_strength")
|
||||
denoising_strength = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, label='Denoising strength', value=0.75, elem_id="img2img_denoising_strength")
|
||||
|
||||
elif category == "seed":
|
||||
seed, reuse_seed, subseed, reuse_subseed, subseed_strength, seed_resize_from_h, seed_resize_from_w, seed_checkbox = create_seed_inputs('img2img')
|
||||
@@ -841,39 +813,6 @@ def create_ui():
|
||||
outputs=[inpaint_controls, mask_alpha],
|
||||
)
|
||||
|
||||
img2img_resolution_preview_inputs = [dummy_component, # filled in by selected img2img tab index in _js
|
||||
scale, width, height, resize_mode,
|
||||
init_img, sketch, init_img_with_mask, inpaint_color_sketch, init_img_inpaint]
|
||||
for input in img2img_resolution_preview_inputs[1:]:
|
||||
if isinstance(input, Releaseable):
|
||||
input.release(
|
||||
fn=calc_resolution_img2img,
|
||||
_js="get_img2img_tab_index_for_res_preview",
|
||||
inputs=img2img_resolution_preview_inputs,
|
||||
outputs=[final_resolution],
|
||||
show_progress=False,
|
||||
).success(
|
||||
None,
|
||||
_js="onCalcResolutionImg2Img",
|
||||
inputs=img2img_resolution_preview_inputs,
|
||||
outputs=[],
|
||||
show_progress=False,
|
||||
)
|
||||
else:
|
||||
input.change(
|
||||
fn=calc_resolution_img2img,
|
||||
_js="get_img2img_tab_index_for_res_preview",
|
||||
inputs=img2img_resolution_preview_inputs,
|
||||
outputs=[final_resolution],
|
||||
show_progress=False,
|
||||
).success(
|
||||
None,
|
||||
_js="onCalcResolutionImg2Img",
|
||||
inputs=img2img_resolution_preview_inputs,
|
||||
outputs=[],
|
||||
show_progress=False,
|
||||
)
|
||||
|
||||
img2img_gallery, generation_info, html_info, html_log = create_output_panel("img2img", opts.outdir_img2img_samples)
|
||||
|
||||
connect_reuse_seed(seed, reuse_seed, generation_info, dummy_component, is_subseed=False)
|
||||
@@ -922,8 +861,6 @@ def create_ui():
|
||||
subseed, subseed_strength, seed_resize_from_h, seed_resize_from_w, seed_checkbox,
|
||||
height,
|
||||
width,
|
||||
scale,
|
||||
upscaler,
|
||||
resize_mode,
|
||||
inpaint_full_res,
|
||||
inpaint_full_res_padding,
|
||||
@@ -1009,8 +946,6 @@ def create_ui():
|
||||
(seed, "Seed"),
|
||||
(width, "Size-1"),
|
||||
(height, "Size-2"),
|
||||
(scale, "Img2Img upscale"),
|
||||
(upscaler, "Img2Img upscaler"),
|
||||
(batch_size, "Batch size"),
|
||||
(subseed, "Variation seed"),
|
||||
(subseed_strength, "Variation seed strength"),
|
||||
|
Reference in New Issue
Block a user