From 16c842366a0b918c0e1c4aa95168c69bba5fba75 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 21 Sep 2022 19:29:27 +0530 Subject: [PATCH] Don't apply filters if the user stops a task --- ui/sd_internal/runtime.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ui/sd_internal/runtime.py b/ui/sd_internal/runtime.py index 1b1f5b93..3deca3be 100644 --- a/ui/sd_internal/runtime.py +++ b/ui/sd_internal/runtime.py @@ -402,6 +402,11 @@ def mk_img(req: Request): has_filters = (opt_use_face_correction is not None and opt_use_face_correction.startswith('GFPGAN')) or \ (opt_use_upscale is not None and opt_use_upscale.startswith('RealESRGAN')) + return_orig_img = not has_filters or not opt_show_only_filtered + + if stop_processing: + return_orig_img = True + if opt_save_to_disk_path is not None: prompt_flattened = filename_regex.sub('_', prompts[0]) prompt_flattened = prompt_flattened[:50] @@ -412,12 +417,12 @@ def mk_img(req: Request): img_out_path = os.path.join(session_out_path, f"{file_path}.{opt_format}") meta_out_path = os.path.join(session_out_path, f"{file_path}.txt") - if not has_filters or not opt_show_only_filtered: + if return_orig_img: save_image(img, img_out_path) save_metadata(meta_out_path, prompts, opt_seed, opt_W, opt_H, opt_ddim_steps, opt_scale, opt_strength, opt_use_face_correction, opt_use_upscale) - if not has_filters or not opt_show_only_filtered: + if return_orig_img: img_data = img_to_base64_str(img) res_image_orig = ResponseImage(data=img_data, seed=opt_seed) res.images.append(res_image_orig) @@ -425,7 +430,7 @@ def mk_img(req: Request): if opt_save_to_disk_path is not None: res_image_orig.path_abs = img_out_path - if has_filters: + if has_filters and not stop_processing: print('Applying filters..') gc()