Spaces:
Runtime error
Runtime error
Upload 17 files
Browse files- .gitignore +28 -0
- artists.csv +0 -0
- environment-wsl2.yaml +11 -0
- launch.py +152 -0
- requirements.txt +25 -0
- requirements_versions.txt +24 -0
- screenshot.png +0 -0
- script.js +62 -0
- style.css +413 -0
- txt2img_Screenshot.png +0 -0
- webui-user.bat +8 -0
- webui-user.sh +43 -0
- webui.bat +62 -0
- webui.py +124 -0
- webui.sh +141 -0
.gitignore
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
__pycache__
|
2 |
+
*.ckpt
|
3 |
+
*.pth
|
4 |
+
/ESRGAN/*
|
5 |
+
/SwinIR/*
|
6 |
+
/repositories
|
7 |
+
/venv
|
8 |
+
/tmp
|
9 |
+
/model.ckpt
|
10 |
+
/models/**/*
|
11 |
+
/GFPGANv1.3.pth
|
12 |
+
/gfpgan/weights/*.pth
|
13 |
+
/ui-config.json
|
14 |
+
/outputs
|
15 |
+
/config.json
|
16 |
+
/log
|
17 |
+
/webui.settings.bat
|
18 |
+
/embeddings
|
19 |
+
/styles.csv
|
20 |
+
/styles.csv.bak
|
21 |
+
/webui-user.bat
|
22 |
+
/webui-user.sh
|
23 |
+
/interrogate
|
24 |
+
/user.css
|
25 |
+
/.idea
|
26 |
+
notification.mp3
|
27 |
+
/SwinIR
|
28 |
+
/textual_inversion
|
artists.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
environment-wsl2.yaml
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: automatic
|
2 |
+
channels:
|
3 |
+
- pytorch
|
4 |
+
- defaults
|
5 |
+
dependencies:
|
6 |
+
- python=3.8.5
|
7 |
+
- pip=20.3
|
8 |
+
- cudatoolkit=11.3
|
9 |
+
- pytorch=1.11.0
|
10 |
+
- torchvision=0.12.0
|
11 |
+
- numpy=1.19.2
|
launch.py
ADDED
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# this scripts installs necessary requirements and launches main program in webui.py
|
2 |
+
import subprocess
|
3 |
+
import os
|
4 |
+
import sys
|
5 |
+
import importlib.util
|
6 |
+
import shlex
|
7 |
+
|
8 |
+
dir_repos = "repositories"
|
9 |
+
dir_tmp = "tmp"
|
10 |
+
|
11 |
+
python = sys.executable
|
12 |
+
git = os.environ.get('GIT', "git")
|
13 |
+
torch_command = os.environ.get('TORCH_COMMAND', "pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 --extra-index-url https://download.pytorch.org/whl/cu113")
|
14 |
+
requirements_file = os.environ.get('REQS_FILE', "requirements_versions.txt")
|
15 |
+
commandline_args = os.environ.get('COMMANDLINE_ARGS', "")
|
16 |
+
|
17 |
+
gfpgan_package = os.environ.get('GFPGAN_PACKAGE', "git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379")
|
18 |
+
clip_package = os.environ.get('CLIP_PACKAGE', "git+https://github.com/openai/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e4823fc8e1")
|
19 |
+
|
20 |
+
stable_diffusion_commit_hash = os.environ.get('STABLE_DIFFUSION_COMMIT_HASH', "69ae4b35e0a0f6ee1af8bb9a5d0016ccb27e36dc")
|
21 |
+
taming_transformers_commit_hash = os.environ.get('TAMING_TRANSFORMERS_COMMIT_HASH', "24268930bf1dce879235a7fddd0b2355b84d7ea6")
|
22 |
+
k_diffusion_commit_hash = os.environ.get('K_DIFFUSION_COMMIT_HASH', "f4e99857772fc3a126ba886aadf795a332774878")
|
23 |
+
codeformer_commit_hash = os.environ.get('CODEFORMER_COMMIT_HASH', "c5b4593074ba6214284d6acd5f1719b6c5d739af")
|
24 |
+
blip_commit_hash = os.environ.get('BLIP_COMMIT_HASH', "48211a1594f1321b00f14c9f7a5b4813144b2fb9")
|
25 |
+
|
26 |
+
args = shlex.split(commandline_args)
|
27 |
+
|
28 |
+
|
29 |
+
def extract_arg(args, name):
|
30 |
+
return [x for x in args if x != name], name in args
|
31 |
+
|
32 |
+
|
33 |
+
args, skip_torch_cuda_test = extract_arg(args, '--skip-torch-cuda-test')
|
34 |
+
|
35 |
+
|
36 |
+
def repo_dir(name):
|
37 |
+
return os.path.join(dir_repos, name)
|
38 |
+
|
39 |
+
|
40 |
+
def run(command, desc=None, errdesc=None):
|
41 |
+
if desc is not None:
|
42 |
+
print(desc)
|
43 |
+
|
44 |
+
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
45 |
+
|
46 |
+
if result.returncode != 0:
|
47 |
+
|
48 |
+
message = f"""{errdesc or 'Error running command'}.
|
49 |
+
Command: {command}
|
50 |
+
Error code: {result.returncode}
|
51 |
+
stdout: {result.stdout.decode(encoding="utf8", errors="ignore") if len(result.stdout)>0 else '<empty>'}
|
52 |
+
stderr: {result.stderr.decode(encoding="utf8", errors="ignore") if len(result.stderr)>0 else '<empty>'}
|
53 |
+
"""
|
54 |
+
raise RuntimeError(message)
|
55 |
+
|
56 |
+
return result.stdout.decode(encoding="utf8", errors="ignore")
|
57 |
+
|
58 |
+
|
59 |
+
def run_python(code, desc=None, errdesc=None):
|
60 |
+
return run(f'"{python}" -c "{code}"', desc, errdesc)
|
61 |
+
|
62 |
+
|
63 |
+
def run_pip(args, desc=None):
|
64 |
+
return run(f'"{python}" -m pip {args} --prefer-binary', desc=f"Installing {desc}", errdesc=f"Couldn't install {desc}")
|
65 |
+
|
66 |
+
|
67 |
+
def check_run(command):
|
68 |
+
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
69 |
+
return result.returncode == 0
|
70 |
+
|
71 |
+
|
72 |
+
def check_run_python(code):
|
73 |
+
return check_run(f'"{python}" -c "{code}"')
|
74 |
+
|
75 |
+
|
76 |
+
def is_installed(package):
|
77 |
+
try:
|
78 |
+
spec = importlib.util.find_spec(package)
|
79 |
+
except ModuleNotFoundError:
|
80 |
+
return False
|
81 |
+
|
82 |
+
return spec is not None
|
83 |
+
|
84 |
+
|
85 |
+
def git_clone(url, dir, name, commithash=None):
|
86 |
+
# TODO clone into temporary dir and move if successful
|
87 |
+
|
88 |
+
if os.path.exists(dir):
|
89 |
+
if commithash is None:
|
90 |
+
return
|
91 |
+
|
92 |
+
current_hash = run(f'"{git}" -C {dir} rev-parse HEAD', None, f"Couldn't determine {name}'s hash: {commithash}").strip()
|
93 |
+
if current_hash == commithash:
|
94 |
+
return
|
95 |
+
|
96 |
+
run(f'"{git}" -C {dir} fetch', f"Fetching updates for {name}...", f"Couldn't fetch {name}")
|
97 |
+
run(f'"{git}" -C {dir} checkout {commithash}', f"Checking out commint for {name} with hash: {commithash}...", f"Couldn't checkout commit {commithash} for {name}")
|
98 |
+
return
|
99 |
+
|
100 |
+
run(f'"{git}" clone "{url}" "{dir}"', f"Cloning {name} into {dir}...", f"Couldn't clone {name}")
|
101 |
+
|
102 |
+
if commithash is not None:
|
103 |
+
run(f'"{git}" -C {dir} checkout {commithash}', None, "Couldn't checkout {name}'s hash: {commithash}")
|
104 |
+
|
105 |
+
|
106 |
+
try:
|
107 |
+
commit = run(f"{git} rev-parse HEAD").strip()
|
108 |
+
except Exception:
|
109 |
+
commit = "<none>"
|
110 |
+
|
111 |
+
print(f"Python {sys.version}")
|
112 |
+
print(f"Commit hash: {commit}")
|
113 |
+
|
114 |
+
|
115 |
+
if not is_installed("torch") or not is_installed("torchvision"):
|
116 |
+
run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch")
|
117 |
+
|
118 |
+
if not skip_torch_cuda_test:
|
119 |
+
run_python("import torch; assert torch.cuda.is_available(), 'Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check'")
|
120 |
+
|
121 |
+
if not is_installed("gfpgan"):
|
122 |
+
run_pip(f"install {gfpgan_package}", "gfpgan")
|
123 |
+
|
124 |
+
if not is_installed("clip"):
|
125 |
+
run_pip(f"install {clip_package}", "clip")
|
126 |
+
|
127 |
+
os.makedirs(dir_repos, exist_ok=True)
|
128 |
+
|
129 |
+
git_clone("https://github.com/CompVis/stable-diffusion.git", repo_dir('stable-diffusion'), "Stable Diffusion", stable_diffusion_commit_hash)
|
130 |
+
git_clone("https://github.com/CompVis/taming-transformers.git", repo_dir('taming-transformers'), "Taming Transformers", taming_transformers_commit_hash)
|
131 |
+
git_clone("https://github.com/crowsonkb/k-diffusion.git", repo_dir('k-diffusion'), "K-diffusion", k_diffusion_commit_hash)
|
132 |
+
git_clone("https://github.com/sczhou/CodeFormer.git", repo_dir('CodeFormer'), "CodeFormer", codeformer_commit_hash)
|
133 |
+
git_clone("https://github.com/salesforce/BLIP.git", repo_dir('BLIP'), "BLIP", blip_commit_hash)
|
134 |
+
|
135 |
+
if not is_installed("lpips"):
|
136 |
+
run_pip(f"install -r {os.path.join(repo_dir('CodeFormer'), 'requirements.txt')}", "requirements for CodeFormer")
|
137 |
+
|
138 |
+
run_pip(f"install -r {requirements_file}", "requirements for Web UI")
|
139 |
+
|
140 |
+
sys.argv += args
|
141 |
+
|
142 |
+
if "--exit" in args:
|
143 |
+
print("Exiting because of --exit argument")
|
144 |
+
exit(0)
|
145 |
+
|
146 |
+
def start_webui():
|
147 |
+
print(f"Launching Web UI with arguments: {' '.join(sys.argv[1:])}")
|
148 |
+
import webui
|
149 |
+
webui.webui()
|
150 |
+
|
151 |
+
if __name__ == "__main__":
|
152 |
+
start_webui()
|
requirements.txt
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
basicsr
|
2 |
+
diffusers
|
3 |
+
fairscale==0.4.4
|
4 |
+
fonts
|
5 |
+
font-roboto
|
6 |
+
gfpgan
|
7 |
+
gradio==3.4b3
|
8 |
+
invisible-watermark
|
9 |
+
numpy
|
10 |
+
omegaconf
|
11 |
+
piexif
|
12 |
+
Pillow
|
13 |
+
pytorch_lightning
|
14 |
+
realesrgan
|
15 |
+
scikit-image>=0.19
|
16 |
+
timm==0.4.12
|
17 |
+
transformers==4.19.2
|
18 |
+
torch
|
19 |
+
einops
|
20 |
+
jsonmerge
|
21 |
+
clean-fid
|
22 |
+
resize-right
|
23 |
+
torchdiffeq
|
24 |
+
kornia
|
25 |
+
lark
|
requirements_versions.txt
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
transformers==4.19.2
|
2 |
+
diffusers==0.3.0
|
3 |
+
basicsr==1.4.2
|
4 |
+
gfpgan==1.3.8
|
5 |
+
gradio==3.4b3
|
6 |
+
numpy==1.23.3
|
7 |
+
Pillow==9.2.0
|
8 |
+
realesrgan==0.3.0
|
9 |
+
torch
|
10 |
+
omegaconf==2.2.3
|
11 |
+
pytorch_lightning==1.7.6
|
12 |
+
scikit-image==0.19.2
|
13 |
+
fonts
|
14 |
+
font-roboto
|
15 |
+
timm==0.6.7
|
16 |
+
fairscale==0.4.9
|
17 |
+
piexif==1.1.3
|
18 |
+
einops==0.4.1
|
19 |
+
jsonmerge==1.8.0
|
20 |
+
clean-fid==0.1.29
|
21 |
+
resize-right==0.0.2
|
22 |
+
torchdiffeq==0.2.3
|
23 |
+
kornia==0.6.7
|
24 |
+
lark==1.1.2
|
screenshot.png
ADDED
script.js
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function gradioApp(){
|
2 |
+
return document.getElementsByTagName('gradio-app')[0].shadowRoot;
|
3 |
+
}
|
4 |
+
|
5 |
+
function get_uiCurrentTab() {
|
6 |
+
return gradioApp().querySelector('.tabs button:not(.border-transparent)')
|
7 |
+
}
|
8 |
+
|
9 |
+
uiUpdateCallbacks = []
|
10 |
+
uiTabChangeCallbacks = []
|
11 |
+
let uiCurrentTab = null
|
12 |
+
|
13 |
+
function onUiUpdate(callback){
|
14 |
+
uiUpdateCallbacks.push(callback)
|
15 |
+
}
|
16 |
+
function onUiTabChange(callback){
|
17 |
+
uiTabChangeCallbacks.push(callback)
|
18 |
+
}
|
19 |
+
|
20 |
+
function runCallback(x){
|
21 |
+
try {
|
22 |
+
x()
|
23 |
+
} catch (e) {
|
24 |
+
(console.error || console.log).call(console, e.message, e);
|
25 |
+
}
|
26 |
+
}
|
27 |
+
function executeCallbacks(queue) {
|
28 |
+
queue.forEach(runCallback)
|
29 |
+
}
|
30 |
+
|
31 |
+
document.addEventListener("DOMContentLoaded", function() {
|
32 |
+
var mutationObserver = new MutationObserver(function(m){
|
33 |
+
executeCallbacks(uiUpdateCallbacks);
|
34 |
+
const newTab = get_uiCurrentTab();
|
35 |
+
if ( newTab && ( newTab !== uiCurrentTab ) ) {
|
36 |
+
uiCurrentTab = newTab;
|
37 |
+
executeCallbacks(uiTabChangeCallbacks);
|
38 |
+
}
|
39 |
+
});
|
40 |
+
mutationObserver.observe( gradioApp(), { childList:true, subtree:true })
|
41 |
+
});
|
42 |
+
|
43 |
+
/**
|
44 |
+
* checks that a UI element is not in another hidden element or tab content
|
45 |
+
*/
|
46 |
+
function uiElementIsVisible(el) {
|
47 |
+
let isVisible = !el.closest('.\\!hidden');
|
48 |
+
if ( ! isVisible ) {
|
49 |
+
return false;
|
50 |
+
}
|
51 |
+
|
52 |
+
while( isVisible = el.closest('.tabitem')?.style.display !== 'none' ) {
|
53 |
+
if ( ! isVisible ) {
|
54 |
+
return false;
|
55 |
+
} else if ( el.parentElement ) {
|
56 |
+
el = el.parentElement
|
57 |
+
} else {
|
58 |
+
break;
|
59 |
+
}
|
60 |
+
}
|
61 |
+
return isVisible;
|
62 |
+
}
|
style.css
ADDED
@@ -0,0 +1,413 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.output-html p {margin: 0 0.5em;}
|
2 |
+
|
3 |
+
.row > *,
|
4 |
+
.row > .gr-form > * {
|
5 |
+
min-width: min(120px, 100%);
|
6 |
+
flex: 1 1 0%;
|
7 |
+
}
|
8 |
+
|
9 |
+
.performance {
|
10 |
+
font-size: 0.85em;
|
11 |
+
color: #444;
|
12 |
+
display: flex;
|
13 |
+
justify-content: space-between;
|
14 |
+
white-space: nowrap;
|
15 |
+
}
|
16 |
+
|
17 |
+
.performance .time {
|
18 |
+
margin-right: 0;
|
19 |
+
}
|
20 |
+
|
21 |
+
.performance .vram {
|
22 |
+
margin-left: 0;
|
23 |
+
text-align: right;
|
24 |
+
}
|
25 |
+
|
26 |
+
#txt2img_generate, #img2img_generate {
|
27 |
+
min-height: 4.5em;
|
28 |
+
}
|
29 |
+
|
30 |
+
@media screen and (min-width: 2500px) {
|
31 |
+
#txt2img_gallery, #img2img_gallery {
|
32 |
+
min-height: 768px;
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
#txt2img_gallery img, #img2img_gallery img{
|
37 |
+
object-fit: scale-down;
|
38 |
+
}
|
39 |
+
|
40 |
+
.justify-center.overflow-x-scroll {
|
41 |
+
justify-content: left;
|
42 |
+
}
|
43 |
+
|
44 |
+
.justify-center.overflow-x-scroll button:first-of-type {
|
45 |
+
margin-left: auto;
|
46 |
+
}
|
47 |
+
|
48 |
+
.justify-center.overflow-x-scroll button:last-of-type {
|
49 |
+
margin-right: auto;
|
50 |
+
}
|
51 |
+
|
52 |
+
#random_seed, #random_subseed, #reuse_seed, #reuse_subseed, #open_folder{
|
53 |
+
min-width: auto;
|
54 |
+
flex-grow: 0;
|
55 |
+
padding-left: 0.25em;
|
56 |
+
padding-right: 0.25em;
|
57 |
+
}
|
58 |
+
|
59 |
+
#hidden_element{
|
60 |
+
display: none;
|
61 |
+
}
|
62 |
+
|
63 |
+
#seed_row, #subseed_row{
|
64 |
+
gap: 0.5rem;
|
65 |
+
}
|
66 |
+
|
67 |
+
#subseed_show_box{
|
68 |
+
min-width: auto;
|
69 |
+
flex-grow: 0;
|
70 |
+
}
|
71 |
+
|
72 |
+
#subseed_show_box > div{
|
73 |
+
border: 0;
|
74 |
+
height: 100%;
|
75 |
+
}
|
76 |
+
|
77 |
+
#subseed_show{
|
78 |
+
min-width: auto;
|
79 |
+
flex-grow: 0;
|
80 |
+
padding: 0;
|
81 |
+
}
|
82 |
+
|
83 |
+
#subseed_show label{
|
84 |
+
height: 100%;
|
85 |
+
}
|
86 |
+
|
87 |
+
#roll_col{
|
88 |
+
min-width: unset !important;
|
89 |
+
flex-grow: 0 !important;
|
90 |
+
padding: 0.4em 0;
|
91 |
+
}
|
92 |
+
|
93 |
+
#roll, #paste{
|
94 |
+
min-width: 2em;
|
95 |
+
min-height: 2em;
|
96 |
+
max-width: 2em;
|
97 |
+
max-height: 2em;
|
98 |
+
flex-grow: 0;
|
99 |
+
padding-left: 0.25em;
|
100 |
+
padding-right: 0.25em;
|
101 |
+
margin: 0.1em 0;
|
102 |
+
}
|
103 |
+
|
104 |
+
#style_apply, #style_create, #interrogate{
|
105 |
+
margin: 0.75em 0.25em 0.25em 0.25em;
|
106 |
+
min-width: 3em;
|
107 |
+
}
|
108 |
+
|
109 |
+
#style_pos_col, #style_neg_col{
|
110 |
+
min-width: 8em !important;
|
111 |
+
}
|
112 |
+
|
113 |
+
#txt2img_style_index, #txt2img_style2_index, #img2img_style_index, #img2img_style2_index{
|
114 |
+
margin-top: 1em;
|
115 |
+
}
|
116 |
+
|
117 |
+
.gr-form{
|
118 |
+
background: transparent;
|
119 |
+
}
|
120 |
+
|
121 |
+
.my-4{
|
122 |
+
margin-top: 0;
|
123 |
+
margin-bottom: 0;
|
124 |
+
}
|
125 |
+
|
126 |
+
#toprow div{
|
127 |
+
border: none;
|
128 |
+
gap: 0;
|
129 |
+
background: transparent;
|
130 |
+
}
|
131 |
+
|
132 |
+
#resize_mode{
|
133 |
+
flex: 1.5;
|
134 |
+
}
|
135 |
+
|
136 |
+
button{
|
137 |
+
align-self: stretch !important;
|
138 |
+
}
|
139 |
+
|
140 |
+
#prompt, #negative_prompt{
|
141 |
+
border: none !important;
|
142 |
+
}
|
143 |
+
#prompt textarea, #negative_prompt textarea{
|
144 |
+
border: none !important;
|
145 |
+
}
|
146 |
+
|
147 |
+
|
148 |
+
#img2maskimg .h-60{
|
149 |
+
height: 30rem;
|
150 |
+
}
|
151 |
+
|
152 |
+
.overflow-hidden, .gr-panel{
|
153 |
+
overflow: visible !important;
|
154 |
+
}
|
155 |
+
|
156 |
+
#x_type, #y_type{
|
157 |
+
max-width: 10em;
|
158 |
+
}
|
159 |
+
|
160 |
+
#txt2img_preview, #img2img_preview, #ti_preview{
|
161 |
+
position: absolute;
|
162 |
+
width: 320px;
|
163 |
+
left: 0;
|
164 |
+
right: 0;
|
165 |
+
margin-left: auto;
|
166 |
+
margin-right: auto;
|
167 |
+
margin-top: 34px;
|
168 |
+
z-index: 100;
|
169 |
+
border: none;
|
170 |
+
border-top-left-radius: 0;
|
171 |
+
border-top-right-radius: 0;
|
172 |
+
}
|
173 |
+
|
174 |
+
@media screen and (min-width: 768px) {
|
175 |
+
#txt2img_preview, #img2img_preview, #ti_preview {
|
176 |
+
position: absolute;
|
177 |
+
}
|
178 |
+
}
|
179 |
+
|
180 |
+
@media screen and (max-width: 767px) {
|
181 |
+
#txt2img_preview, #img2img_preview, #ti_preview {
|
182 |
+
position: relative;
|
183 |
+
}
|
184 |
+
}
|
185 |
+
|
186 |
+
#txt2img_preview div.left-0.top-0, #img2img_preview div.left-0.top-0, #ti_preview div.left-0.top-0{
|
187 |
+
display: none;
|
188 |
+
}
|
189 |
+
|
190 |
+
fieldset span.text-gray-500, .gr-block.gr-box span.text-gray-500, label.block span{
|
191 |
+
position: absolute;
|
192 |
+
top: -0.6em;
|
193 |
+
line-height: 1.2em;
|
194 |
+
padding: 0 0.5em;
|
195 |
+
margin: 0;
|
196 |
+
|
197 |
+
background-color: white;
|
198 |
+
border-top: 1px solid #eee;
|
199 |
+
border-left: 1px solid #eee;
|
200 |
+
border-right: 1px solid #eee;
|
201 |
+
}
|
202 |
+
|
203 |
+
.dark fieldset span.text-gray-500, .dark .gr-block.gr-box span.text-gray-500, .dark label.block span{
|
204 |
+
background-color: rgb(31, 41, 55);
|
205 |
+
border-top: 1px solid rgb(55 65 81);
|
206 |
+
border-left: 1px solid rgb(55 65 81);
|
207 |
+
border-right: 1px solid rgb(55 65 81);
|
208 |
+
}
|
209 |
+
|
210 |
+
#settings fieldset span.text-gray-500, #settings .gr-block.gr-box span.text-gray-500, #settings label.block span{
|
211 |
+
position: relative;
|
212 |
+
border: none;
|
213 |
+
}
|
214 |
+
|
215 |
+
.gr-panel div.flex-col div.justify-between label span{
|
216 |
+
margin: 0;
|
217 |
+
}
|
218 |
+
|
219 |
+
.gr-panel div.flex-col div.justify-between div{
|
220 |
+
position: absolute;
|
221 |
+
top: -0.1em;
|
222 |
+
right: 1em;
|
223 |
+
padding: 0 0.5em;
|
224 |
+
}
|
225 |
+
|
226 |
+
#settings .gr-panel div.flex-col div.justify-between div{
|
227 |
+
position: relative;
|
228 |
+
z-index: 200;
|
229 |
+
}
|
230 |
+
|
231 |
+
input[type="range"]{
|
232 |
+
margin: 0.5em 0 -0.3em 0;
|
233 |
+
}
|
234 |
+
|
235 |
+
#txt2img_sampling label{
|
236 |
+
padding-left: 0.6em;
|
237 |
+
padding-right: 0.6em;
|
238 |
+
}
|
239 |
+
|
240 |
+
#mask_bug_info {
|
241 |
+
text-align: center;
|
242 |
+
display: block;
|
243 |
+
margin-top: -0.75em;
|
244 |
+
margin-bottom: -0.75em;
|
245 |
+
}
|
246 |
+
|
247 |
+
#txt2img_negative_prompt, #img2img_negative_prompt{
|
248 |
+
}
|
249 |
+
|
250 |
+
#txt2img_progressbar, #img2img_progressbar, #ti_progressbar{
|
251 |
+
position: absolute;
|
252 |
+
z-index: 1000;
|
253 |
+
right: 0;
|
254 |
+
padding-left: 5px;
|
255 |
+
padding-right: 5px;
|
256 |
+
display: block;
|
257 |
+
}
|
258 |
+
|
259 |
+
#txt2img_progress_row, #img2img_progress_row{
|
260 |
+
margin-bottom: 10px;
|
261 |
+
margin-top: -18px;
|
262 |
+
}
|
263 |
+
|
264 |
+
.progressDiv{
|
265 |
+
width: 100%;
|
266 |
+
height: 20px;
|
267 |
+
background: #b4c0cc;
|
268 |
+
border-radius: 8px;
|
269 |
+
}
|
270 |
+
|
271 |
+
.dark .progressDiv{
|
272 |
+
background: #424c5b;
|
273 |
+
}
|
274 |
+
|
275 |
+
.progressDiv .progress{
|
276 |
+
width: 0%;
|
277 |
+
height: 20px;
|
278 |
+
background: #0060df;
|
279 |
+
color: white;
|
280 |
+
font-weight: bold;
|
281 |
+
line-height: 20px;
|
282 |
+
padding: 0 8px 0 0;
|
283 |
+
text-align: right;
|
284 |
+
border-radius: 8px;
|
285 |
+
}
|
286 |
+
|
287 |
+
#lightboxModal{
|
288 |
+
display: none;
|
289 |
+
position: fixed;
|
290 |
+
z-index: 1001;
|
291 |
+
padding-top: 100px;
|
292 |
+
left: 0;
|
293 |
+
top: 0;
|
294 |
+
width: 100%;
|
295 |
+
height: 100%;
|
296 |
+
overflow: auto;
|
297 |
+
background-color: rgba(20, 20, 20, 0.95);
|
298 |
+
}
|
299 |
+
|
300 |
+
.modalControls {
|
301 |
+
display: grid;
|
302 |
+
grid-template-columns: 32px auto 1fr 32px;
|
303 |
+
grid-template-areas: "zoom tile space close";
|
304 |
+
position: absolute;
|
305 |
+
top: 0;
|
306 |
+
left: 0;
|
307 |
+
right: 0;
|
308 |
+
padding: 16px;
|
309 |
+
gap: 16px;
|
310 |
+
background-color: rgba(0,0,0,0.2);
|
311 |
+
}
|
312 |
+
|
313 |
+
.modalClose {
|
314 |
+
grid-area: close;
|
315 |
+
}
|
316 |
+
|
317 |
+
.modalZoom {
|
318 |
+
grid-area: zoom;
|
319 |
+
}
|
320 |
+
|
321 |
+
.modalTileImage {
|
322 |
+
grid-area: tile;
|
323 |
+
}
|
324 |
+
|
325 |
+
.modalClose,
|
326 |
+
.modalZoom,
|
327 |
+
.modalTileImage {
|
328 |
+
color: white;
|
329 |
+
font-size: 35px;
|
330 |
+
font-weight: bold;
|
331 |
+
cursor: pointer;
|
332 |
+
}
|
333 |
+
|
334 |
+
.modalClose:hover,
|
335 |
+
.modalClose:focus,
|
336 |
+
.modalZoom:hover,
|
337 |
+
.modalZoom:focus {
|
338 |
+
color: #999;
|
339 |
+
text-decoration: none;
|
340 |
+
cursor: pointer;
|
341 |
+
}
|
342 |
+
|
343 |
+
#modalImage {
|
344 |
+
display: block;
|
345 |
+
margin-left: auto;
|
346 |
+
margin-right: auto;
|
347 |
+
margin-top: auto;
|
348 |
+
width: auto;
|
349 |
+
}
|
350 |
+
|
351 |
+
.modalImageFullscreen {
|
352 |
+
object-fit: contain;
|
353 |
+
height: 90%;
|
354 |
+
}
|
355 |
+
|
356 |
+
.modalPrev,
|
357 |
+
.modalNext {
|
358 |
+
cursor: pointer;
|
359 |
+
position: absolute;
|
360 |
+
top: 50%;
|
361 |
+
width: auto;
|
362 |
+
padding: 16px;
|
363 |
+
margin-top: -50px;
|
364 |
+
color: white;
|
365 |
+
font-weight: bold;
|
366 |
+
font-size: 20px;
|
367 |
+
transition: 0.6s ease;
|
368 |
+
border-radius: 0 3px 3px 0;
|
369 |
+
user-select: none;
|
370 |
+
-webkit-user-select: none;
|
371 |
+
}
|
372 |
+
|
373 |
+
.modalNext {
|
374 |
+
right: 0;
|
375 |
+
border-radius: 3px 0 0 3px;
|
376 |
+
}
|
377 |
+
|
378 |
+
.modalPrev:hover,
|
379 |
+
.modalNext:hover {
|
380 |
+
background-color: rgba(0, 0, 0, 0.8);
|
381 |
+
}
|
382 |
+
|
383 |
+
#imageARPreview{
|
384 |
+
position:absolute;
|
385 |
+
top:0px;
|
386 |
+
left:0px;
|
387 |
+
border:2px solid red;
|
388 |
+
background:rgba(255, 0, 0, 0.3);
|
389 |
+
z-index: 900;
|
390 |
+
pointer-events:none;
|
391 |
+
display:none
|
392 |
+
}
|
393 |
+
|
394 |
+
#txt2img_interrupt, #img2img_interrupt{
|
395 |
+
position: absolute;
|
396 |
+
width: 100%;
|
397 |
+
height: 72px;
|
398 |
+
background: #b4c0cc;
|
399 |
+
border-radius: 8px;
|
400 |
+
display: none;
|
401 |
+
}
|
402 |
+
|
403 |
+
.red {
|
404 |
+
color: red;
|
405 |
+
}
|
406 |
+
|
407 |
+
.gallery-item {
|
408 |
+
--tw-bg-opacity: 0 !important;
|
409 |
+
}
|
410 |
+
|
411 |
+
#img2img_image div.h-60{
|
412 |
+
height: 480px;
|
413 |
+
}
|
txt2img_Screenshot.png
ADDED
webui-user.bat
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
@echo off
|
2 |
+
|
3 |
+
set PYTHON=
|
4 |
+
set GIT=
|
5 |
+
set VENV_DIR=
|
6 |
+
set COMMANDLINE_ARGS=
|
7 |
+
|
8 |
+
call webui.bat
|
webui-user.sh
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
#########################################################
|
3 |
+
# Uncomment and change the variables below to your need:#
|
4 |
+
#########################################################
|
5 |
+
|
6 |
+
# Install directory without trailing slash
|
7 |
+
#install_dir="/home/$(whoami)"
|
8 |
+
|
9 |
+
# Name of the subdirectory
|
10 |
+
#clone_dir="stable-diffusion-webui"
|
11 |
+
|
12 |
+
# Commandline arguments for webui.py, for example: export COMMANDLINE_ARGS="--medvram --opt-split-attention"
|
13 |
+
export COMMANDLINE_ARGS=""
|
14 |
+
|
15 |
+
# python3 executable
|
16 |
+
#python_cmd="python3"
|
17 |
+
|
18 |
+
# git executable
|
19 |
+
#export GIT="git"
|
20 |
+
|
21 |
+
# python3 venv without trailing slash (defaults to ${install_dir}/${clone_dir}/venv)
|
22 |
+
#venv_dir="venv"
|
23 |
+
|
24 |
+
# script to launch to start the app
|
25 |
+
#export LAUNCH_SCRIPT="launch.py"
|
26 |
+
|
27 |
+
# install command for torch
|
28 |
+
#export TORCH_COMMAND="pip install torch==1.12.1+cu113 --extra-index-url https://download.pytorch.org/whl/cu113"
|
29 |
+
|
30 |
+
# Requirements file to use for stable-diffusion-webui
|
31 |
+
#export REQS_FILE="requirements_versions.txt"
|
32 |
+
|
33 |
+
# Fixed git repos
|
34 |
+
#export K_DIFFUSION_PACKAGE=""
|
35 |
+
#export GFPGAN_PACKAGE=""
|
36 |
+
|
37 |
+
# Fixed git commits
|
38 |
+
#export STABLE_DIFFUSION_COMMIT_HASH=""
|
39 |
+
#export TAMING_TRANSFORMERS_COMMIT_HASH=""
|
40 |
+
#export CODEFORMER_COMMIT_HASH=""
|
41 |
+
#export BLIP_COMMIT_HASH=""
|
42 |
+
|
43 |
+
###########################################
|
webui.bat
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
@echo off
|
2 |
+
|
3 |
+
if not defined PYTHON (set PYTHON=python)
|
4 |
+
if not defined VENV_DIR (set VENV_DIR=venv)
|
5 |
+
|
6 |
+
set ERROR_REPORTING=FALSE
|
7 |
+
|
8 |
+
mkdir tmp 2>NUL
|
9 |
+
|
10 |
+
%PYTHON% -c "" >tmp/stdout.txt 2>tmp/stderr.txt
|
11 |
+
if %ERRORLEVEL% == 0 goto :start_venv
|
12 |
+
echo Couldn't launch python
|
13 |
+
goto :show_stdout_stderr
|
14 |
+
|
15 |
+
:start_venv
|
16 |
+
if [%VENV_DIR%] == [-] goto :skip_venv
|
17 |
+
|
18 |
+
dir %VENV_DIR%\Scripts\Python.exe >tmp/stdout.txt 2>tmp/stderr.txt
|
19 |
+
if %ERRORLEVEL% == 0 goto :activate_venv
|
20 |
+
|
21 |
+
for /f "delims=" %%i in ('CALL %PYTHON% -c "import sys; print(sys.executable)"') do set PYTHON_FULLNAME="%%i"
|
22 |
+
echo Creating venv in directory %VENV_DIR% using python %PYTHON_FULLNAME%
|
23 |
+
%PYTHON_FULLNAME% -m venv %VENV_DIR% >tmp/stdout.txt 2>tmp/stderr.txt
|
24 |
+
if %ERRORLEVEL% == 0 goto :activate_venv
|
25 |
+
echo Unable to create venv in directory %VENV_DIR%
|
26 |
+
goto :show_stdout_stderr
|
27 |
+
|
28 |
+
:activate_venv
|
29 |
+
set PYTHON="%~dp0%VENV_DIR%\Scripts\Python.exe"
|
30 |
+
echo venv %PYTHON%
|
31 |
+
goto :launch
|
32 |
+
|
33 |
+
:skip_venv
|
34 |
+
|
35 |
+
:launch
|
36 |
+
%PYTHON% launch.py
|
37 |
+
pause
|
38 |
+
exit /b
|
39 |
+
|
40 |
+
:show_stdout_stderr
|
41 |
+
|
42 |
+
echo.
|
43 |
+
echo exit code: %errorlevel%
|
44 |
+
|
45 |
+
for /f %%i in ("tmp\stdout.txt") do set size=%%~zi
|
46 |
+
if %size% equ 0 goto :show_stderr
|
47 |
+
echo.
|
48 |
+
echo stdout:
|
49 |
+
type tmp\stdout.txt
|
50 |
+
|
51 |
+
:show_stderr
|
52 |
+
for /f %%i in ("tmp\stderr.txt") do set size=%%~zi
|
53 |
+
if %size% equ 0 goto :show_stderr
|
54 |
+
echo.
|
55 |
+
echo stderr:
|
56 |
+
type tmp\stderr.txt
|
57 |
+
|
58 |
+
:endofscript
|
59 |
+
|
60 |
+
echo.
|
61 |
+
echo Launch unsuccessful. Exiting.
|
62 |
+
pause
|
webui.py
ADDED
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import threading
|
3 |
+
import time
|
4 |
+
import importlib
|
5 |
+
import signal
|
6 |
+
import threading
|
7 |
+
|
8 |
+
from modules.paths import script_path
|
9 |
+
|
10 |
+
from modules import devices, sd_samplers
|
11 |
+
import modules.codeformer_model as codeformer
|
12 |
+
import modules.extras
|
13 |
+
import modules.face_restoration
|
14 |
+
import modules.gfpgan_model as gfpgan
|
15 |
+
import modules.img2img
|
16 |
+
|
17 |
+
import modules.lowvram
|
18 |
+
import modules.paths
|
19 |
+
import modules.scripts
|
20 |
+
import modules.sd_hijack
|
21 |
+
import modules.sd_models
|
22 |
+
import modules.shared as shared
|
23 |
+
import modules.txt2img
|
24 |
+
|
25 |
+
import modules.ui
|
26 |
+
from modules import devices
|
27 |
+
from modules import modelloader
|
28 |
+
from modules.paths import script_path
|
29 |
+
from modules.shared import cmd_opts
|
30 |
+
|
31 |
+
modelloader.cleanup_models()
|
32 |
+
modules.sd_models.setup_model()
|
33 |
+
codeformer.setup_model(cmd_opts.codeformer_models_path)
|
34 |
+
gfpgan.setup_model(cmd_opts.gfpgan_models_path)
|
35 |
+
shared.face_restorers.append(modules.face_restoration.FaceRestoration())
|
36 |
+
modelloader.load_upscalers()
|
37 |
+
queue_lock = threading.Lock()
|
38 |
+
|
39 |
+
|
40 |
+
def wrap_queued_call(func):
|
41 |
+
def f(*args, **kwargs):
|
42 |
+
with queue_lock:
|
43 |
+
res = func(*args, **kwargs)
|
44 |
+
|
45 |
+
return res
|
46 |
+
|
47 |
+
return f
|
48 |
+
|
49 |
+
|
50 |
+
def wrap_gradio_gpu_call(func, extra_outputs=None):
|
51 |
+
def f(*args, **kwargs):
|
52 |
+
devices.torch_gc()
|
53 |
+
|
54 |
+
shared.state.sampling_step = 0
|
55 |
+
shared.state.job_count = -1
|
56 |
+
shared.state.job_no = 0
|
57 |
+
shared.state.job_timestamp = shared.state.get_job_timestamp()
|
58 |
+
shared.state.current_latent = None
|
59 |
+
shared.state.current_image = None
|
60 |
+
shared.state.current_image_sampling_step = 0
|
61 |
+
shared.state.interrupted = False
|
62 |
+
shared.state.textinfo = None
|
63 |
+
|
64 |
+
with queue_lock:
|
65 |
+
res = func(*args, **kwargs)
|
66 |
+
|
67 |
+
shared.state.job = ""
|
68 |
+
shared.state.job_count = 0
|
69 |
+
|
70 |
+
devices.torch_gc()
|
71 |
+
|
72 |
+
return res
|
73 |
+
|
74 |
+
return modules.ui.wrap_gradio_call(f, extra_outputs=extra_outputs)
|
75 |
+
|
76 |
+
|
77 |
+
modules.scripts.load_scripts(os.path.join(script_path, "scripts"))
|
78 |
+
|
79 |
+
shared.sd_model = modules.sd_models.load_model()
|
80 |
+
shared.opts.onchange("sd_model_checkpoint", wrap_queued_call(lambda: modules.sd_models.reload_model_weights(shared.sd_model)))
|
81 |
+
|
82 |
+
|
83 |
+
def webui():
|
84 |
+
# make the program just exit at ctrl+c without waiting for anything
|
85 |
+
def sigint_handler(sig, frame):
|
86 |
+
print(f'Interrupted with signal {sig} in {frame}')
|
87 |
+
os._exit(0)
|
88 |
+
|
89 |
+
signal.signal(signal.SIGINT, sigint_handler)
|
90 |
+
|
91 |
+
while 1:
|
92 |
+
|
93 |
+
demo = modules.ui.create_ui(wrap_gradio_gpu_call=wrap_gradio_gpu_call)
|
94 |
+
|
95 |
+
demo.launch(
|
96 |
+
share=cmd_opts.share,
|
97 |
+
server_name="0.0.0.0" if cmd_opts.listen else None,
|
98 |
+
server_port=cmd_opts.port,
|
99 |
+
debug=cmd_opts.gradio_debug,
|
100 |
+
auth=[tuple(cred.split(':')) for cred in cmd_opts.gradio_auth.strip('"').split(',')] if cmd_opts.gradio_auth else None,
|
101 |
+
inbrowser=cmd_opts.autolaunch,
|
102 |
+
prevent_thread_lock=True
|
103 |
+
)
|
104 |
+
|
105 |
+
while 1:
|
106 |
+
time.sleep(0.5)
|
107 |
+
if getattr(demo, 'do_restart', False):
|
108 |
+
time.sleep(0.5)
|
109 |
+
demo.close()
|
110 |
+
time.sleep(0.5)
|
111 |
+
break
|
112 |
+
|
113 |
+
sd_samplers.set_samplers()
|
114 |
+
|
115 |
+
print('Reloading Custom Scripts')
|
116 |
+
modules.scripts.reload_scripts(os.path.join(script_path, "scripts"))
|
117 |
+
print('Reloading modules: modules.ui')
|
118 |
+
importlib.reload(modules.ui)
|
119 |
+
print('Restarting Gradio')
|
120 |
+
|
121 |
+
|
122 |
+
|
123 |
+
if __name__ == "__main__":
|
124 |
+
webui()
|
webui.sh
ADDED
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
#################################################
|
3 |
+
# Please do not make any changes to this file, #
|
4 |
+
# change the variables in webui-user.sh instead #
|
5 |
+
#################################################
|
6 |
+
# Read variables from webui-user.sh
|
7 |
+
# shellcheck source=/dev/null
|
8 |
+
if [[ -f webui-user.sh ]]
|
9 |
+
then
|
10 |
+
source ./webui-user.sh
|
11 |
+
fi
|
12 |
+
|
13 |
+
# Set defaults
|
14 |
+
# Install directory without trailing slash
|
15 |
+
if [[ -z "${install_dir}" ]]
|
16 |
+
then
|
17 |
+
install_dir="/home/$(whoami)"
|
18 |
+
fi
|
19 |
+
|
20 |
+
# Name of the subdirectory (defaults to stable-diffusion-webui)
|
21 |
+
if [[ -z "${clone_dir}" ]]
|
22 |
+
then
|
23 |
+
clone_dir="stable-diffusion-webui"
|
24 |
+
fi
|
25 |
+
|
26 |
+
# python3 executable
|
27 |
+
if [[ -z "${python_cmd}" ]]
|
28 |
+
then
|
29 |
+
python_cmd="python3"
|
30 |
+
fi
|
31 |
+
|
32 |
+
# git executable
|
33 |
+
if [[ -z "${GIT}" ]]
|
34 |
+
then
|
35 |
+
export GIT="git"
|
36 |
+
fi
|
37 |
+
|
38 |
+
# python3 venv without trailing slash (defaults to ${install_dir}/${clone_dir}/venv)
|
39 |
+
if [[ -z "${venv_dir}" ]]
|
40 |
+
then
|
41 |
+
venv_dir="venv"
|
42 |
+
fi
|
43 |
+
|
44 |
+
if [[ -z "${LAUNCH_SCRIPT}" ]]
|
45 |
+
then
|
46 |
+
LAUNCH_SCRIPT="launch.py"
|
47 |
+
fi
|
48 |
+
|
49 |
+
# Disable sentry logging
|
50 |
+
export ERROR_REPORTING=FALSE
|
51 |
+
|
52 |
+
# Do not reinstall existing pip packages on Debian/Ubuntu
|
53 |
+
export PIP_IGNORE_INSTALLED=0
|
54 |
+
|
55 |
+
# Pretty print
|
56 |
+
delimiter="################################################################"
|
57 |
+
|
58 |
+
printf "\n%s\n" "${delimiter}"
|
59 |
+
printf "\e[1m\e[32mInstall script for stable-diffusion + Web UI\n"
|
60 |
+
printf "\e[1m\e[34mTested on Debian 11 (Bullseye)\e[0m"
|
61 |
+
printf "\n%s\n" "${delimiter}"
|
62 |
+
|
63 |
+
# Do not run as root
|
64 |
+
if [[ $(id -u) -eq 0 ]]
|
65 |
+
then
|
66 |
+
printf "\n%s\n" "${delimiter}"
|
67 |
+
printf "\e[1m\e[31mERROR: This script must not be launched as root, aborting...\e[0m"
|
68 |
+
printf "\n%s\n" "${delimiter}"
|
69 |
+
exit 1
|
70 |
+
else
|
71 |
+
printf "\n%s\n" "${delimiter}"
|
72 |
+
printf "Running on \e[1m\e[32m%s\e[0m user" "$(whoami)"
|
73 |
+
printf "\n%s\n" "${delimiter}"
|
74 |
+
fi
|
75 |
+
|
76 |
+
if [[ -d .git ]]
|
77 |
+
then
|
78 |
+
printf "\n%s\n" "${delimiter}"
|
79 |
+
printf "Repo already cloned, using it as install directory"
|
80 |
+
printf "\n%s\n" "${delimiter}"
|
81 |
+
install_dir="${PWD}/../"
|
82 |
+
clone_dir="${PWD##*/}"
|
83 |
+
fi
|
84 |
+
|
85 |
+
# Check prequisites
|
86 |
+
for preq in git python3
|
87 |
+
do
|
88 |
+
if ! hash "${preq}" &>/dev/null
|
89 |
+
then
|
90 |
+
printf "\n%s\n" "${delimiter}"
|
91 |
+
printf "\e[1m\e[31mERROR: %s is not installed, aborting...\e[0m" "${preq}"
|
92 |
+
printf "\n%s\n" "${delimiter}"
|
93 |
+
exit 1
|
94 |
+
fi
|
95 |
+
done
|
96 |
+
|
97 |
+
if ! "${python_cmd}" -c "import venv" &>/dev/null
|
98 |
+
then
|
99 |
+
printf "\n%s\n" "${delimiter}"
|
100 |
+
printf "\e[1m\e[31mERROR: python3-venv is not installed, aborting...\e[0m"
|
101 |
+
printf "\n%s\n" "${delimiter}"
|
102 |
+
exit 1
|
103 |
+
fi
|
104 |
+
|
105 |
+
printf "\n%s\n" "${delimiter}"
|
106 |
+
printf "Clone or update stable-diffusion-webui"
|
107 |
+
printf "\n%s\n" "${delimiter}"
|
108 |
+
cd "${install_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/, aborting...\e[0m" "${install_dir}"; exit 1; }
|
109 |
+
if [[ -d "${clone_dir}" ]]
|
110 |
+
then
|
111 |
+
cd "${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; }
|
112 |
+
"${GIT}" pull
|
113 |
+
else
|
114 |
+
"${GIT}" clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git "${clone_dir}"
|
115 |
+
cd "${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; }
|
116 |
+
fi
|
117 |
+
|
118 |
+
printf "\n%s\n" "${delimiter}"
|
119 |
+
printf "Create and activate python venv"
|
120 |
+
printf "\n%s\n" "${delimiter}"
|
121 |
+
cd "${install_dir}"/"${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; }
|
122 |
+
if [[ ! -d "${venv_dir}" ]]
|
123 |
+
then
|
124 |
+
"${python_cmd}" -m venv "${venv_dir}"
|
125 |
+
first_launch=1
|
126 |
+
fi
|
127 |
+
# shellcheck source=/dev/null
|
128 |
+
if [[ -f "${venv_dir}"/bin/activate ]]
|
129 |
+
then
|
130 |
+
source "${venv_dir}"/bin/activate
|
131 |
+
else
|
132 |
+
printf "\n%s\n" "${delimiter}"
|
133 |
+
printf "\e[1m\e[31mERROR: Cannot activate python venv, aborting...\e[0m"
|
134 |
+
printf "\n%s\n" "${delimiter}"
|
135 |
+
exit 1
|
136 |
+
fi
|
137 |
+
|
138 |
+
printf "\n%s\n" "${delimiter}"
|
139 |
+
printf "Launching launch.py..."
|
140 |
+
printf "\n%s\n" "${delimiter}"
|
141 |
+
"${python_cmd}" "${LAUNCH_SCRIPT}"
|