From de5bfdf9177d7035c76a890c241f8a5a32455cad Mon Sep 17 00:00:00 2001 From: JJ Date: Sat, 17 Sep 2022 06:48:22 +1000 Subject: image info tab * handles exceptions if jpeg jfif data not present * removes further non-comment related exif data. --- modules/extras.py | 7 ++++--- modules/ui.py | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'modules') diff --git a/modules/extras.py b/modules/extras.py index 38d6ec48..64b4f2b6 100644 --- a/modules/extras.py +++ b/modules/extras.py @@ -97,7 +97,7 @@ def run_extras(image, image_folder, gfpgan_visibility, codeformer_visibility, co return outputs, plaintext_to_html(info), '' -def run_pnginfo(image): +def run_image_info(image): items = image.info if "exif" in image.info: @@ -111,8 +111,9 @@ def run_pnginfo(image): items['exif comment'] = exif_comment - for field in ['jfif', 'jfif_version', 'jfif_unit', 'jfif_density', 'dpi', 'exif']: - del items[field] + for field in ['jfif', 'jfif_version', 'jfif_unit', 'jfif_density', 'dpi', 'exif', + 'loop', 'background', 'timestamp', 'duration']: + items.pop(field, None) info = '' diff --git a/modules/ui.py b/modules/ui.py index 738ac945..0899490f 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -295,7 +295,7 @@ def create_toprow(is_img2img): return prompt, roll, prompt_style, negative_prompt, prompt_style2, submit, interrogate, prompt_style_apply, save_style, check_progress -def create_ui(txt2img, img2img, run_extras, run_pnginfo): +def create_ui(txt2img, img2img, run_extras, run_image_info): with gr.Blocks(analytics_enabled=False) as txt2img_interface: txt2img_prompt, roll, txt2img_prompt_style, txt2img_negative_prompt, txt2img_prompt_style2, submit, _, txt2img_prompt_style_apply, txt2img_save_style, check_progress = create_toprow(is_img2img=False) @@ -697,7 +697,7 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo): submit.click(**extras_args) pnginfo_interface = gr.Interface( - wrap_gradio_call(run_pnginfo), + wrap_gradio_call(run_image_info), inputs=[ gr.Image(label="Source", source="upload", interactive=True, type="pil"), ], -- cgit v1.2.1 From 047a623f7a5c585d308d25268763f76ea225f9a0 Mon Sep 17 00:00:00 2001 From: jjisnow Date: Sat, 17 Sep 2022 16:07:07 +1000 Subject: Restore run_pnginfo --- modules/extras.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/extras.py b/modules/extras.py index 64b4f2b6..3d9d9f7a 100644 --- a/modules/extras.py +++ b/modules/extras.py @@ -97,7 +97,7 @@ def run_extras(image, image_folder, gfpgan_visibility, codeformer_visibility, co return outputs, plaintext_to_html(info), '' -def run_image_info(image): +def run_pnginfo(image): items = image.info if "exif" in image.info: -- cgit v1.2.1 From 588d6de4a870a80862377d14c4f316ff13e5e818 Mon Sep 17 00:00:00 2001 From: jjisnow Date: Sat, 17 Sep 2022 16:08:56 +1000 Subject: Update ui.py Reverse run_pnginfo for compatibility reasons --- modules/ui.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/ui.py b/modules/ui.py index 0899490f..738ac945 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -295,7 +295,7 @@ def create_toprow(is_img2img): return prompt, roll, prompt_style, negative_prompt, prompt_style2, submit, interrogate, prompt_style_apply, save_style, check_progress -def create_ui(txt2img, img2img, run_extras, run_image_info): +def create_ui(txt2img, img2img, run_extras, run_pnginfo): with gr.Blocks(analytics_enabled=False) as txt2img_interface: txt2img_prompt, roll, txt2img_prompt_style, txt2img_negative_prompt, txt2img_prompt_style2, submit, _, txt2img_prompt_style_apply, txt2img_save_style, check_progress = create_toprow(is_img2img=False) @@ -697,7 +697,7 @@ def create_ui(txt2img, img2img, run_extras, run_image_info): submit.click(**extras_args) pnginfo_interface = gr.Interface( - wrap_gradio_call(run_image_info), + wrap_gradio_call(run_pnginfo), inputs=[ gr.Image(label="Source", source="upload", interactive=True, type="pil"), ], -- cgit v1.2.1 From ba295b32688629cf575d67f1750a7838b008858b Mon Sep 17 00:00:00 2001 From: Tony Beeman Date: Sat, 17 Sep 2022 01:34:33 -0700 Subject: * Fix process_images where the number of images is not a multiple of (batch_size * n_iter), which would cause us to throw an exception. * Add a textbox option to Prompts from file (ease of use and it makes it much easier to use on a mobile device) * Fix the fact that Prompts from file was sometimes passing an empty batch. --- modules/processing.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/processing.py b/modules/processing.py index 3a4ff224..6a99d383 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -188,7 +188,11 @@ def fix_seed(p): def process_images(p: StableDiffusionProcessing) -> Processed: """this is the main loop that both txt2img and img2img use; it calls func_init once inside all the scopes and func_sample once per batch""" - assert p.prompt is not None + if type(p.prompt) == list: + assert(len(p.prompt) > 0) + else: + assert p.prompt is not None + devices.torch_gc() fix_seed(p) @@ -265,6 +269,9 @@ def process_images(p: StableDiffusionProcessing) -> Processed: seeds = all_seeds[n * p.batch_size:(n + 1) * p.batch_size] subseeds = all_subseeds[n * p.batch_size:(n + 1) * p.batch_size] + if (len(prompts) == 0): + break + #uc = p.sd_model.get_learned_conditioning(len(prompts) * [p.negative_prompt]) #c = p.sd_model.get_learned_conditioning(prompts) uc = prompt_parser.get_learned_conditioning(len(prompts) * [p.negative_prompt], p.steps) -- cgit v1.2.1