aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/ISSUE_TEMPLATE/bug_report.md2
-rw-r--r--.gitignore1
-rw-r--r--javascript/progressbar.js4
-rw-r--r--modules/gfpgan_model.py19
-rw-r--r--modules/shared.py24
-rw-r--r--modules/ui.py20
-rw-r--r--webui.py1
7 files changed, 58 insertions, 13 deletions
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index 21accbf0..50c54210 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -2,7 +2,7 @@
name: Bug report
about: Create a report to help us improve
title: ''
-labels: bug
+labels: bug-report
assignees: ''
---
diff --git a/.gitignore b/.gitignore
index 18017239..9d78853a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,7 @@ __pycache__
/model.ckpt
/models/*.ckpt
/GFPGANv1.3.pth
+/gfpgan/weights/*.pth
/ui-config.json
/outputs
/config.json
diff --git a/javascript/progressbar.js b/javascript/progressbar.js
index 20b4dc62..ce0f0df3 100644
--- a/javascript/progressbar.js
+++ b/javascript/progressbar.js
@@ -3,7 +3,7 @@ global_progressbar = null
onUiUpdate(function(){
progressbar = gradioApp().getElementById('progressbar')
- progressDiv = gradioApp().querySelectorAll('.progressDiv').length > 0;
+ progressDiv = gradioApp().querySelectorAll('#progressSpan').length > 0;
interrupt = gradioApp().getElementById('interrupt')
if(progressbar!= null && progressbar != global_progressbar){
global_progressbar = progressbar
@@ -40,7 +40,7 @@ function requestMoreProgress(){
if(btn==null) return;
btn.click();
- progressDiv = gradioApp().querySelectorAll('.progressDiv').length > 0;
+ progressDiv = gradioApp().querySelectorAll('#progressSpan').length > 0;
if(progressDiv){
interrupt.style.display = "block"
}
diff --git a/modules/gfpgan_model.py b/modules/gfpgan_model.py
index 0af97123..44c5dc6c 100644
--- a/modules/gfpgan_model.py
+++ b/modules/gfpgan_model.py
@@ -1,6 +1,7 @@
import os
import sys
import traceback
+from glob import glob
from modules import shared, devices
from modules.shared import cmd_opts
@@ -11,14 +12,20 @@ import modules.face_restoration
def gfpgan_model_path():
from modules.shared import cmd_opts
+ filemask = 'GFPGAN*.pth'
+
+ if cmd_opts.gfpgan_model is not None:
+ return cmd_opts.gfpgan_model
+
places = [script_path, '.', os.path.join(cmd_opts.gfpgan_dir, 'experiments/pretrained_models')]
- files = [cmd_opts.gfpgan_model] + [os.path.join(dirname, cmd_opts.gfpgan_model) for dirname in places]
- found = [x for x in files if os.path.exists(x)]
- if len(found) == 0:
- raise Exception("GFPGAN model not found in paths: " + ", ".join(files))
+ filename = None
+ for place in places:
+ filename = next(iter(glob(os.path.join(place, filemask))), None)
+ if filename is not None:
+ break
- return found[0]
+ return filename
loaded_gfpgan_model = None
@@ -34,7 +41,7 @@ def gfpgan():
if gfpgan_constructor is None:
return None
- model = gfpgan_constructor(model_path=gfpgan_model_path(), upscale=1, arch='clean', channel_multiplier=2, bg_upsampler=None)
+ model = gfpgan_constructor(model_path=gfpgan_model_path() or 'https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.4.pth', upscale=1, arch='clean', channel_multiplier=2, bg_upsampler=None)
model.gfpgan.to(shared.device)
loaded_gfpgan_model = model
diff --git a/modules/shared.py b/modules/shared.py
index b712f20e..0978f3f6 100644
--- a/modules/shared.py
+++ b/modules/shared.py
@@ -2,7 +2,6 @@ import sys
import argparse
import json
import os
-from glob import glob
import gradio as gr
import tqdm
@@ -22,7 +21,7 @@ parser.add_argument("--config", type=str, default=os.path.join(sd_path, "configs
parser.add_argument("--ckpt", type=str, default=sd_model_file, help="path to checkpoint of stable diffusion model; this checkpoint will be added to the list of checkpoints and loaded by default if you don't have a checkpoint selected in settings",)
parser.add_argument("--ckpt-dir", type=str, default=os.path.join(script_path, 'models'), help="path to directory with stable diffusion checkpoints",)
parser.add_argument("--gfpgan-dir", type=str, help="GFPGAN directory", default=('./src/gfpgan' if os.path.exists('./src/gfpgan') else './GFPGAN'))
-parser.add_argument("--gfpgan-model", type=str, help="GFPGAN model file name", default=next(iter(glob('GFPGAN*.pth')), ''))
+parser.add_argument("--gfpgan-model", type=str, help="GFPGAN model file name", default=None)
parser.add_argument("--no-half", action='store_true', help="do not switch the model to 16-bit floats")
parser.add_argument("--no-progressbar-hiding", action='store_true', help="do not hide progressbar in gradio UI (we hide it because it slows down ML if you have hardware acceleration in browser)")
parser.add_argument("--max-batch-count", type=int, default=16, help="maximum batch count value for the UI")
@@ -249,6 +248,27 @@ class Options:
with open(filename, "r", encoding="utf8") as file:
self.data = json.load(file)
+ typemap = {int: float}
+
+ def same_type(x, y):
+ if x is None or y is None:
+ return True
+
+ type_x = typemap.get(type(x), type(x))
+ type_y = typemap.get(type(y), type(y))
+
+ return type_x == type_y
+
+ bad_settings = 0
+ for k, v in self.data.items():
+ info = self.data_labels.get(k, None)
+ if info is not None and not same_type(info.default, v):
+ print(f"Warning: bad setting value: {k}: {v} ({type(v).__name__}; expected {type(info.default).__name__})", file=sys.stderr)
+ bad_settings += 1
+
+ if bad_settings > 0:
+ print(f"The program is likely to not work with bad settings.\nSettings file: {filename}\nEither fix the file, or delete it and restart.", file=sys.stderr)
+
def onchange(self, key, func):
item = self.data_labels.get(key)
item.onchange = func
diff --git a/modules/ui.py b/modules/ui.py
index 036f2ed3..3f92efc6 100644
--- a/modules/ui.py
+++ b/modules/ui.py
@@ -200,7 +200,7 @@ def check_progress_call():
else:
preview_visibility = gr_show(True)
- return f"<span style='display: none'>{time.time()}</span><p>{progressbar}</p>", preview_visibility, image
+ return f"<span id='progressSpan' style='display: none'>{time.time()}</span><p>{progressbar}</p>", preview_visibility, image
def check_progress_call_initial():
@@ -752,6 +752,8 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
result_images = gr.Gallery(label="Result", show_label=False)
html_info_x = gr.HTML()
html_info = gr.HTML()
+ extras_send_to_img2img = gr.Button('Send to img2img')
+ extras_send_to_inpaint = gr.Button('Send to inpaint')
submit.click(
fn=run_extras,
@@ -774,6 +776,20 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
html_info,
]
)
+
+ extras_send_to_img2img.click(
+ fn=lambda x: image_from_url_text(x),
+ _js="extract_image_from_gallery_img2img",
+ inputs=[result_images],
+ outputs=[init_img],
+ )
+
+ extras_send_to_inpaint.click(
+ fn=lambda x: image_from_url_text(x),
+ _js="extract_image_from_gallery_img2img",
+ inputs=[result_images],
+ outputs=[init_img_with_mask],
+ )
pnginfo_interface = gr.Interface(
wrap_gradio_call(run_pnginfo),
@@ -1019,7 +1035,7 @@ with open(os.path.join(script_path, "script.js"), "r", encoding="utf8") as jsfil
javascript = f'<script>{jsfile.read()}</script>'
jsdir = os.path.join(script_path, "javascript")
-for filename in os.listdir(jsdir):
+for filename in sorted(os.listdir(jsdir)):
with open(os.path.join(jsdir, filename), "r", encoding="utf8") as jsfile:
javascript += f"\n<script>{jsfile.read()}</script>"
diff --git a/webui.py b/webui.py
index a23d65a1..64c9d462 100644
--- a/webui.py
+++ b/webui.py
@@ -53,6 +53,7 @@ def wrap_gradio_gpu_call(func):
shared.state.current_latent = None
shared.state.current_image = None
shared.state.current_image_sampling_step = 0
+ shared.state.interrupted = False
with queue_lock:
res = func(*args, **kwargs)