diff --git a/CHANGELOG.md b/CHANGELOG.md index b727e8f13..7a46ec7f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,7 @@ - add hdr settings to metadata - improve handling of long filenames and filenames during batch processing - do not set preview samples when using via api + - log output file sizes - avoid unnecessary resizes in img2img and inpaint - updated `cli/simple-txt2img.py` and `cli/simple-img2img.py` scripts - save `params.txt` regardless of image save status diff --git a/modules/images.py b/modules/images.py index 9b6d4cf67..2a372faaf 100644 --- a/modules/images.py +++ b/modules/images.py @@ -520,7 +520,8 @@ def atomically_save_image(): image_format = 'JPEG' if shared.opts.image_watermark_enabled: image = set_watermark(image, shared.opts.image_watermark) - shared.log.debug(f'Saving: image="{fn}" type={image_format} size={image.width}x{image.height}') + size = os.path.getsize(fn) if os.path.exists(fn) else 0 + shared.log.debug(f'Saving: image="{fn}" type={image_format} resolution={image.width}x{image.height} size={size}') # additional metadata saved in files if shared.opts.save_txt and len(exifinfo) > 0: try: diff --git a/modules/modelloader.py b/modules/modelloader.py index c1dc6bfa1..a8bf22339 100644 --- a/modules/modelloader.py +++ b/modules/modelloader.py @@ -607,3 +607,4 @@ def load_upscalers(): shared.sd_upscalers = sorted(datas, key=lambda x: x.name.lower() if not isinstance(x.scaler, (UpscalerNone, UpscalerLanczos, UpscalerNearest)) else "") # Special case for UpscalerNone keeps it at the beginning of the list. t1 = time.time() shared.log.debug(f"Load upscalers: total={len(shared.sd_upscalers)} downloaded={len([x for x in shared.sd_upscalers if x.data_path is not None and os.path.isfile(x.data_path)])} user={len([x for x in shared.sd_upscalers if x.custom])} time={t1-t0:.2f} {names}") + return [x.name for x in shared.sd_upscalers] diff --git a/modules/shared.py b/modules/shared.py index 1a8e664b2..d88d651bd 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -152,6 +152,11 @@ def refresh_vaes(): modules.sd_vae.refresh_vae_list() +def refresh_upscalers(): + import modules.modelloader + modules.modelloader.load_upscalers() + + def list_samplers(): import modules.sd_samplers # pylint: disable=W0621 modules.sd_samplers.set_samplers() @@ -564,7 +569,7 @@ options_templates.update(options_section(('postprocessing', "Postprocessing"), { "postprocessing_sep_upscalers": OptionInfo("

Upscaling

", "", gr.HTML), "upscaler_unload": OptionInfo(False, "Unload upscaler after processing"), # 'upscaling_max_images_in_cache': OptionInfo(5, "Maximum number of images in upscaling cache", gr.Slider, {"minimum": 0, "maximum": 10, "step": 1, "visible": False}), - "upscaler_for_img2img": OptionInfo("None", "Default upscaler for image resize operations", gr.Dropdown, lambda: {"choices": [x.name for x in sd_upscalers], "visible": False}), + "upscaler_for_img2img": OptionInfo("None", "Default upscaler for image resize operations", gr.Dropdown, lambda: {"choices": [x.name for x in sd_upscalers], "visible": False}, refresh=refresh_upscalers), "upscaler_tile_size": OptionInfo(192, "Upscaler tile size", gr.Slider, {"minimum": 0, "maximum": 512, "step": 16}), "upscaler_tile_overlap": OptionInfo(8, "Upscaler tile overlap", gr.Slider, {"minimum": 0, "maximum": 64, "step": 1}), })) diff --git a/modules/ui.py b/modules/ui.py index 217e284ec..c93c76430 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -10,7 +10,7 @@ import numpy as np from PIL import Image from modules.call_queue import wrap_gradio_gpu_call, wrap_queued_call, wrap_gradio_call -from modules import sd_hijack, sd_models, script_callbacks, ui_extensions, deepbooru, extra_networks, ui_common, ui_postprocessing, ui_loadsave, ui_train, ui_models, ui_interrogate +from modules import sd_hijack, sd_models, script_callbacks, ui_extensions, deepbooru, extra_networks, ui_common, ui_postprocessing, ui_loadsave, ui_train, ui_models, ui_interrogate, modelloader from modules.ui_components import FormRow, FormGroup, ToolButton, FormHTML from modules.paths import script_path, data_path from modules.shared import opts, cmd_opts @@ -223,6 +223,7 @@ def create_resize_inputs(tab, images, time_selector=False, scale_visible=True): resize_time = gr.Radio(label="Resize order", elem_id=f"{tab}_resize_order", choices=['Before', 'After'], value="Before", visible=time_selector) with gr.Row(): resize_name = gr.Dropdown(label="Resize method", elem_id=f"{tab}_resize_name", choices=[x.name for x in modules.shared.sd_upscalers], value=opts.upscaler_for_img2img) + create_refresh_button(resize_name, modelloader.load_upscalers, lambda: {"choices": modelloader.load_upscalers()}, 'refresh_upscalers') with FormRow(visible=True) as _resize_group: with gr.Column(elem_id=f"{tab}_column_size"): @@ -1206,7 +1207,6 @@ def create_ui(startup_timer = None): ) def reference_submit(model): - from modules import modelloader loaded = modelloader.load_reference(model) if loaded: return model if loaded else opts.sd_model_checkpoint