tweaks to latent corrections

This commit is contained in:
Vladimir Mandic
2024-02-02 18:24:44 -05:00
parent 5c9ca793e9
commit 94332fe2c6
13 changed files with 68 additions and 78 deletions
+3 -10
View File
@@ -35,7 +35,7 @@ def control_run(units: List[unit.Unit], inputs, inits, mask, unit_type: str, is_
prompt, negative, styles, steps, sampler_index,
seed, subseed, subseed_strength, seed_resize_from_h, seed_resize_from_w,
cfg_scale, clip_skip, image_cfg_scale, diffusers_guidance_rescale, sag_scale, full_quality, restore_faces, tiling,
hdr_clamp, hdr_boundary, hdr_threshold, hdr_brightness, hdr_center, hdr_color_correction, hdr_maximize, hdr_max_center, hdr_max_boundry,
hdr_mode, hdr_brightness, hdr_color, hdr_sharpen, hdr_clamp, hdr_boundary, hdr_threshold, hdr_maximize, hdr_max_center, hdr_max_boundry,
resize_mode_before, resize_name_before, width_before, height_before, scale_by_before, selected_scale_tab_before,
resize_mode_after, resize_name_after, width_after, height_after, scale_by_after, selected_scale_tab_after,
denoising_strength, batch_count, batch_size,
@@ -77,15 +77,6 @@ def control_run(units: List[unit.Unit], inputs, inits, mask, unit_type: str, is_
full_quality = full_quality,
restore_faces = restore_faces,
tiling = tiling,
hdr_clamp = hdr_clamp,
hdr_boundary = hdr_boundary,
hdr_threshold = hdr_threshold,
hdr_center = hdr_center,
hdr_color_correction = hdr_color_correction,
hdr_brightness = hdr_brightness,
hdr_maximize = hdr_maximize,
hdr_max_center = hdr_max_center,
hdr_max_boundry = hdr_max_boundry,
resize_mode = resize_mode_before if resize_name_before != 'None' else 0,
resize_name = resize_name_before,
scale_by = scale_by_before,
@@ -96,6 +87,8 @@ def control_run(units: List[unit.Unit], inputs, inits, mask, unit_type: str, is_
inpaint_full_res = masking.opts.mask_only,
inpaint_full_res_padding = masking.opts.mask_padding,
inpainting_fill = 1,
hdr_mode=hdr_mode, hdr_brightness=hdr_brightness, hdr_color=hdr_color, hdr_sharpen=hdr_sharpen, hdr_clamp=hdr_clamp,
hdr_boundary=hdr_boundary, hdr_threshold=hdr_threshold, hdr_maximize=hdr_maximize, hdr_max_center=hdr_max_center, hdr_max_boundry=hdr_max_boundry,
outpath_samples=shared.opts.outdir_samples or shared.opts.outdir_control_samples,
outpath_grids=shared.opts.outdir_grids or shared.opts.outdir_control_grids,
)
+3 -5
View File
@@ -135,7 +135,7 @@ def img2img(id_task: str, mode: int,
resize_mode, resize_name,
inpaint_full_res, inpaint_full_res_padding, inpainting_mask_invert,
img2img_batch_files, img2img_batch_input_dir, img2img_batch_output_dir, img2img_batch_inpaint_mask_dir,
hdr_clamp, hdr_boundary, hdr_threshold, hdr_brightness, hdr_center, hdr_color_correction, hdr_sharpen, hdr_sharpen_ratio, hdr_sharpen_start, hdr_maximize, hdr_max_center, hdr_max_boundry,
hdr_mode, hdr_brightness, hdr_color, hdr_sharpen, hdr_clamp, hdr_boundary, hdr_threshold, hdr_maximize, hdr_max_center, hdr_max_boundry,
override_settings_texts,
*args): # pylint: disable=unused-argument
@@ -239,10 +239,8 @@ def img2img(id_task: str, mode: int,
inpaint_full_res=inpaint_full_res != 0,
inpaint_full_res_padding=inpaint_full_res_padding,
inpainting_mask_invert=inpainting_mask_invert,
hdr_clamp=hdr_clamp, hdr_boundary=hdr_boundary, hdr_threshold=hdr_threshold,
hdr_center=hdr_center, hdr_color_correction=hdr_color_correction, hdr_brightness=hdr_brightness,
hdr_sharpen=hdr_sharpen, hdr_sharpen_ratio=hdr_sharpen_ratio, hdr_sharpen_start=hdr_sharpen_start,
hdr_maximize=hdr_maximize, hdr_max_center=hdr_max_center, hdr_max_boundry=hdr_max_boundry,
hdr_mode=hdr_mode, hdr_brightness=hdr_brightness, hdr_color=hdr_color, hdr_sharpen=hdr_sharpen, hdr_clamp=hdr_clamp,
hdr_boundary=hdr_boundary, hdr_threshold=hdr_threshold, hdr_maximize=hdr_maximize, hdr_max_center=hdr_max_center, hdr_max_boundry=hdr_max_boundry,
override_settings=override_settings,
)
if selected_scale_tab == 1 and resize_mode != 0:
+12 -13
View File
@@ -16,7 +16,7 @@ class StableDiffusionProcessing:
"""
The first set of paramaters: sd_models -> do_not_reload_embeddings represent the minimum required to create a StableDiffusionProcessing
"""
def __init__(self, sd_model=None, outpath_samples=None, outpath_grids=None, prompt: str = "", styles: List[str] = None, seed: int = -1, subseed: int = -1, subseed_strength: float = 0, seed_resize_from_h: int = -1, seed_resize_from_w: int = -1, seed_enable_extras: bool = True, sampler_name: str = None, hr_sampler_name: str = None, batch_size: int = 1, n_iter: int = 1, steps: int = 50, cfg_scale: float = 7.0, image_cfg_scale: float = None, clip_skip: int = 1, width: int = 512, height: int = 512, full_quality: bool = True, restore_faces: bool = False, tiling: bool = False, do_not_save_samples: bool = False, do_not_save_grid: bool = False, extra_generation_params: Dict[Any, Any] = None, overlay_images: Any = None, negative_prompt: str = None, eta: float = None, do_not_reload_embeddings: bool = False, denoising_strength: float = 0, diffusers_guidance_rescale: float = 0.7, sag_scale: float = 0.0, cfg_end: float = 1, resize_mode: int = 0, resize_name: str = 'None', scale_by: float = 0, selected_scale_tab: int = 0, hdr_clamp: bool = False, hdr_boundary: float = 4.0, hdr_threshold: float = 3.5, hdr_center: bool = False, hdr_color_correction: float = 0.8, hdr_brightness: float = 0.8, hdr_sharpen: bool = False, hdr_sharpen_ratio: float = 0.0, hdr_sharpen_start: int = 500, hdr_maximize: bool = False, hdr_max_center: float = 0.6, hdr_max_boundry: float = 1.0, override_settings: Dict[str, Any] = None, override_settings_restore_afterwards: bool = True, sampler_index: int = None, script_args: list = None): # pylint: disable=unused-argument
def __init__(self, sd_model=None, outpath_samples=None, outpath_grids=None, prompt: str = "", styles: List[str] = None, seed: int = -1, subseed: int = -1, subseed_strength: float = 0, seed_resize_from_h: int = -1, seed_resize_from_w: int = -1, seed_enable_extras: bool = True, sampler_name: str = None, hr_sampler_name: str = None, batch_size: int = 1, n_iter: int = 1, steps: int = 50, cfg_scale: float = 7.0, image_cfg_scale: float = None, clip_skip: int = 1, width: int = 512, height: int = 512, full_quality: bool = True, restore_faces: bool = False, tiling: bool = False, do_not_save_samples: bool = False, do_not_save_grid: bool = False, extra_generation_params: Dict[Any, Any] = None, overlay_images: Any = None, negative_prompt: str = None, eta: float = None, do_not_reload_embeddings: bool = False, denoising_strength: float = 0, diffusers_guidance_rescale: float = 0.7, sag_scale: float = 0.0, cfg_end: float = 1, resize_mode: int = 0, resize_name: str = 'None', scale_by: float = 0, selected_scale_tab: int = 0, hdr_mode: int = 0, hdr_brightness: float = 0, hdr_color: float = 0, hdr_sharpen: float = 0, hdr_clamp: bool = False, hdr_boundary: float = 4.0, hdr_threshold: float = 0.95, hdr_maximize: bool = False, hdr_max_center: float = 0.6, hdr_max_boundry: float = 1.0, override_settings: Dict[str, Any] = None, override_settings_restore_afterwards: bool = True, sampler_index: int = None, script_args: list = None): # pylint: disable=unused-argument
self.outpath_samples: str = outpath_samples
self.outpath_grids: str = outpath_grids
self.prompt: str = prompt
@@ -115,18 +115,17 @@ class StableDiffusionProcessing:
self.script_args_value: list = field(default=None, init=False)
self.scripts_setup_complete: bool = field(default=False, init=False)
# hdr
self.hdr_clamp = hdr_clamp
self.hdr_boundary = hdr_boundary
self.hdr_threshold = hdr_threshold
self.hdr_center = hdr_center
self.hdr_color_correction = hdr_color_correction
self.hdr_brightness = hdr_brightness
self.hdr_sharpen = hdr_sharpen
self.hdr_sharpen_ratio = hdr_sharpen_ratio
self.hdr_sharpen_start = hdr_sharpen_start
self.hdr_maximize = hdr_maximize
self.hdr_max_center = hdr_max_center
self.hdr_max_boundry = hdr_max_boundry
self.hdr_mode=hdr_mode
self.hdr_brightness=hdr_brightness
self.hdr_color=hdr_color
self.hdr_sharpen=hdr_sharpen
self.hdr_clamp=hdr_clamp
self.hdr_boundary=hdr_boundary
self.hdr_threshold=hdr_threshold
self.hdr_maximize=hdr_maximize
self.hdr_max_center=hdr_max_center
self.hdr_max_boundry=hdr_max_boundry
# globals
self.scheduled_prompt: bool = False
self.prompt_embeds = []
self.positive_pooleds = []
+18 -16
View File
@@ -14,7 +14,7 @@ debug('Trace: HDR')
def sharpen_tensor(tensor, ratio=0):
if ratio == 0:
print("early exit...")
debug("Sharpen: Early exit")
return tensor
kernel = torch.ones((3, 3), dtype=tensor.dtype, device=tensor.device)
kernel[1, 1] = 5.0
@@ -71,20 +71,22 @@ def correction(p, timestep, latent):
if timestep > 950 and p.hdr_clamp:
p.extra_generation_params["HDR clamp"] = f'{p.hdr_threshold}/{p.hdr_boundary}'
latent = soft_clamp_tensor(latent, threshold=p.hdr_threshold, boundary=p.hdr_boundary)
if 500 < timestep < 800 and (p.hdr_center or p.hdr_brightness):
p.extra_generation_params["HDR center"] = f'{p.hdr_color_correction}/{p.hdr_brightness}'
latent[0:1] = center_tensor(latent[0:1], full_shift=float(p.hdr_center), offset=p.hdr_brightness) # Brightness
p.hdr_center = 0
p.hdr_brightness = 0
if 500 < timestep < 800 and p.hdr_color_correction != 0:
latent[1:] = center_tensor(latent[1:], channel_shift=p.hdr_color_correction, full_shift=0.0) # Color
p.hdr_color_correction = 0
if timestep < p.hdr_sharpen_start and p.hdr_sharpen:
print(f"Sharpening... {p.hdr_sharpen_ratio}/{p.hdr_sharpen_start}")
p.extra_generation_params["HDR sharpen"] = f'{p.hdr_sharpen_ratio}/{p.hdr_sharpen_start}'
latent = sharpen_tensor(latent, ratio=p.hdr_sharpen_ratio)
# p.hdr_sharpen = False
p.hdr_sharpen_ratio *= 0.5 * 2**0.5
if 500 < timestep < 800 and (p.hdr_brightness != 0 or p.hdr_color != 0):
p.extra_generation_params["HDR center"] = f'{p.hdr_color}/{p.hdr_brightness}'
if p.hdr_brightness != 0:
latent[0:1] = center_tensor(latent[0:1], full_shift=float(p.hdr_mode), offset=2*p.hdr_brightness) # Brightness
p.extra_generation_params["HDR brightness"] = f'{p.hdr_brightness}'
p.hdr_brightness = 0
if p.hdr_color != 0:
latent[1:] = center_tensor(latent[1:], channel_shift=p.hdr_color, full_shift=float(p.hdr_mode)) # Color
p.extra_generation_params["HDR color"] = f'{p.hdr_color}'
p.hdr_color = 0
if timestep < 350 and p.hdr_sharpen != 0:
p.extra_generation_params["HDR sharpen"] = f'{p.hdr_sharpen}'
per_step_ratio = 2 ** (timestep / 250) * p.hdr_sharpen / 16
if abs(per_step_ratio) > 0.01:
debug(f"HDR Sharpen: timestep={timestep} ratio={p.hdr_sharpen} val={per_step_ratio}")
latent = sharpen_tensor(latent, ratio=per_step_ratio)
if 1 < timestep < 100 and p.hdr_maximize:
p.extra_generation_params["HDR max"] = f'{p.hdr_max_center}/{p.hdr_max_boundry}'
latent = center_tensor(latent, channel_shift=p.hdr_max_center, full_shift=1.0)
@@ -93,7 +95,7 @@ def correction(p, timestep, latent):
def correction_callback(p, timestep, kwargs):
if not any([p.hdr_clamp, p.hdr_center, p.hdr_maximize, p.hdr_sharpen, p.hdr_color_correction, p.hdr_brightness]):
if not any([p.hdr_clamp, p.hdr_mode, p.hdr_maximize, p.hdr_sharpen, p.hdr_color, p.hdr_brightness]):
return kwargs
latents = kwargs["latents"]
debug('')
+6 -4
View File
@@ -77,7 +77,7 @@ def process_diffusers(p: processing.StableDiffusionProcessing):
except Exception as e:
shared.log.debug(f"Callback: {e}")
if step == int(pipe.num_timesteps * p.cfg_end) and 'prompt_embeds' in kwargs and 'negative_prompt_embeds' in kwargs:
pipe._guidance_scale = 0.0
pipe._guidance_scale = 0.0 # pylint: disable=protected-access
for key in {"prompt_embeds", "negative_prompt_embeds", "add_text_embeds", "add_time_ids"} & set(kwargs):
kwargs[key] = kwargs[key].chunk(2)[-1]
shared.state.current_latent = kwargs['latents']
@@ -211,7 +211,7 @@ def process_diffusers(p: processing.StableDiffusionProcessing):
elif 'callback_on_step_end_tensor_inputs' in possible:
args['callback_on_step_end'] = diffusers_callback
if 'prompt_embeds' in possible and 'negative_prompt_embeds' in possible:
args['callback_on_step_end_tensor_inputs'] = model._callback_tensor_inputs
args['callback_on_step_end_tensor_inputs'] = model._callback_tensor_inputs # pylint: disable=protected-access
else:
args['callback_on_step_end_tensor_inputs'] = ['latents']
for arg in kwargs:
@@ -265,10 +265,12 @@ def process_diffusers(p: processing.StableDiffusionProcessing):
clean['generator'] = generator_device
clean['parser'] = parser
shared.log.debug(f'Diffuser pipeline: {model.__class__.__name__} task={sd_models.get_diffusers_task(model)} set={clean}')
if p.hdr_clamp or p.hdr_center or p.hdr_maximize:
if p.hdr_clamp or p.hdr_maximize or p.hdr_brightness != 0 or p.hdr_color != 0 or p.hdr_sharpen != 0:
txt = 'HDR:'
txt += f' Brightness={p.hdr_brightness}' if p.hdr_brightness != 0 else ' Brightness off'
txt += f' Color={p.hdr_color}' if p.hdr_color != 0 else ' Color off'
txt += f' Sharpen={p.hdr_sharpen}' if p.hdr_sharpen != 0 else ' Sharpen off'
txt += f' Clamp threshold={p.hdr_threshold} boundary={p.hdr_boundary}' if p.hdr_clamp else ' Clamp off'
txt += f' Center channel-shift={p.hdr_color_correction} full-shift={p.hdr_brightness}' if p.hdr_center else ' Center off'
txt += f' Maximize boundary={p.hdr_max_boundry} center={p.hdr_max_center}' if p.hdr_maximize else ' Maximize off'
shared.log.debug(txt)
# components = [{ k: getattr(v, 'device', None) } for k, v in model.components.items()]
+3 -5
View File
@@ -20,7 +20,7 @@ def txt2img(id_task,
enable_hr, denoising_strength,
hr_scale, hr_upscaler, hr_force, hr_second_pass_steps, hr_resize_x, hr_resize_y,
refiner_steps, refiner_start, refiner_prompt, refiner_negative,
hdr_clamp, hdr_boundary, hdr_threshold, hdr_brightness, hdr_center, hdr_color_correction, hdr_sharpen, hdr_sharpen_ratio, hdr_sharpen_start, hdr_maximize, hdr_max_center, hdr_max_boundry,
hdr_mode, hdr_brightness, hdr_color, hdr_sharpen, hdr_clamp, hdr_boundary, hdr_threshold, hdr_maximize, hdr_max_center, hdr_max_boundry,
override_settings_texts,
*args):
@@ -77,10 +77,8 @@ def txt2img(id_task,
refiner_start=refiner_start,
refiner_prompt=refiner_prompt,
refiner_negative=refiner_negative,
hdr_clamp=hdr_clamp, hdr_boundary=hdr_boundary, hdr_threshold=hdr_threshold,
hdr_center=hdr_center, hdr_color_correction=hdr_color_correction, hdr_brightness=hdr_brightness,
hdr_sharpen=hdr_sharpen, hdr_sharpen_ratio=hdr_sharpen_ratio, hdr_sharpen_start=hdr_sharpen_start,
hdr_maximize=hdr_maximize, hdr_max_center=hdr_max_center, hdr_max_boundry=hdr_max_boundry,
hdr_mode=hdr_mode, hdr_brightness=hdr_brightness, hdr_color=hdr_color, hdr_sharpen=hdr_sharpen, hdr_clamp=hdr_clamp,
hdr_boundary=hdr_boundary, hdr_threshold=hdr_threshold, hdr_maximize=hdr_maximize, hdr_max_center=hdr_max_center, hdr_max_boundry=hdr_max_boundry,
override_settings=override_settings,
)
p.scripts = scripts.scripts_txt2img
+3 -2
View File
@@ -104,7 +104,7 @@ def create_ui(_blocks: gr.Blocks=None):
mask_controls = masking.create_segment_ui()
cfg_scale, clip_skip, image_cfg_scale, diffusers_guidance_rescale, sag_scale, cfg_end, full_quality, restore_faces, tiling= ui_sections.create_advanced_inputs('control')
hdr_clamp, hdr_boundary, hdr_threshold, hdr_brightness, hdr_center, hdr_color_correction, hdr_sharpen, hdr_sharpen_ratio, hdr_sharpen_start, hdr_maximize, hdr_max_center, hdr_max_boundry = ui_sections.create_callback_inputs('control')
hdr_mode, hdr_brightness, hdr_color, hdr_sharpen, hdr_clamp, hdr_boundary, hdr_threshold, hdr_maximize, hdr_max_center, hdr_max_boundry = ui_sections.create_correction_inputs('control')
with gr.Accordion(open=False, label="Video", elem_id="control_video", elem_classes=["small-accordion"]):
with gr.Row():
@@ -488,7 +488,8 @@ def create_ui(_blocks: gr.Blocks=None):
prompt, negative, styles,
steps, sampler_index,
seed, subseed, subseed_strength, seed_resize_from_h, seed_resize_from_w,
cfg_scale, clip_skip, image_cfg_scale, diffusers_guidance_rescale, sag_scale, cfg_end, full_quality, restore_faces, tiling, hdr_clamp, hdr_boundary, hdr_threshold, hdr_brightness, hdr_center, hdr_color_correction, hdr_sharpen, hdr_sharpen_ratio, hdr_sharpen_start, hdr_maximize, hdr_max_center, hdr_max_boundry,
cfg_scale, clip_skip, image_cfg_scale, diffusers_guidance_rescale, sag_scale, cfg_end, full_quality, restore_faces, tiling,
hdr_mode, hdr_brightness, hdr_color, hdr_sharpen, hdr_clamp, hdr_boundary, hdr_threshold, hdr_maximize, hdr_max_center, hdr_max_boundry,
resize_mode_before, resize_name_before, width_before, height_before, scale_by_before, selected_scale_tab_before,
resize_mode_after, resize_name_after, width_after, height_after, scale_by_after, selected_scale_tab_after,
denoising_strength, batch_count, batch_size,
+2 -2
View File
@@ -131,7 +131,7 @@ def create_ui():
refiner_start = gr.Slider(minimum=0.0, maximum=1.0, step=0.05, label='Denoise start', value=0.0, elem_id="img2img_refiner_start")
cfg_scale, clip_skip, image_cfg_scale, diffusers_guidance_rescale, sag_scale, cfg_end, full_quality, restore_faces, tiling = ui_sections.create_advanced_inputs('img2img')
hdr_clamp, hdr_boundary, hdr_threshold, hdr_brightness, hdr_center, hdr_color_correction, hdr_sharpen, hdr_sharpen_ratio, hdr_sharpen_start, hdr_maximize, hdr_max_center, hdr_max_boundry = ui_sections.create_callback_inputs('img2img')
hdr_mode, hdr_brightness, hdr_color, hdr_sharpen, hdr_clamp, hdr_boundary, hdr_threshold, hdr_maximize, hdr_max_center, hdr_max_boundry = ui_sections.create_correction_inputs('img2img')
# with gr.Group(elem_id="inpaint_controls", visible=False) as inpaint_controls:
with gr.Accordion(open=True, label="Mask", elem_classes=["small-accordion"], elem_id="img2img_mask_group") as inpaint_controls:
@@ -191,7 +191,7 @@ def create_ui():
resize_mode, resize_name,
inpaint_full_res, inpaint_full_res_padding, inpainting_mask_invert,
img2img_batch_files, img2img_batch_input_dir, img2img_batch_output_dir, img2img_batch_inpaint_mask_dir,
hdr_clamp, hdr_boundary, hdr_threshold, hdr_brightness, hdr_center, hdr_color_correction, hdr_sharpen, hdr_sharpen_ratio, hdr_sharpen_start, hdr_maximize, hdr_max_center, hdr_max_boundry,
hdr_mode, hdr_brightness, hdr_color, hdr_sharpen, hdr_clamp, hdr_boundary, hdr_threshold, hdr_maximize, hdr_max_center, hdr_max_boundry,
override_settings,
]
img2img_dict = dict(
+10 -12
View File
@@ -119,27 +119,25 @@ def create_advanced_inputs(tab):
return cfg_scale, clip_skip, image_cfg_scale, diffusers_guidance_rescale, diffusers_sag_scale, cfg_end, full_quality, restore_faces, tiling
def create_callback_inputs(tab):
with gr.Accordion(open=False, label="Callback", elem_id=f"{tab}_callback", elem_classes=["small-accordion"], visible=shared.backend == shared.Backend.DIFFUSERS):
def create_correction_inputs(tab):
with gr.Accordion(open=False, label="Corrections", elem_id=f"{tab}_corrections", elem_classes=["small-accordion"], visible=shared.backend == shared.Backend.DIFFUSERS):
with gr.Group(visible=shared.backend == shared.Backend.DIFFUSERS):
with gr.Row():
hdr_mode = gr.Dropdown(label="Mode", choices=["Relative values", "Absolute values"], type="index", value="Relative values", elem_id=f"{tab}_hdr_mode", show_label=False)
gr.HTML('<br>')
with gr.Row():
hdr_brightness = gr.Slider(minimum=-1.0, maximum=1.0, step=0.1, value=0, label='Brightness', elem_id=f"{tab}_hdr_brightness")
hdr_sharpen = gr.Slider(minimum=-1.0, maximum=1.0, step=0.1, value=0, label='Sharpen', elem_id=f"{tab}_hdr_sharpen")
hdr_color = gr.Slider(minimum=0.0, maximum=4.0, step=0.1, value=0.0, label='Color', elem_id=f"{tab}_hdr_color")
with gr.Row():
hdr_clamp = gr.Checkbox(label='HDR clamp', value=False, elem_id=f"{tab}_hdr_clamp")
hdr_boundary = gr.Slider(minimum=0.0, maximum=10.0, step=0.1, value=4.0, label='Range', elem_id=f"{tab}_hdr_boundary")
hdr_threshold = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, value=0.95, label='Threshold', elem_id=f"{tab}_hdr_threshold")
with gr.Row():
hdr_brightness = gr.Slider(minimum=-1.0, maximum=1.0, step=0.1, value=0, label='Brightness', elem_id=f"{tab}_hdr_brightness")
hdr_center = gr.Dropdown(label="HDR Brightness Center", choices=["Relative", "Absolute"], type="index", value="Relative", elem_id=f"{tab}_hdr_center", show_label=False)
with gr.Row():
hdr_color_correction = gr.Slider(minimum=0.0, maximum=2.0, step=0.1, value=0.0, label='Color Correction', elem_id=f"{tab}_hdr_color_correction")
with gr.Row():
hdr_sharpen = gr.Checkbox(label='HDR sharpen', value=False, elem_id=f"{tab}_sharpen")
hdr_sharpen_ratio = gr.Slider(minimum=-1.0, maximum=1.0, step=0.1, value=0, label='Sharpen ratio', elem_id=f"{tab}_hdr_sharpen_ratio")
hdr_sharpen_start = gr.Slider(minimum=0, maximum=1000, step=50, value=500, label='Sharpen start', elem_id=f"{tab}_hdr_sharpen_start")
with gr.Row():
hdr_maximize = gr.Checkbox(label='HDR maximize', value=False, elem_id=f"{tab}_hdr_maximize")
hdr_max_center = gr.Slider(minimum=0.0, maximum=2.0, step=0.1, value=0.6, label='Center', elem_id=f"{tab}_hdr_max_center")
hdr_max_boundry = gr.Slider(minimum=0.5, maximum=2.0, step=0.1, value=1.0, label='Max Range', elem_id=f"{tab}_hdr_max_boundry")
return hdr_clamp, hdr_boundary, hdr_threshold, hdr_brightness, hdr_center, hdr_color_correction, hdr_sharpen, hdr_sharpen_ratio, hdr_sharpen_start, hdr_maximize, hdr_max_center, hdr_max_boundry
return hdr_mode, hdr_brightness, hdr_color, hdr_sharpen, hdr_clamp, hdr_boundary, hdr_threshold, hdr_maximize, hdr_max_center, hdr_max_boundry
def create_sampler_and_steps_selection(choices, tabname):
def set_sampler_original_options(sampler_options, sampler_algo):
+2 -2
View File
@@ -46,7 +46,7 @@ def create_ui():
batch_count, batch_size = ui_sections.create_batch_inputs('txt2img')
seed, reuse_seed, subseed, reuse_subseed, subseed_strength, seed_resize_from_h, seed_resize_from_w = ui_sections.create_seed_inputs('txt2img')
cfg_scale, clip_skip, image_cfg_scale, diffusers_guidance_rescale, sag_scale, cfg_end, full_quality, restore_faces, tiling = ui_sections.create_advanced_inputs('txt2img')
hdr_clamp, hdr_boundary, hdr_threshold, hdr_brightness, hdr_center, hdr_color_correction, hdr_sharpen, hdr_sharpen_ratio, hdr_sharpen_start, hdr_maximize, hdr_max_center, hdr_max_boundry = ui_sections.create_callback_inputs('txt2img')
hdr_mode, hdr_brightness, hdr_color, hdr_sharpen, hdr_clamp, hdr_boundary, hdr_threshold, hdr_maximize, hdr_max_center, hdr_max_boundry = ui_sections.create_correction_inputs('txt2img')
enable_hr, hr_sampler_index, denoising_strength, hr_final_resolution, hr_upscaler, hr_force, hr_second_pass_steps, hr_scale, hr_resize_x, hr_resize_y, refiner_steps, refiner_start, refiner_prompt, refiner_negative = ui_sections.create_hires_inputs('txt2img')
override_settings = ui_common.create_override_inputs('txt2img')
@@ -80,7 +80,7 @@ def create_ui():
enable_hr, denoising_strength,
hr_scale, hr_upscaler, hr_force, hr_second_pass_steps, hr_resize_x, hr_resize_y,
refiner_steps, refiner_start, refiner_prompt, refiner_negative,
hdr_clamp, hdr_boundary, hdr_threshold, hdr_brightness, hdr_center, hdr_color_correction, hdr_sharpen, hdr_sharpen_ratio, hdr_sharpen_start, hdr_maximize, hdr_max_center, hdr_max_boundry,
hdr_mode, hdr_brightness, hdr_color, hdr_sharpen, hdr_clamp, hdr_boundary, hdr_threshold, hdr_maximize, hdr_max_center, hdr_max_boundry,
override_settings,
]
txt2img_dict = dict(
+1 -1
View File
@@ -55,7 +55,7 @@ antlr4-python3-runtime==4.9.3
requests==2.31.0
tqdm==4.66.1
accelerate==0.26.1
opencv-contrib-python-headless==4.8.1.78
opencv-contrib-python-headless==4.9.0.80
diffusers==0.26.1
einops==0.4.1
gradio==3.43.2
+4 -5
View File
@@ -257,14 +257,13 @@ axis_options = [
AxisOption("[Refiner] Model", str, apply_refiner, fmt=format_value, cost=1.0, choices=lambda: ['None'] + sorted(sd_models.checkpoints_list)),
AxisOption("[Refiner] Refiner start", float, apply_field("refiner_start")),
AxisOption("[Refiner] Refiner steps", float, apply_field("refiner_steps")),
AxisOption("[HDR] Mode", int, apply_field("hdr_mode")),
AxisOption("[HDR] Brightness", float, apply_field("hdr_brightness")),
AxisOption("[HDR] Color", float, apply_field("hdr_color")),
AxisOption("[HDR] Sharpen", float, apply_field("hdr_sharpen")),
AxisOption("[HDR] Clamp boundary", float, apply_field("hdr_boundary")),
AxisOption("[HDR] Clamp threshold", float, apply_field("hdr_threshold")),
AxisOption("[HDR] Color Correction", float, apply_field("hdr_color_correction")),
AxisOption("[HDR] Brightness", float, apply_field("hdr_brightness")),
AxisOption("[HDR] Brightness Center", float, apply_field("hdr_center")),
AxisOption("[HDR] Maximize center shift", float, apply_field("hdr_max_center")),
AxisOption("[HDR] Sharpen ratio", float, apply_field("hdr_sharpen_ratio")),
AxisOption("[HDR] Sharpen start", float, apply_field("hdr_sharpen_start")),
AxisOption("[HDR] Maximize boundary", float, apply_field("hdr_max_boundry")),
AxisOption("[ToMe] Token merging ratio (txt2img)", float, apply_override('token_merging_ratio')),
AxisOption("[ToMe] Token merging ratio (hires)", float, apply_override('token_merging_ratio_hr')),
+1 -1
Submodule wiki updated: 853e874e8f...05d9b0f38e