diff --git a/ui/index.html b/ui/index.html
index 0c6850cd..0a9c1499 100644
--- a/ui/index.html
+++ b/ui/index.html
@@ -714,7 +714,6 @@ async function doMakeImage(reqBody, batchCount) {
let res = ''
let seed = reqBody['seed']
let numOutputs = parseInt(reqBody['num_outputs'])
- let showOnlyFilteredImage = reqBody['show_only_filtered_image']
let images = []
@@ -843,7 +842,7 @@ async function doMakeImage(reqBody, batchCount) {
lastPromptUsed = reqBody['prompt']
- makeImageContainers(numOutputs * (showOnlyFilteredImage ? 1 : 2))
+ makeImageContainers(res.output.length)
for (let idx in res.output) {
let imgBody = ''
@@ -991,7 +990,8 @@ async function makeImage() {
use_cpu: useCPUField.checked,
use_full_precision: useFullPrecisionField.checked,
stream_progress_updates: true,
- stream_image_progress: streamImageProgress
+ stream_image_progress: streamImageProgress,
+ show_only_filtered_image: showOnlyFilteredImageField.checked
}
if (IMAGE_REGEX.test(initImagePreview.src)) {
@@ -1018,10 +1018,6 @@ async function makeImage() {
reqBody['use_upscale'] = upscaleModelField.value
}
- if (showOnlyFilteredImageField.checked && (useUpscalingField.checked || useFaceCorrectionField.checked)) {
- reqBody['show_only_filtered_image'] = showOnlyFilteredImageField.checked
- }
-
let time = new Date().getTime()
imagesContainer.innerHTML = ''
diff --git a/ui/sd_internal/runtime.py b/ui/sd_internal/runtime.py
index c05dde45..1b1f5b93 100644
--- a/ui/sd_internal/runtime.py
+++ b/ui/sd_internal/runtime.py
@@ -399,6 +399,9 @@ def mk_img(req: Request):
x_sample = x_sample.astype(np.uint8)
img = Image.fromarray(x_sample)
+ 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'))
+
if opt_save_to_disk_path is not None:
prompt_flattened = filename_regex.sub('_', prompts[0])
prompt_flattened = prompt_flattened[:50]
@@ -409,12 +412,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 opt_show_only_filtered:
+ if not has_filters or not opt_show_only_filtered:
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 opt_show_only_filtered:
+ if not has_filters or not opt_show_only_filtered:
img_data = img_to_base64_str(img)
res_image_orig = ResponseImage(data=img_data, seed=opt_seed)
res.images.append(res_image_orig)
@@ -422,9 +425,7 @@ def mk_img(req: Request):
if opt_save_to_disk_path is not None:
res_image_orig.path_abs = img_out_path
- if (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')):
-
+ if has_filters:
print('Applying filters..')
gc()