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()