From bb438efed47d5ed064ea5933cccc009d8549d4cb Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Tue, 25 Apr 2023 09:53:11 -0400 Subject: [PATCH] update geninfo --- modules/extras.py | 11 +++++------ modules/images.py | 2 +- modules/processing.py | 2 +- modules/ui_postprocessing.py | 9 ++++++++- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/modules/extras.py b/modules/extras.py index 1907a18b1..c0ae9477f 100644 --- a/modules/extras.py +++ b/modules/extras.py @@ -5,12 +5,11 @@ import shutil import torch import tqdm - -from modules import shared, images, sd_models, sd_vae, sd_models_config -from modules.ui_common import plaintext_to_html import gradio as gr import safetensors.torch +from modules import shared, images, sd_models, sd_vae, sd_models_config + def run_pnginfo(image): if image is None: @@ -130,14 +129,14 @@ def run_modelmerger(id_task, primary_model_name, secondary_model_name, tertiary_ result_is_instruct_pix2pix_model = False if theta_func2: - shared.state.textinfo = f"Loading B" + shared.state.textinfo = "Loading B" print(f"Loading {secondary_model_info.filename}...") theta_1 = sd_models.read_state_dict(secondary_model_info.filename) else: theta_1 = None if theta_func1: - shared.state.textinfo = f"Loading C" + shared.state.textinfo = "Loading C" print(f"Loading {tertiary_model_info.filename}...") theta_2 = sd_models.read_state_dict(tertiary_model_info.filename) @@ -193,7 +192,7 @@ def run_modelmerger(id_task, primary_model_name, secondary_model_name, tertiary_ result_is_inpainting_model = True else: theta_0[key] = theta_func2(a, b, multiplier) - + theta_0[key] = to_half(theta_0[key], save_as_half) shared.state.sampling_step += 1 diff --git a/modules/images.py b/modules/images.py index a137e73dc..8b3c539c3 100644 --- a/modules/images.py +++ b/modules/images.py @@ -634,7 +634,7 @@ def read_info_from_image(image): if isinstance(val, bytes): # decode bytestring items[key] = safe_decode_string(val) - for key in ['exif', 'ExifOffset', 'JpegIFOffset', 'JpegIFByteCount', 'ExifVersion', 'icc_profile', 'jfif', 'jfif_version', 'jfif_unit', 'jfif_density', 'adobe', 'photoshop', 'loop', 'duration']: # remove unwanted tags + for key in ['exif', 'ExifOffset', 'JpegIFOffset', 'JpegIFByteCount', 'ExifVersion', 'icc_profile', 'jfif', 'jfif_version', 'jfif_unit', 'jfif_density', 'adobe', 'photoshop', 'loop', 'duration', 'dpi']: # remove unwanted tags items.pop(key, None) if items.get("Software", None) == "NovelAI": diff --git a/modules/processing.py b/modules/processing.py index 43200c9ff..a546e4f19 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -474,6 +474,7 @@ def create_infotext(p, all_prompts, all_seeds, all_subseeds, comments=None, iter "Size": f"{p.width}x{p.height}", "Model hash": getattr(p, 'sd_model_hash', None if not opts.add_model_hash_to_info or not shared.sd_model.sd_model_hash else shared.sd_model.sd_model_hash), "Model": (None if not opts.add_model_name_to_info or not shared.sd_model.sd_checkpoint_info.model_name else shared.sd_model.sd_checkpoint_info.model_name.replace(',', '').replace(':', '')), + "VAE": (None if not opts.add_model_name_to_info or sd_vae.loaded_vae_file is None else os.path.splitext(os.path.basename(sd_vae.loaded_vae_file))[0]), "Variation seed": (None if p.subseed_strength == 0 else all_subseeds[index]), "Variation seed strength": (None if p.subseed_strength == 0 else p.subseed_strength), "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}"), @@ -490,7 +491,6 @@ def create_infotext(p, all_prompts, all_seeds, all_subseeds, comments=None, iter "Token merging stride x": None if opts.token_merging_stride_x == 2 else opts.token_merging_stride_x, "Token merging stride y": None if opts.token_merging_stride_y == 2 else opts.token_merging_stride_y } - generation_params.update(p.extra_generation_params) generation_params_text = ", ".join([k if k == v else f'{k}: {generation_parameters_copypaste.quote(v)}' for k, v in generation_params.items() if v is not None]) diff --git a/modules/ui_postprocessing.py b/modules/ui_postprocessing.py index 23c2d60bc..243631d88 100644 --- a/modules/ui_postprocessing.py +++ b/modules/ui_postprocessing.py @@ -32,17 +32,24 @@ def create_ui(): with gr.Column(): result_images, html_info_x, html_info, _html_log = ui_common.create_output_panel("extras", shared.opts.outdir_extras_samples) html_info = gr.HTML(elem_id="pnginfo_html_info") - generation_info = gr.Textbox(elem_id="pnginfo_generation_info", label="Parameters") + generation_info = gr.Textbox(elem_id="pnginfo_generation_info", label="Parameters", visible=False) + generation_info_pretty = gr.Textbox(elem_id="pnginfo_generation_info_pretty", label="Parameters") + gr.HTML('Full metadata') html2_info = gr.HTML(elem_id="pnginfo_html2_info") for tabname, button in buttons.items(): parameters_copypaste.register_paste_params_button(parameters_copypaste.ParamBinding(paste_button=button, tabname=tabname, source_text_component=generation_info, source_image_component=extras_image)) + def pretty_geninfo(generation_info): + return generation_info.replace(', ', '\n') + tab_single.select(fn=lambda: 0, inputs=[], outputs=[tab_index]) tab_batch.select(fn=lambda: 1, inputs=[], outputs=[tab_index]) tab_batch_dir.select(fn=lambda: 2, inputs=[], outputs=[tab_index]) + generation_info.change(fn=pretty_geninfo, inputs=[generation_info], outputs=[generation_info_pretty]) + extras_image.change( fn=wrap_gradio_call(run_pnginfo), inputs=[extras_image],