From be3f080909968278f2713ee72925b5d9eb50248f Mon Sep 17 00:00:00 2001 From: ClashSAN <98228077+ClashSAN@users.noreply.github.com> Date: Wed, 21 Sep 2022 20:58:41 +0000 Subject: [PATCH 01/20] Update README.md Added SwinIR and new features to readme --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index d355db34..e9c2c572 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ A browser interface based on Gradio library for Stable Diffusion. - CodeFormer, face restoration tool as an alternative to GFPGAN - RealESRGAN, neural network upscaler - ESRGAN, neural network with a lot of third party models + - SwinIR, neural network upscaler - Resizing aspect ratio options - Sampling method selection - Interrupt processing at any time @@ -41,6 +42,10 @@ A browser interface based on Gradio library for Stable Diffusion. - Seed resizing - CLIP interrogator - Prompt Editing +- Batch Processing +- Img2img Alternative +- Highres Fix +- Golatent Upscaling ## Installation and Running Make sure the required [dependencies](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Dependencies) are met and follow the instructions available for both [NVidia](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Install-and-Run-on-NVidia-GPUs) (recommended) and [AMD](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Install-and-Run-on-AMD-GPUs) GPUs. @@ -79,6 +84,7 @@ The documentation was moved from this README over to the project's [wiki](https: - GFPGAN - https://github.com/TencentARC/GFPGAN.git - CodeFormer - https://github.com/sczhou/CodeFormer - ESRGAN - https://github.com/xinntao/ESRGAN +- SwinIR - https://github.com/JingyunLiang/SwinIR - Ideas for optimizations - https://github.com/basujindal/stable-diffusion - Doggettx - Cross Attention layer optimization - https://github.com/Doggettx/stable-diffusion, original idea for prompt editing. - Idea for SD upscale - https://github.com/jquesnelle/txt2imghd From 76c9d1a991872c539732337680c7f7b867108b23 Mon Sep 17 00:00:00 2001 From: ClashSAN <98228077+ClashSAN@users.noreply.github.com> Date: Wed, 21 Sep 2022 21:07:18 +0000 Subject: [PATCH 02/20] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e9c2c572..f99e465a 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ A browser interface based on Gradio library for Stable Diffusion. - Batch Processing - Img2img Alternative - Highres Fix -- Golatent Upscaling +- LDSR Upscaling ## Installation and Running Make sure the required [dependencies](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Dependencies) are met and follow the instructions available for both [NVidia](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Install-and-Run-on-NVidia-GPUs) (recommended) and [AMD](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Install-and-Run-on-AMD-GPUs) GPUs. From ca22b820f497d6a85862d53cf27793aa2511d22d Mon Sep 17 00:00:00 2001 From: ClashSAN <98228077+ClashSAN@users.noreply.github.com> Date: Wed, 21 Sep 2022 21:46:17 +0000 Subject: [PATCH 03/20] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f99e465a..c63a35ca 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ A browser interface based on Gradio library for Stable Diffusion. - RealESRGAN, neural network upscaler - ESRGAN, neural network with a lot of third party models - SwinIR, neural network upscaler + - LDSR Upscaling - Resizing aspect ratio options - Sampling method selection - Interrupt processing at any time From ef744b96d64695c1f4d5b6312a60078c1b8f2827 Mon Sep 17 00:00:00 2001 From: ClashSAN <98228077+ClashSAN@users.noreply.github.com> Date: Wed, 21 Sep 2022 22:53:35 +0000 Subject: [PATCH 04/20] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c63a35ca..c1538100 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ A browser interface based on Gradio library for Stable Diffusion. - RealESRGAN, neural network upscaler - ESRGAN, neural network with a lot of third party models - SwinIR, neural network upscaler - - LDSR Upscaling + - LDSR, Latent diffusion super resolution upscaling - Resizing aspect ratio options - Sampling method selection - Interrupt processing at any time @@ -86,6 +86,7 @@ The documentation was moved from this README over to the project's [wiki](https: - CodeFormer - https://github.com/sczhou/CodeFormer - ESRGAN - https://github.com/xinntao/ESRGAN - SwinIR - https://github.com/JingyunLiang/SwinIR +- LDSR - https://github.com/Hafiidz/latent-diffusion - Ideas for optimizations - https://github.com/basujindal/stable-diffusion - Doggettx - Cross Attention layer optimization - https://github.com/Doggettx/stable-diffusion, original idea for prompt editing. - Idea for SD upscale - https://github.com/jquesnelle/txt2imghd From cc287d53a5193aab42fa36bedae1ac590ad52322 Mon Sep 17 00:00:00 2001 From: d8ahazard Date: Tue, 20 Sep 2022 20:10:32 -0500 Subject: [PATCH 05/20] Bump Versions --- requirements_versions.txt | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/requirements_versions.txt b/requirements_versions.txt index bb88eda9..0ab14e0c 100644 --- a/requirements_versions.txt +++ b/requirements_versions.txt @@ -1,18 +1,17 @@ -transformers==4.19.2 -diffusers==0.2.4 -basicsr==1.3.5 -gfpgan +transformers==4.22.1 +diffusers==0.3.0 +basicsr==1.4.2 +gfpgan==1.3.8 gradio==3.3.1 numpy==1.23.3 Pillow==9.2.0 -realesrgan==0.2.5.0 +realesrgan==0.3.0 torch -transformers==4.19.2 -omegaconf==2.1.1 -pytorch_lightning==1.7.2 +omegaconf==2.2.3 +pytorch_lightning==1.7.6 scikit-image==0.19.2 fonts font-roboto -timm==0.4.12 -fairscale==0.4.4 +timm==0.6.7 +fairscale==0.4.9 piexif==1.1.3 \ No newline at end of file From dd5566814acb9623b201c441b458d0d6a7014f2f Mon Sep 17 00:00:00 2001 From: d8ahazard Date: Tue, 20 Sep 2022 20:11:53 -0500 Subject: [PATCH 06/20] Add new models, fix shared opts issues Add General x4x3, GeneralWDN x4x3, and AnimeVideo models from newer ESRGAN releases. Fix issues caused by renaming ESRGAN_tille values to GAN_tile without using an IDE... --- modules/esrgan_model.py | 4 ++-- modules/realesrgan_model.py | 33 +++++++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/modules/esrgan_model.py b/modules/esrgan_model.py index 7f3baf31..930e790c 100644 --- a/modules/esrgan_model.py +++ b/modules/esrgan_model.py @@ -92,10 +92,10 @@ def upscale_without_tiling(model, img): def esrgan_upscale(model, img): - if opts.ESRGAN_tile == 0: + if opts.GAN_tile == 0: return upscale_without_tiling(model, img) - grid = modules.images.split_grid(img, opts.ESRGAN_tile, opts.ESRGAN_tile, opts.ESRGAN_tile_overlap) + grid = modules.images.split_grid(img, opts.GAN_tile, opts.GAN_tile, opts.GAN_tile_overlap) newtiles = [] scale_factor = 1 diff --git a/modules/realesrgan_model.py b/modules/realesrgan_model.py index e2cef0c8..1f1af0c3 100644 --- a/modules/realesrgan_model.py +++ b/modules/realesrgan_model.py @@ -2,7 +2,11 @@ import sys import traceback from collections import namedtuple import numpy as np +import torch from PIL import Image +from basicsr.archs.rrdbnet_arch import RRDBNet +from realesrgan import RealESRGANer +from realesrgan.archs.srvgg_arch import SRVGGNetCompact import modules.images from modules.shared import cmd_opts, opts @@ -35,9 +39,27 @@ def setup_realesrgan(): from realesrgan.archs.srvgg_arch import SRVGGNetCompact realesrgan_models = [ + RealesrganModelInfo( + name="Real-ESRGAN General x4x3", + location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-x4v3.pth", + netscale=4, + model=lambda: SRVGGNetCompact(num_in_ch=3, num_out_ch=3, num_feat=64, num_conv=32, upscale=4, act_type='prelu') + ), + RealesrganModelInfo( + name="Real-ESRGAN General WDN x4x3", + location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-wdn-x4v3.pth", + netscale=4, + model=lambda: SRVGGNetCompact(num_in_ch=3, num_out_ch=3, num_feat=64, num_conv=32, upscale=4, act_type='prelu') + ), + RealesrganModelInfo( + name="Real-ESRGAN AnimeVideo", + location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-animevideov3.pth", + netscale=4, + model=lambda: SRVGGNetCompact(num_in_ch=3, num_out_ch=3, num_feat=64, num_conv=16, upscale=4, act_type='prelu') + ), RealesrganModelInfo( name="Real-ESRGAN 4x plus", - location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth", + location="https://github.com/xinntao/Real-ESRGA N/releases/download/v0.1.0/RealESRGAN_x4plus.pth", netscale=4, model=lambda: RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32, scale=4) ), RealesrganModelInfo( @@ -64,21 +86,20 @@ def setup_realesrgan(): realesrgan_models = [RealesrganModelInfo('None', '', 0, None)] have_realesrgan = False - def upscale_with_realesrgan(image, RealESRGAN_upscaling, RealESRGAN_model_index): - if not have_realesrgan or RealESRGANer_constructor is None: + if not have_realesrgan: return image info = realesrgan_models[RealESRGAN_model_index] model = info.model() - upsampler = RealESRGANer_constructor( + upsampler = RealESRGANer( scale=info.netscale, model_path=info.location, model=model, half=not cmd_opts.no_half, - tile=opts.ESRGAN_tile, - tile_pad=opts.ESRGAN_tile_overlap, + tile=opts.GAN_tile, + tile_pad=opts.GAN_tile_overlap, ) upsampled = upsampler.enhance(np.array(image), outscale=RealESRGAN_upscaling)[0] From 3cc68300cb81a12c574a0cb67bd6a27198b88310 Mon Sep 17 00:00:00 2001 From: d8ahazard Date: Wed, 21 Sep 2022 07:32:50 -0500 Subject: [PATCH 07/20] Typo Fix --- modules/realesrgan_model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/realesrgan_model.py b/modules/realesrgan_model.py index 1f1af0c3..7220feb7 100644 --- a/modules/realesrgan_model.py +++ b/modules/realesrgan_model.py @@ -59,7 +59,7 @@ def setup_realesrgan(): ), RealesrganModelInfo( name="Real-ESRGAN 4x plus", - location="https://github.com/xinntao/Real-ESRGA N/releases/download/v0.1.0/RealESRGAN_x4plus.pth", + location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth", netscale=4, model=lambda: RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32, scale=4) ), RealesrganModelInfo( From 9a93a82b8255f3049f1b1d30d0c06c3085e4410a Mon Sep 17 00:00:00 2001 From: d8ahazard Date: Wed, 21 Sep 2022 07:37:54 -0500 Subject: [PATCH 08/20] Cleanup Imports --- modules/realesrgan_model.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/realesrgan_model.py b/modules/realesrgan_model.py index 7220feb7..b24cffeb 100644 --- a/modules/realesrgan_model.py +++ b/modules/realesrgan_model.py @@ -1,12 +1,10 @@ import sys import traceback from collections import namedtuple + import numpy as np -import torch from PIL import Image -from basicsr.archs.rrdbnet_arch import RRDBNet from realesrgan import RealESRGANer -from realesrgan.archs.srvgg_arch import SRVGGNetCompact import modules.images from modules.shared import cmd_opts, opts From 4f434c8aea3007cbf8038aec0c2a73c452ec9eca Mon Sep 17 00:00:00 2001 From: d8ahazard Date: Wed, 21 Sep 2022 08:38:38 -0500 Subject: [PATCH 09/20] Fix/Revert opts name from GAN to ESRGAN --- modules/esrgan_model.py | 4 ++-- modules/realesrgan_model.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/esrgan_model.py b/modules/esrgan_model.py index 930e790c..7f3baf31 100644 --- a/modules/esrgan_model.py +++ b/modules/esrgan_model.py @@ -92,10 +92,10 @@ def upscale_without_tiling(model, img): def esrgan_upscale(model, img): - if opts.GAN_tile == 0: + if opts.ESRGAN_tile == 0: return upscale_without_tiling(model, img) - grid = modules.images.split_grid(img, opts.GAN_tile, opts.GAN_tile, opts.GAN_tile_overlap) + grid = modules.images.split_grid(img, opts.ESRGAN_tile, opts.ESRGAN_tile, opts.ESRGAN_tile_overlap) newtiles = [] scale_factor = 1 diff --git a/modules/realesrgan_model.py b/modules/realesrgan_model.py index b24cffeb..a3917773 100644 --- a/modules/realesrgan_model.py +++ b/modules/realesrgan_model.py @@ -96,8 +96,8 @@ def upscale_with_realesrgan(image, RealESRGAN_upscaling, RealESRGAN_model_index) model_path=info.location, model=model, half=not cmd_opts.no_half, - tile=opts.GAN_tile, - tile_pad=opts.GAN_tile_overlap, + tile=opts.ESRGAN_tile, + tile_pad=opts.ESRGAN_tile_overlap, ) upsampled = upsampler.enhance(np.array(image), outscale=RealESRGAN_upscaling)[0] From c214c428bcb28b8b32cbf42dc56eaf5e4cb17f06 Mon Sep 17 00:00:00 2001 From: d8ahazard Date: Wed, 21 Sep 2022 17:23:38 -0500 Subject: [PATCH 10/20] Basic settings for realesrgan model selection. I don't like that you have to restart the app, but it works. --- modules/realesrgan_model.py | 42 +++----------------- modules/realesrgan_model_loader.py | 62 ++++++++++++++++++++++++++++++ modules/shared.py | 5 +++ 3 files changed, 72 insertions(+), 37 deletions(-) create mode 100644 modules/realesrgan_model_loader.py diff --git a/modules/realesrgan_model.py b/modules/realesrgan_model.py index a3917773..fc8623de 100644 --- a/modules/realesrgan_model.py +++ b/modules/realesrgan_model.py @@ -7,10 +7,10 @@ from PIL import Image from realesrgan import RealESRGANer import modules.images +from modules import realesrgan_model_loader from modules.shared import cmd_opts, opts RealesrganModelInfo = namedtuple("RealesrganModelInfo", ["name", "location", "model", "netscale"]) - realesrgan_models = [] have_realesrgan = False RealESRGANer_constructor = None @@ -36,46 +36,13 @@ def setup_realesrgan(): from realesrgan import RealESRGANer from realesrgan.archs.srvgg_arch import SRVGGNetCompact - realesrgan_models = [ - RealesrganModelInfo( - name="Real-ESRGAN General x4x3", - location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-x4v3.pth", - netscale=4, - model=lambda: SRVGGNetCompact(num_in_ch=3, num_out_ch=3, num_feat=64, num_conv=32, upscale=4, act_type='prelu') - ), - RealesrganModelInfo( - name="Real-ESRGAN General WDN x4x3", - location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-wdn-x4v3.pth", - netscale=4, - model=lambda: SRVGGNetCompact(num_in_ch=3, num_out_ch=3, num_feat=64, num_conv=32, upscale=4, act_type='prelu') - ), - RealesrganModelInfo( - name="Real-ESRGAN AnimeVideo", - location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-animevideov3.pth", - netscale=4, - model=lambda: SRVGGNetCompact(num_in_ch=3, num_out_ch=3, num_feat=64, num_conv=16, upscale=4, act_type='prelu') - ), - RealesrganModelInfo( - name="Real-ESRGAN 4x plus", - location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth", - netscale=4, model=lambda: RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32, scale=4) - ), - RealesrganModelInfo( - name="Real-ESRGAN 4x plus anime 6B", - location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth", - netscale=4, model=lambda: RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=6, num_grow_ch=32, scale=4) - ), - RealesrganModelInfo( - name="Real-ESRGAN 2x plus", - location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.1/RealESRGAN_x2plus.pth", - netscale=2, model=lambda: RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32, scale=2) - ), - ] + realesrgan_models = realesrgan_model_loader.get_realesrgan_models() have_realesrgan = True RealESRGANer_constructor = RealESRGANer for i, model in enumerate(realesrgan_models): - modules.shared.sd_upscalers.append(UpscalerRealESRGAN(model.netscale, i)) + if model.name in opts.realesrgan_enabled_models: + modules.shared.sd_upscalers.append(UpscalerRealESRGAN(model.netscale, i)) except Exception: print("Error importing Real-ESRGAN:", file=sys.stderr) @@ -84,6 +51,7 @@ def setup_realesrgan(): realesrgan_models = [RealesrganModelInfo('None', '', 0, None)] have_realesrgan = False + def upscale_with_realesrgan(image, RealESRGAN_upscaling, RealESRGAN_model_index): if not have_realesrgan: return image diff --git a/modules/realesrgan_model_loader.py b/modules/realesrgan_model_loader.py new file mode 100644 index 00000000..3ae3f8b7 --- /dev/null +++ b/modules/realesrgan_model_loader.py @@ -0,0 +1,62 @@ +from collections import namedtuple + +RealesrganModelInfo = namedtuple("RealesrganModelInfo", ["name", "location", "model", "netscale"]) + + +def get_realesrgan_model_names(): + names = set() + models = get_realesrgan_models() + for model in models: + names.add(model.name) + return sorted(names) + + +def get_realesrgan_models(): + try: + from basicsr.archs.rrdbnet_arch import RRDBNet + from realesrgan import RealESRGANer + from realesrgan.archs.srvgg_arch import SRVGGNetCompact + models = [ + RealesrganModelInfo( + name="Real-ESRGAN General x4x3", + location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-x4v3.pth", + netscale=4, + model=lambda: SRVGGNetCompact(num_in_ch=3, num_out_ch=3, num_feat=64, num_conv=32, upscale=4, + act_type='prelu') + ), + RealesrganModelInfo( + name="Real-ESRGAN General WDN x4x3", + location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-wdn-x4v3.pth", + netscale=4, + model=lambda: SRVGGNetCompact(num_in_ch=3, num_out_ch=3, num_feat=64, num_conv=32, upscale=4, + act_type='prelu') + ), + RealesrganModelInfo( + name="Real-ESRGAN AnimeVideo", + location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-animevideov3.pth", + netscale=4, + model=lambda: SRVGGNetCompact(num_in_ch=3, num_out_ch=3, num_feat=64, num_conv=16, upscale=4, + act_type='prelu') + ), + RealesrganModelInfo( + name="Real-ESRGAN 4x plus", + location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth", + netscale=4, + model=lambda: RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32, scale=4) + ), + RealesrganModelInfo( + name="Real-ESRGAN 4x plus anime 6B", + location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth", + netscale=4, + model=lambda: RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=6, num_grow_ch=32, scale=4) + ), + RealesrganModelInfo( + name="Real-ESRGAN 2x plus", + location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.1/RealESRGAN_x2plus.pth", + netscale=2, + model=lambda: RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32, scale=2) + ), + ] + return models + except Exception as e: + print("Exception loading models: %s" % e) diff --git a/modules/shared.py b/modules/shared.py index 280d6c4c..99762f41 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -13,6 +13,7 @@ import modules.styles import modules.interrogate import modules.memmon import modules.sd_models +from modules.realesrgan_model_loader import get_realesrgan_model_names sd_model_file = os.path.join(script_path, 'model.ckpt') default_sd_model_file = sd_model_file @@ -142,6 +143,10 @@ class Options: "save_txt": OptionInfo(False, "Create a text file next to every image with generation parameters."), "ESRGAN_tile": OptionInfo(192, "Tile size for ESRGAN upscalers. 0 = no tiling.", gr.Slider, {"minimum": 0, "maximum": 512, "step": 16}), "ESRGAN_tile_overlap": OptionInfo(8, "Tile overlap, in pixels for ESRGAN upscalers. Low values = visible seam.", gr.Slider, {"minimum": 0, "maximum": 48, "step": 1}), + "realesrgan_enabled_models": OptionInfo( + ["Real-ESRGAN 2x plus", "Real-ESRGAN 4x plus", "Real-ESRGAN 4x plus anime 6B"], + "Select which RealESRGAN models to show in the web UI. (Requires restart)", + gr.CheckboxGroup, {"choices": get_realesrgan_model_names()}), "SWIN_tile": OptionInfo(192, "Tile size for all SwinIR.", gr.Slider, {"minimum": 16, "maximum": 512, "step": 16}), "SWIN_tile_overlap": OptionInfo(8, "Tile overlap, in pixels for SwinIR. Low values = visible seam.", gr.Slider, {"minimum": 0, "maximum": 48, "step": 1}), "ldsr_steps": OptionInfo(100, "LDSR processing steps. Lower = faster", From 81c7961c251c596f82536984354dada7acfcf820 Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Thu, 22 Sep 2022 07:28:19 +0300 Subject: [PATCH 11/20] revert transformers version change that prevents the program from starting. --- requirements_versions.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_versions.txt b/requirements_versions.txt index 0ab14e0c..9372cb69 100644 --- a/requirements_versions.txt +++ b/requirements_versions.txt @@ -1,4 +1,4 @@ -transformers==4.22.1 +transformers==4.19.2 diffusers==0.3.0 basicsr==1.4.2 gfpgan==1.3.8 From 3eaae8ae655346c8c510b677bd48021b86842561 Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Thu, 22 Sep 2022 07:59:27 +0300 Subject: [PATCH 12/20] reworking #775 --- modules/realesrgan_model.py | 55 +++++++++++++++++++++++--- modules/realesrgan_model_loader.py | 62 ------------------------------ modules/shared.py | 20 +++++----- 3 files changed, 59 insertions(+), 78 deletions(-) delete mode 100644 modules/realesrgan_model_loader.py diff --git a/modules/realesrgan_model.py b/modules/realesrgan_model.py index fc8623de..c32d6c4c 100644 --- a/modules/realesrgan_model.py +++ b/modules/realesrgan_model.py @@ -7,13 +7,60 @@ from PIL import Image from realesrgan import RealESRGANer import modules.images -from modules import realesrgan_model_loader from modules.shared import cmd_opts, opts RealesrganModelInfo = namedtuple("RealesrganModelInfo", ["name", "location", "model", "netscale"]) realesrgan_models = [] have_realesrgan = False -RealESRGANer_constructor = None + + +def get_realesrgan_models(): + try: + from basicsr.archs.rrdbnet_arch import RRDBNet + from realesrgan import RealESRGANer + from realesrgan.archs.srvgg_arch import SRVGGNetCompact + models = [ + RealesrganModelInfo( + name="Real-ESRGAN General x4x3", + location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-x4v3.pth", + netscale=4, + model=lambda: SRVGGNetCompact(num_in_ch=3, num_out_ch=3, num_feat=64, num_conv=32, upscale=4, act_type='prelu') + ), + RealesrganModelInfo( + name="Real-ESRGAN General WDN x4x3", + location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-wdn-x4v3.pth", + netscale=4, + model=lambda: SRVGGNetCompact(num_in_ch=3, num_out_ch=3, num_feat=64, num_conv=32, upscale=4, act_type='prelu') + ), + RealesrganModelInfo( + name="Real-ESRGAN AnimeVideo", + location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-animevideov3.pth", + netscale=4, + model=lambda: SRVGGNetCompact(num_in_ch=3, num_out_ch=3, num_feat=64, num_conv=16, upscale=4, act_type='prelu') + ), + RealesrganModelInfo( + name="Real-ESRGAN 4x plus", + location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth", + netscale=4, + model=lambda: RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32, scale=4) + ), + RealesrganModelInfo( + name="Real-ESRGAN 4x plus anime 6B", + location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth", + netscale=4, + model=lambda: RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=6, num_grow_ch=32, scale=4) + ), + RealesrganModelInfo( + name="Real-ESRGAN 2x plus", + location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.1/RealESRGAN_x2plus.pth", + netscale=2, + model=lambda: RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32, scale=2) + ), + ] + return models + except Exception as e: + print("Error makeing Real-ESRGAN midels list:", file=sys.stderr) + print(traceback.format_exc(), file=sys.stderr) class UpscalerRealESRGAN(modules.images.Upscaler): @@ -29,16 +76,14 @@ class UpscalerRealESRGAN(modules.images.Upscaler): def setup_realesrgan(): global realesrgan_models global have_realesrgan - global RealESRGANer_constructor try: from basicsr.archs.rrdbnet_arch import RRDBNet from realesrgan import RealESRGANer from realesrgan.archs.srvgg_arch import SRVGGNetCompact - realesrgan_models = realesrgan_model_loader.get_realesrgan_models() + realesrgan_models = get_realesrgan_models() have_realesrgan = True - RealESRGANer_constructor = RealESRGANer for i, model in enumerate(realesrgan_models): if model.name in opts.realesrgan_enabled_models: diff --git a/modules/realesrgan_model_loader.py b/modules/realesrgan_model_loader.py deleted file mode 100644 index 3ae3f8b7..00000000 --- a/modules/realesrgan_model_loader.py +++ /dev/null @@ -1,62 +0,0 @@ -from collections import namedtuple - -RealesrganModelInfo = namedtuple("RealesrganModelInfo", ["name", "location", "model", "netscale"]) - - -def get_realesrgan_model_names(): - names = set() - models = get_realesrgan_models() - for model in models: - names.add(model.name) - return sorted(names) - - -def get_realesrgan_models(): - try: - from basicsr.archs.rrdbnet_arch import RRDBNet - from realesrgan import RealESRGANer - from realesrgan.archs.srvgg_arch import SRVGGNetCompact - models = [ - RealesrganModelInfo( - name="Real-ESRGAN General x4x3", - location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-x4v3.pth", - netscale=4, - model=lambda: SRVGGNetCompact(num_in_ch=3, num_out_ch=3, num_feat=64, num_conv=32, upscale=4, - act_type='prelu') - ), - RealesrganModelInfo( - name="Real-ESRGAN General WDN x4x3", - location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-wdn-x4v3.pth", - netscale=4, - model=lambda: SRVGGNetCompact(num_in_ch=3, num_out_ch=3, num_feat=64, num_conv=32, upscale=4, - act_type='prelu') - ), - RealesrganModelInfo( - name="Real-ESRGAN AnimeVideo", - location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-animevideov3.pth", - netscale=4, - model=lambda: SRVGGNetCompact(num_in_ch=3, num_out_ch=3, num_feat=64, num_conv=16, upscale=4, - act_type='prelu') - ), - RealesrganModelInfo( - name="Real-ESRGAN 4x plus", - location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth", - netscale=4, - model=lambda: RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32, scale=4) - ), - RealesrganModelInfo( - name="Real-ESRGAN 4x plus anime 6B", - location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth", - netscale=4, - model=lambda: RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=6, num_grow_ch=32, scale=4) - ), - RealesrganModelInfo( - name="Real-ESRGAN 2x plus", - location="https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.1/RealESRGAN_x2plus.pth", - netscale=2, - model=lambda: RRDBNet(num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32, scale=2) - ), - ] - return models - except Exception as e: - print("Exception loading models: %s" % e) diff --git a/modules/shared.py b/modules/shared.py index 99762f41..0a852838 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -13,7 +13,6 @@ import modules.styles import modules.interrogate import modules.memmon import modules.sd_models -from modules.realesrgan_model_loader import get_realesrgan_model_names sd_model_file = os.path.join(script_path, 'model.ckpt') default_sd_model_file = sd_model_file @@ -96,6 +95,11 @@ face_restorers = [] modules.sd_models.list_models() +def realesrgan_models_names(): + import modules.realesrgan_model + return [x.name for x in modules.realesrgan_model.get_realesrgan_models()] + + class Options: class OptionInfo: def __init__(self, default=None, label="", component=None, component_args=None, onchange=None): @@ -143,18 +147,12 @@ class Options: "save_txt": OptionInfo(False, "Create a text file next to every image with generation parameters."), "ESRGAN_tile": OptionInfo(192, "Tile size for ESRGAN upscalers. 0 = no tiling.", gr.Slider, {"minimum": 0, "maximum": 512, "step": 16}), "ESRGAN_tile_overlap": OptionInfo(8, "Tile overlap, in pixels for ESRGAN upscalers. Low values = visible seam.", gr.Slider, {"minimum": 0, "maximum": 48, "step": 1}), - "realesrgan_enabled_models": OptionInfo( - ["Real-ESRGAN 2x plus", "Real-ESRGAN 4x plus", "Real-ESRGAN 4x plus anime 6B"], - "Select which RealESRGAN models to show in the web UI. (Requires restart)", - gr.CheckboxGroup, {"choices": get_realesrgan_model_names()}), + "realesrgan_enabled_models": OptionInfo(["Real-ESRGAN 4x plus", "Real-ESRGAN 4x plus anime 6B"],"Select which RealESRGAN models to show in the web UI. (Requires restart)", gr.CheckboxGroup, lambda: {"choices": realesrgan_models_names()}), "SWIN_tile": OptionInfo(192, "Tile size for all SwinIR.", gr.Slider, {"minimum": 16, "maximum": 512, "step": 16}), "SWIN_tile_overlap": OptionInfo(8, "Tile overlap, in pixels for SwinIR. Low values = visible seam.", gr.Slider, {"minimum": 0, "maximum": 48, "step": 1}), - "ldsr_steps": OptionInfo(100, "LDSR processing steps. Lower = faster", - gr.Slider, {"minimum": 1, "maximum": 200, "step": 1}), - "ldsr_pre_down":OptionInfo(1, "LDSR Pre-process downssample scale. 1 = no down-sampling, 4 = 1/4 scale.", - gr.Slider, {"minimum": 1, "maximum": 4, "step": 1}), - "ldsr_post_down":OptionInfo(1, "LDSR Post-process down-sample scale. 1 = no down-sampling, 4 = 1/4 scale.", - gr.Slider, {"minimum": 1, "maximum": 4, "step": 1}), + "ldsr_steps": OptionInfo(100, "LDSR processing steps. Lower = faster", gr.Slider, {"minimum": 1, "maximum": 200, "step": 1}), + "ldsr_pre_down":OptionInfo(1, "LDSR Pre-process downssample scale. 1 = no down-sampling, 4 = 1/4 scale.", gr.Slider, {"minimum": 1, "maximum": 4, "step": 1}), + "ldsr_post_down":OptionInfo(1, "LDSR Post-process down-sample scale. 1 = no down-sampling, 4 = 1/4 scale.", gr.Slider, {"minimum": 1, "maximum": 4, "step": 1}), "random_artist_categories": OptionInfo([], "Allowed categories for random artists selection when using the Roll button", gr.CheckboxGroup, {"choices": artist_db.categories()}), "upscale_at_full_resolution_padding": OptionInfo(16, "Inpainting at full resolution: padding, in pixels, for the masked region.", gr.Slider, {"minimum": 0, "maximum": 128, "step": 4}), "upscaler_for_hires_fix": OptionInfo(None, "Upscaler for highres. fix", gr.Radio, lambda: {"choices": [x.name for x in sd_upscalers]}), From f183e09fcc17ee28c2ede2c5f0506c630d79486e Mon Sep 17 00:00:00 2001 From: innovaciones Date: Tue, 20 Sep 2022 13:05:25 -0500 Subject: [PATCH 13/20] Fix progress bar position --- javascript/progressbar.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/javascript/progressbar.js b/javascript/progressbar.js index 065f259b..0f33851f 100644 --- a/javascript/progressbar.js +++ b/javascript/progressbar.js @@ -4,6 +4,7 @@ global_progressbar = null onUiUpdate(function(){ progressbar = gradioApp().getElementById('progressbar') + progressDiv = gradioApp().querySelectorAll('.progressDiv').length > 0; if(progressbar!= null && progressbar != global_progressbar){ global_progressbar = progressbar @@ -16,12 +17,18 @@ onUiUpdate(function(){ if(txt2img_preview != null && txt2img_gallery != null){ txt2img_preview.style.width = txt2img_gallery.clientWidth + "px" - txt2img_preview.style.height = txt2img_gallery.clientHeight + "px" + txt2img_preview.style.height = txt2img_gallery.clientHeight + "px" + if(!progressDiv){ + progressbar.style.display = "none" + } } if(img2img_preview != null && img2img_gallery != null){ img2img_preview.style.width = img2img_gallery.clientWidth + "px" - img2img_preview.style.height = img2img_gallery.clientHeight + "px" + img2img_preview.style.height = img2img_gallery.clientHeight + "px" + if(!progressDiv){ + progressbar.style.display = "none" + } } window.setTimeout(requestMoreProgress, 500) @@ -35,6 +42,10 @@ function requestMoreProgress(){ if(btn==null) return; btn.click(); + progressDiv = gradioApp().querySelectorAll('.progressDiv').length > 0; + if(progressDiv){ + progressbar.style.display = "block" + } } function requestProgress(){ @@ -43,4 +54,3 @@ function requestProgress(){ btn.click(); } - From b9aed0c692c89c61e621b3ad988cd56995ed035f Mon Sep 17 00:00:00 2001 From: innovaciones Date: Tue, 20 Sep 2022 13:06:38 -0500 Subject: [PATCH 14/20] Fix progress bar position --- style.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/style.css b/style.css index 587bcec1..98532046 100644 --- a/style.css +++ b/style.css @@ -205,9 +205,10 @@ input[type="range"]{ } #progressbar{ - position: absolute; + position: relative; z-index: 1000; right: 0; + display: none; } .progressDiv{ From 057206cb738b42dd624265b0c20505a2637d8626 Mon Sep 17 00:00:00 2001 From: innovaciones Date: Tue, 20 Sep 2022 13:16:43 -0500 Subject: [PATCH 15/20] Update progressbar.js --- javascript/progressbar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javascript/progressbar.js b/javascript/progressbar.js index 0f33851f..69ebae61 100644 --- a/javascript/progressbar.js +++ b/javascript/progressbar.js @@ -4,7 +4,7 @@ global_progressbar = null onUiUpdate(function(){ progressbar = gradioApp().getElementById('progressbar') - progressDiv = gradioApp().querySelectorAll('.progressDiv').length > 0; + progressDiv = gradioApp().querySelectorAll('.progressDiv').length > 0; if(progressbar!= null && progressbar != global_progressbar){ global_progressbar = progressbar From 12622105dc54f8904842e098a6e6dda7dace3d38 Mon Sep 17 00:00:00 2001 From: innovaciones Date: Wed, 21 Sep 2022 12:47:17 -0500 Subject: [PATCH 16/20] Use generate button as progress bar --- style.css | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/style.css b/style.css index 98532046..f493cf38 100644 --- a/style.css +++ b/style.css @@ -100,7 +100,6 @@ #toprow div{ border: none; gap: 0; - background: transparent; } #resize_mode{ @@ -205,15 +204,15 @@ input[type="range"]{ } #progressbar{ - position: relative; + position: absolute; z-index: 1000; - right: 0; + width: 100%; display: none; } .progressDiv{ width: 100%; - height: 30px; + height: 72px; background: #b4c0cc; border-radius: 8px; } @@ -224,11 +223,11 @@ input[type="range"]{ .progressDiv .progress{ width: 0%; - height: 30px; + height: 72px; background: #0060df; color: white; font-weight: bold; - line-height: 30px; + line-height: 72px; padding: 0 8px 0 0; text-align: right; border-radius: 8px; From 70e39f6cfea215197db7b1298ab4c45d5c03a40d Mon Sep 17 00:00:00 2001 From: innovaciones Date: Wed, 21 Sep 2022 12:51:23 -0500 Subject: [PATCH 17/20] Use generate button as progress bar --- modules/ui.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/ui.py b/modules/ui.py index e3cd7f3a..88b6ec30 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -350,7 +350,11 @@ def create_toprow(is_img2img): with gr.Column(scale=1): with gr.Row(): + progressbar = gr.HTML(elem_id="progressbar") submit = gr.Button('Generate', elem_id="generate", variant='primary') + + txt2img_preview = gr.Image(elem_id='txt2img_preview', visible=False) + setup_progressbar(progressbar, txt2img_preview) with gr.Row(): if is_img2img: @@ -416,14 +420,11 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo): custom_inputs = modules.scripts.scripts_txt2img.setup_ui(is_img2img=False) with gr.Column(variant='panel'): - progressbar = gr.HTML(elem_id="progressbar") with gr.Group(): txt2img_preview = gr.Image(elem_id='txt2img_preview', visible=False) txt2img_gallery = gr.Gallery(label='Output', elem_id='txt2img_gallery').style(grid=4) - setup_progressbar(progressbar, txt2img_preview) - with gr.Group(): with gr.Row(): save = gr.Button('Save') From 8af8fa20558fcdafd9fc3d1f74754b67d886957c Mon Sep 17 00:00:00 2001 From: innovaciones Date: Wed, 21 Sep 2022 20:11:04 -0500 Subject: [PATCH 18/20] New position and interrupt integration --- style.css | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/style.css b/style.css index f493cf38..8abe4c76 100644 --- a/style.css +++ b/style.css @@ -86,7 +86,7 @@ } #style_pos_col, #style_neg_col{ - min-width: 4em !important; + min-width: 8em !important; } #style_index, #style2_index{ @@ -100,6 +100,7 @@ #toprow div{ border: none; gap: 0; + background: transparent; } #resize_mode{ @@ -206,13 +207,20 @@ input[type="range"]{ #progressbar{ position: absolute; z-index: 1000; - width: 100%; - display: none; + right: 0; + padding-left: 5px; + padding-right: 5px; + display: block; +} + +#progressRow{ + margin-bottom: 10px; + margin-top: -18px; } .progressDiv{ width: 100%; - height: 72px; + height: 20px; background: #b4c0cc; border-radius: 8px; } @@ -223,11 +231,11 @@ input[type="range"]{ .progressDiv .progress{ width: 0%; - height: 72px; + height: 20px; background: #0060df; color: white; font-weight: bold; - line-height: 72px; + line-height: 20px; padding: 0 8px 0 0; text-align: right; border-radius: 8px; @@ -328,3 +336,12 @@ input[type="range"]{ .modalNext:hover { background-color: rgba(0, 0, 0, 0.8); } + +#interrupt{ + position: absolute; + width: 100%; + height: 72px; + background: #b4c0cc; + border-radius: 8px; + display: none; +} From c9ee98440bb922efffefeca20592f3fe9ebb781b Mon Sep 17 00:00:00 2001 From: innovaciones Date: Wed, 21 Sep 2022 20:11:53 -0500 Subject: [PATCH 19/20] New position and interrupt integration --- javascript/progressbar.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/javascript/progressbar.js b/javascript/progressbar.js index 69ebae61..20b4dc62 100644 --- a/javascript/progressbar.js +++ b/javascript/progressbar.js @@ -1,17 +1,16 @@ // code related to showing and updating progressbar shown as the image is being made - global_progressbar = null onUiUpdate(function(){ - progressbar = gradioApp().getElementById('progressbar') - progressDiv = gradioApp().querySelectorAll('.progressDiv').length > 0; + progressbar = gradioApp().getElementById('progressbar') + progressDiv = gradioApp().querySelectorAll('.progressDiv').length > 0; + interrupt = gradioApp().getElementById('interrupt') if(progressbar!= null && progressbar != global_progressbar){ global_progressbar = progressbar var mutationObserver = new MutationObserver(function(m){ txt2img_preview = gradioApp().getElementById('txt2img_preview') txt2img_gallery = gradioApp().getElementById('txt2img_gallery') - img2img_preview = gradioApp().getElementById('img2img_preview') img2img_gallery = gradioApp().getElementById('img2img_gallery') @@ -19,7 +18,7 @@ onUiUpdate(function(){ txt2img_preview.style.width = txt2img_gallery.clientWidth + "px" txt2img_preview.style.height = txt2img_gallery.clientHeight + "px" if(!progressDiv){ - progressbar.style.display = "none" + interrupt.style.display = "none" } } @@ -27,7 +26,7 @@ onUiUpdate(function(){ img2img_preview.style.width = img2img_gallery.clientWidth + "px" img2img_preview.style.height = img2img_gallery.clientHeight + "px" if(!progressDiv){ - progressbar.style.display = "none" + interrupt.style.display = "none" } } @@ -36,7 +35,6 @@ onUiUpdate(function(){ mutationObserver.observe( progressbar, { childList:true, subtree:true }) } }) - function requestMoreProgress(){ btn = gradioApp().getElementById("check_progress"); if(btn==null) return; @@ -44,7 +42,7 @@ function requestMoreProgress(){ btn.click(); progressDiv = gradioApp().querySelectorAll('.progressDiv').length > 0; if(progressDiv){ - progressbar.style.display = "block" + interrupt.style.display = "block" } } From aa1d1bf44ece3f0495873fc3129d2dba664f8c2f Mon Sep 17 00:00:00 2001 From: innovaciones Date: Wed, 21 Sep 2022 20:12:39 -0500 Subject: [PATCH 20/20] New position and interrupt integration --- modules/ui.py | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/modules/ui.py b/modules/ui.py index 88b6ec30..572dcfb9 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -350,11 +350,14 @@ def create_toprow(is_img2img): with gr.Column(scale=1): with gr.Row(): - progressbar = gr.HTML(elem_id="progressbar") + interrupt = gr.Button('Interrupt', elem_id="interrupt") submit = gr.Button('Generate', elem_id="generate", variant='primary') - - txt2img_preview = gr.Image(elem_id='txt2img_preview', visible=False) - setup_progressbar(progressbar, txt2img_preview) + + interrupt.click( + fn=lambda: shared.state.interrupt(), + inputs=[], + outputs=[], + ) with gr.Row(): if is_img2img: @@ -390,6 +393,15 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo): txt2img_prompt, roll, txt2img_prompt_style, txt2img_negative_prompt, txt2img_prompt_style2, submit, _, txt2img_prompt_style_apply, txt2img_save_style = create_toprow(is_img2img=False) dummy_component = gr.Label(visible=False) + with gr.Row(elem_id='progressRow'): + with gr.Column(scale=1): + columnEmpty = "Empty" + + with gr.Column(scale=1): + progressbar = gr.HTML(elem_id="progressbar") + txt2img_preview = gr.Image(elem_id='txt2img_preview', visible=False) + setup_progressbar(progressbar, txt2img_preview) + with gr.Row().style(equal_height=False): with gr.Column(variant='panel'): steps = gr.Slider(minimum=1, maximum=150, step=1, label="Sampling Steps", value=20) @@ -431,7 +443,6 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo): send_to_img2img = gr.Button('Send to img2img') send_to_inpaint = gr.Button('Send to inpaint') send_to_extras = gr.Button('Send to extras') - interrupt = gr.Button('Interrupt') with gr.Group(): html_info = gr.HTML() @@ -480,12 +491,6 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo): outputs=[hr_options], ) - interrupt.click( - fn=lambda: shared.state.interrupt(), - inputs=[], - outputs=[], - ) - save.click( fn=wrap_gradio_call(save_files), _js="(x, y, z) => [x, y, selected_gallery_index()]", @@ -514,6 +519,15 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo): with gr.Blocks(analytics_enabled=False) as img2img_interface: img2img_prompt, roll, img2img_prompt_style, img2img_negative_prompt, img2img_prompt_style2, submit, img2img_interrogate, img2img_prompt_style_apply, img2img_save_style = create_toprow(is_img2img=True) + with gr.Row(elem_id='progressRow'): + with gr.Column(scale=1): + columnEmpty = "Empty" + + with gr.Column(scale=1): + progressbar = gr.HTML(elem_id="progressbar") + img2img_preview = gr.Image(elem_id='img2img_preview', visible=False) + setup_progressbar(progressbar, img2img_preview) + with gr.Row().style(equal_height=False): with gr.Column(variant='panel'): with gr.Group(): @@ -562,21 +576,17 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo): custom_inputs = modules.scripts.scripts_img2img.setup_ui(is_img2img=True) with gr.Column(variant='panel'): - progressbar = gr.HTML(elem_id="progressbar") with gr.Group(): img2img_preview = gr.Image(elem_id='img2img_preview', visible=False) img2img_gallery = gr.Gallery(label='Output', elem_id='img2img_gallery').style(grid=4) - setup_progressbar(progressbar, img2img_preview) - with gr.Group(): with gr.Row(): save = gr.Button('Save') img2img_send_to_img2img = gr.Button('Send to img2img') img2img_send_to_inpaint = gr.Button('Send to inpaint') img2img_send_to_extras = gr.Button('Send to extras') - interrupt = gr.Button('Interrupt') img2img_save_style = gr.Button('Save prompt as style') @@ -690,12 +700,6 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo): outputs=[img2img_prompt], ) - interrupt.click( - fn=lambda: shared.state.interrupt(), - inputs=[], - outputs=[], - ) - save.click( fn=wrap_gradio_call(save_files), _js="(x, y, z) => [x, y, selected_gallery_index()]",