From 3047f92a4a6be39fe8e35425398daa7a77231867 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Sat, 4 Jan 2025 13:55:57 -0500 Subject: [PATCH] improve metadata Signed-off-by: Vladimir Mandic --- CHANGELOG.md | 4 +++- modules/processing_args.py | 3 ++- modules/processing_info.py | 26 ++++++++++++++------------ modules/ui_control.py | 6 ++++-- modules/ui_img2img.py | 27 ++++++++++++++++++++++++--- modules/ui_txt2img.py | 12 ++++++------ wiki | 2 +- 7 files changed, 54 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2bd7d4b7..0be26a812 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log for SD.Next -## Update for 2025-01-03 +## Update for 2025-01-04 - [Allegro Video](https://huggingface.co/rhymes-ai/Allegro) - optimizations: full offload and quantization support @@ -20,6 +20,8 @@ - add explicit detailer steps setting - **SysInfo**: - update to collected data and benchmarks +- **Metadata**: + - improved metadata save and restore - **Fixes**: - explict clear caches on model load - lock adetailer commit: `#a89c01d` diff --git a/modules/processing_args.py b/modules/processing_args.py index 360928de7..32fac0b17 100644 --- a/modules/processing_args.py +++ b/modules/processing_args.py @@ -35,7 +35,8 @@ def task_specific_kwargs(p, model): elif (sd_models.get_diffusers_task(model) == sd_models.DiffusersTaskType.IMAGE_2_IMAGE or is_img2img_model) and len(getattr(p, 'init_images', [])) > 0: if shared.sd_model_type == 'sdxl' and hasattr(model, 'register_to_config'): model.register_to_config(requires_aesthetics_score = False) - p.ops.append('img2img') + if 'hires' not in p.ops: + p.ops.append('img2img') task_args = { 'image': p.init_images, 'strength': p.denoising_strength, diff --git a/modules/processing_info.py b/modules/processing_info.py index e0fca12ae..54bfe331d 100644 --- a/modules/processing_info.py +++ b/modules/processing_info.py @@ -37,7 +37,6 @@ def create_infotext(p: StableDiffusionProcessing, all_prompts=None, all_seeds=No all_negative_prompts.append(all_negative_prompts[-1]) comment = ', '.join(comments) if comments is not None and type(comments) is list else None ops = list(set(p.ops)) - ops.reverse() args = { # basic "Size": f"{p.width}x{p.height}" if hasattr(p, 'width') and hasattr(p, 'height') else None, @@ -46,6 +45,7 @@ def create_infotext(p: StableDiffusionProcessing, all_prompts=None, all_seeds=No "Seed": all_seeds[index], "Seed resize from": None if p.seed_resize_from_w == 0 or p.seed_resize_from_h == 0 else f"{p.seed_resize_from_w}x{p.seed_resize_from_h}", "CFG scale": p.cfg_scale if p.cfg_scale > 1.0 else None, + "CFG rescale": p.diffusers_guidance_rescale if p.diffusers_guidance_rescale > 0 else None, "CFG end": p.cfg_end if p.cfg_end < 1.0 else None, "Clip skip": p.clip_skip if p.clip_skip > 1 else None, "Batch": f'{p.n_iter}x{p.batch_size}' if p.n_iter > 1 or p.batch_size > 1 else None, @@ -82,31 +82,33 @@ def create_infotext(p: StableDiffusionProcessing, all_prompts=None, all_seeds=No args["Variation strength"] = p.subseed_strength if p.subseed_strength > 0 else None if 'hires' in p.ops or 'upscale' in p.ops: is_resize = p.hr_resize_mode > 0 and (p.hr_upscaler != 'None' or p.hr_resize_mode == 5) + is_fixed = p.hr_resize_x > 0 or p.hr_resize_y > 0 args["Refine"] = p.enable_hr args["Hires force"] = p.hr_force args["Hires steps"] = p.hr_second_pass_steps - args["HiRes resize mode"] = p.hr_resize_mode if is_resize else None - args["HiRes resize context"] = p.hr_resize_context if p.hr_resize_mode == 5 else None + args["HiRes mode"] = p.hr_resize_mode if is_resize else None + args["HiRes context"] = p.hr_resize_context if p.hr_resize_mode == 5 else None args["Hires upscaler"] = p.hr_upscaler if is_resize else None - args["Hires scale"] = p.hr_scale if is_resize else None - args["Hires resize"] = f"{p.hr_resize_x}x{p.hr_resize_y}" if is_resize else None + if is_fixed: + args["Hires fixed"] = f"{p.hr_resize_x}x{p.hr_resize_y}" if is_resize else None + else: + args["Hires scale"] = p.hr_scale if is_resize else None args["Hires size"] = f"{p.hr_upscale_to_x}x{p.hr_upscale_to_y}" if is_resize else None - args["Denoising strength"] = p.denoising_strength - args["Hires sampler"] = p.hr_sampler_name - args["Image CFG scale"] = p.image_cfg_scale - args["CFG rescale"] = p.diffusers_guidance_rescale + args["Hires strength"] = p.denoising_strength + args["Hires sampler"] = p.hr_sampler_name if p.hr_sampler_name != p.sampler_name else None + args["Hires CFG scale"] = p.image_cfg_scale if 'refine' in p.ops: args["Refine"] = p.enable_hr args["Refiner"] = None if (not shared.opts.add_model_name_to_info) or (not shared.sd_refiner) or (not shared.sd_refiner.sd_checkpoint_info.model_name) else shared.sd_refiner.sd_checkpoint_info.model_name.replace(',', '').replace(':', '') - args['Image CFG scale'] = p.image_cfg_scale + args['Hires CFG scale'] = p.image_cfg_scale args['Refiner steps'] = p.refiner_steps args['Refiner start'] = p.refiner_start args["Hires steps"] = p.hr_second_pass_steps args["Hires sampler"] = p.hr_sampler_name - args["CFG rescale"] = p.diffusers_guidance_rescale - if 'img2img' in p.ops or 'inpaint' in p.ops: + if ('img2img' in p.ops or 'inpaint' in p.ops) and ('txt2img' not in p.ops and 'hires' not in p.ops): # real img2img/inpaint args["Init image size"] = f"{getattr(p, 'init_img_width', 0)}x{getattr(p, 'init_img_height', 0)}" args["Init image hash"] = getattr(p, 'init_img_hash', None) + args['Image CFG scale'] = p.image_cfg_scale args['Resize scale'] = getattr(p, 'scale_by', None) args["Mask weight"] = getattr(p, "inpainting_mask_weight", shared.opts.inpainting_mask_weight) if p.is_using_inpainting_conditioning else None args["Denoising strength"] = getattr(p, 'denoising_strength', None) diff --git a/modules/ui_control.py b/modules/ui_control.py index c12a03130..4dbd1b089 100644 --- a/modules/ui_control.py +++ b/modules/ui_control.py @@ -649,6 +649,7 @@ def create_ui(_blocks: gr.Blocks=None): (cfg_end, "CFG end"), (clip_skip, "Clip skip"), (image_cfg_scale, "Image CFG scale"), + (image_cfg_scale, "Hires CFG scale"), (guidance_rescale, "CFG rescale"), (full_quality, "Full quality"), (detailer, "Detailer"), @@ -658,13 +659,14 @@ def create_ui(_blocks: gr.Blocks=None): (enable_hr, "Second pass"), (enable_hr, "Refine"), (hr_sampler_index, "Hires sampler"), + (denoising_strength, "Hires strength"), (denoising_strength, "Denoising strength"), (hr_upscaler, "Hires upscaler"), (hr_force, "Hires force"), (hr_second_pass_steps, "Hires steps"), (hr_scale, "Hires upscale"), - (hr_resize_x, "Hires resize-1"), - (hr_resize_y, "Hires resize-2"), + (hr_resize_x, "Hires fixed-1"), + (hr_resize_y, "Hires fixed-2"), # refiner (refiner_start, "Refiner start"), (refiner_steps, "Refiner steps"), diff --git a/modules/ui_img2img.py b/modules/ui_img2img.py index 45c901c6d..48f22af7e 100644 --- a/modules/ui_img2img.py +++ b/modules/ui_img2img.py @@ -253,19 +253,40 @@ def create_ui(): (seed, "Seed"), (subseed, "Variation seed"), (subseed_strength, "Variation strength"), - # denoise - (denoising_strength, "Denoising strength"), - (refiner_start, "Refiner start"), # advanced (cfg_scale, "CFG scale"), (cfg_end, "CFG end"), (image_cfg_scale, "Image CFG scale"), + (image_cfg_scale, "Hires CFG scale"), (clip_skip, "Clip skip"), (diffusers_guidance_rescale, "CFG rescale"), (full_quality, "Full quality"), (detailer, "Detailer"), (tiling, "Tiling"), (hidiffusion, "HiDiffusion"), + # second pass + (enable_hr, "Second pass"), + (enable_hr, "Refine"), + (denoising_strength, "Denoising strength"), + (denoising_strength, "Hires strength"), + (hr_sampler_index, "Hires sampler"), + (hr_resize_mode, "Hires mode"), + (hr_resize_context, "Hires context"), + (hr_upscaler, "Hires upscaler"), + (hr_force, "Hires force"), + (hr_second_pass_steps, "Hires steps"), + (hr_scale, "Hires upscale"), + (hr_scale, "Hires scale"), + (hr_resize_x, "Hires fixed-1"), + (hr_resize_y, "Hires fixed-2"), + # refiner + (refiner_start, "Refiner start"), + (refiner_steps, "Refiner steps"), + (refiner_prompt, "Prompt2"), + (refiner_negative, "Negative2"), + # pag + (pag_scale, "PAG scale"), + (pag_adaptive, "PAG adaptive"), # inpaint (mask_blur, "Mask blur"), (mask_alpha, "Mask alpha"), diff --git a/modules/ui_txt2img.py b/modules/ui_txt2img.py index e2886e901..be27b7e9e 100644 --- a/modules/ui_txt2img.py +++ b/modules/ui_txt2img.py @@ -119,6 +119,7 @@ def create_ui(): (cfg_end, "CFG end"), (clip_skip, "Clip skip"), (image_cfg_scale, "Image CFG scale"), + (image_cfg_scale, "Hires CFG scale"), (diffusers_guidance_rescale, "CFG rescale"), (full_quality, "Full quality"), (detailer, "Detailer"), @@ -128,18 +129,17 @@ def create_ui(): (enable_hr, "Second pass"), (enable_hr, "Refine"), (denoising_strength, "Denoising strength"), + (denoising_strength, "Hires strength"), (hr_sampler_index, "Hires sampler"), - (hr_resize_mode, "Hires resize mode"), - (hr_resize_context, "Hires resize context"), + (hr_resize_mode, "Hires mode"), + (hr_resize_context, "Hires context"), (hr_upscaler, "Hires upscaler"), (hr_force, "Hires force"), (hr_second_pass_steps, "Hires steps"), (hr_scale, "Hires upscale"), (hr_scale, "Hires scale"), - (hr_resize_x, "Hires resize-1"), - (hr_resize_y, "Hires resize-2"), - (hr_resize_x, "Hires size-1"), - (hr_resize_y, "Hires size-2"), + (hr_resize_x, "Hires fixed-1"), + (hr_resize_y, "Hires fixed-2"), # refiner (refiner_start, "Refiner start"), (refiner_steps, "Refiner steps"), diff --git a/wiki b/wiki index 7bd8f8200..1f792d308 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 7bd8f82008007bc7a766ca47b4dc1a54470397df +Subproject commit 1f792d30858b511ef728531250f3c1a283e4c211