From acc5f7591a5d66f1fa4b003a7a851778c560b86b Mon Sep 17 00:00:00 2001 From: unnamedplugins <79282950+unnamedplugins@users.noreply.github.com> Date: Mon, 12 Sep 2022 21:43:53 -0400 Subject: [PATCH 1/2] Fix issue where loopback was using batch mode --- scripts/webui_streamlit.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/webui_streamlit.py b/scripts/webui_streamlit.py index eaa7e2a..d7695dd 100644 --- a/scripts/webui_streamlit.py +++ b/scripts/webui_streamlit.py @@ -1594,7 +1594,7 @@ def img2img(prompt: str = '', init_info: any = None, init_info_mask: any = None, except: print("Install scikit-image to perform color correction on loopback") - for i in range(1): + for i in range(n_iter): if do_color_correction and i == 0: correction_target = cv2.cvtColor(np.asarray(init_img.copy()), cv2.COLOR_RGB2LAB) @@ -1607,7 +1607,7 @@ def img2img(prompt: str = '', init_info: any = None, init_info_mask: any = None, sampler_name=sampler_name, save_grid=save_grid, batch_size=1, - n_iter=n_iter, + n_iter=1, steps=ddim_steps, cfg_scale=cfg_scale, width=width, From 2af42fed51a9f9d987ebf3d6210343ccfb6f9159 Mon Sep 17 00:00:00 2001 From: unnamedplugins <79282950+unnamedplugins@users.noreply.github.com> Date: Mon, 12 Sep 2022 23:01:59 -0400 Subject: [PATCH 2/2] Fix indentation error that prevents mask_restore from working unless ESRGAN is turned on --- scripts/webui_streamlit.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/scripts/webui_streamlit.py b/scripts/webui_streamlit.py index d7695dd..b08de90 100644 --- a/scripts/webui_streamlit.py +++ b/scripts/webui_streamlit.py @@ -1273,27 +1273,27 @@ def process_images( if simple_templating: grid_captions.append( captions[i] + "\ngfpgan_esrgan" ) - if mask_restore and init_mask: - #init_mask = init_mask if keep_mask else ImageOps.invert(init_mask) - init_mask = init_mask.filter(ImageFilter.GaussianBlur(mask_blur_strength)) - init_mask = init_mask.convert('L') + if mask_restore and init_mask: + #init_mask = init_mask if keep_mask else ImageOps.invert(init_mask) + init_mask = init_mask.filter(ImageFilter.GaussianBlur(mask_blur_strength)) + init_mask = init_mask.convert('L') + init_img = init_img.convert('RGB') + image = image.convert('RGB') + + if use_RealESRGAN and st.session_state["RealESRGAN"] is not None: + if st.session_state["RealESRGAN"].model.name != realesrgan_model_name: + #try_loading_RealESRGAN(realesrgan_model_name) + load_models(use_GFPGAN=use_GFPGAN, use_RealESRGAN=use_RealESRGAN, RealESRGAN_model=realesrgan_model_name) + + output, img_mode = st.session_state["RealESRGAN"].enhance(np.array(init_img, dtype=np.uint8)) + init_img = Image.fromarray(output) init_img = init_img.convert('RGB') - image = image.convert('RGB') - if use_RealESRGAN and st.session_state["RealESRGAN"] is not None: - if st.session_state["RealESRGAN"].model.name != realesrgan_model_name: - #try_loading_RealESRGAN(realesrgan_model_name) - load_models(use_GFPGAN=use_GFPGAN, use_RealESRGAN=use_RealESRGAN, RealESRGAN_model=realesrgan_model_name) - - output, img_mode = st.session_state["RealESRGAN"].enhance(np.array(init_img, dtype=np.uint8)) - init_img = Image.fromarray(output) - init_img = init_img.convert('RGB') - - output, img_mode = st.session_state["RealESRGAN"].enhance(np.array(init_mask, dtype=np.uint8)) - init_mask = Image.fromarray(output) - init_mask = init_mask.convert('L') + output, img_mode = st.session_state["RealESRGAN"].enhance(np.array(init_mask, dtype=np.uint8)) + init_mask = Image.fromarray(output) + init_mask = init_mask.convert('L') - image = Image.composite(init_img, image, init_mask) + image = Image.composite(init_img, image, init_mask) if save_individual_images: save_sample(image, sample_path_i, filename, jpg_sample, prompts, seeds, width, height, steps, cfg_scale,