awaawawawa commited on
Commit
04fa6e7
2 Parent(s): 70df209 28cea4f

Add application file

Browse files
Files changed (16) hide show
  1. README.md +10 -0
  2. app.py +3 -0
  3. config.json +1 -0
  4. launch.py +181 -0
  5. params.txt +3 -0
  6. prune.bat +84 -0
  7. prune.py +56 -0
  8. requirements.txt +3 -0
  9. requirements_versions.txt +24 -0
  10. script.js +85 -0
  11. style.css +518 -0
  12. ui-config.json +292 -0
  13. webui-user.sh +43 -0
  14. webui.bat +62 -0
  15. webui.py +137 -0
  16. webui.sh +141 -0
README.md CHANGED
@@ -1,4 +1,5 @@
1
  ---
 
2
  title: Stable Diffusion 3
3
  emoji: ⚡
4
  colorFrom: green
@@ -8,6 +9,15 @@ sdk_version: 3.1.7
8
  app_file: start.py
9
  datasets: [emotion]
10
  license: mit
 
 
 
 
 
 
 
 
 
11
  pinned: false
12
  ---
13
 
 
1
  ---
2
+ <<<<<<< HEAD
3
  title: Stable Diffusion 3
4
  emoji: ⚡
5
  colorFrom: green
 
9
  app_file: start.py
10
  datasets: [emotion]
11
  license: mit
12
+ =======
13
+ title: Iurf7irfuyytruyyugb
14
+ emoji: 📚
15
+ colorFrom: red
16
+ colorTo: pink
17
+ sdk: gradio
18
+ sdk_version: 3.5
19
+ app_file: app.py
20
+ >>>>>>> 28cea4f0f809fb6ae1b8e8463506afd99e2a9d19
21
  pinned: false
22
  ---
23
 
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import json
2
  import os, re
3
  import traceback
@@ -870,3 +871,5 @@ def get_initial_model_to_load():
870
  #model_is_loading = False
871
 
872
  #mk_img(ImageRequest)
 
 
 
1
+ <<<<<<< HEAD
2
  import json
3
  import os, re
4
  import traceback
 
871
  #model_is_loading = False
872
 
873
  #mk_img(ImageRequest)
874
+ =======
875
+ >>>>>>> 28cea4f0f809fb6ae1b8e8463506afd99e2a9d19
config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"samples_save": true, "samples_format": "png", "samples_filename_pattern": "", "grid_save": true, "grid_format": "png", "grid_extended_filename": false, "grid_only_if_multiple": true, "n_rows": -1, "enable_pnginfo": true, "save_txt": true, "save_images_before_face_restoration": false, "jpeg_quality": 80, "export_for_4chan": true, "use_original_name_batch": false, "save_selected_only": true, "outdir_samples": "", "outdir_txt2img_samples": "outputs/txt2img-images", "outdir_img2img_samples": "outputs/img2img-images", "outdir_extras_samples": "outputs/extras-images", "outdir_grids": "", "outdir_txt2img_grids": "outputs/txt2img-grids", "outdir_img2img_grids": "outputs/img2img-grids", "outdir_save": "log/images", "save_to_dirs": true, "grid_save_to_dirs": true, "use_save_to_dirs_for_ui": false, "directories_filename_pattern": "", "directories_max_prompt_words": 8, "ESRGAN_tile": 192, "ESRGAN_tile_overlap": 43, "realesrgan_enabled_models": ["R-ESRGAN x4+", "R-ESRGAN x4+ Anime6B"], "SWIN_tile": 192, "SWIN_tile_overlap": 8, "ldsr_steps": 100, "upscaler_for_img2img": "SwinIR_4x", "face_restoration_model": null, "code_former_weight": 0.5, "face_restoration_unload": false, "memmon_poll_rate": 8, "samples_log_stdout": false, "multiple_tqdm": true, "sd_model_checkpoint": "final-pruned.ckpt [925997e9]", "sd_hypernetwork": "None", "img2img_color_correction": false, "save_images_before_color_correction": false, "img2img_fix_steps": false, "enable_quantization": false, "enable_emphasis": true, "use_old_emphasis_implementation": false, "enable_batch_seeds": true, "filter_nsfw": false, "CLIP_ignore_last_layers": 0, "random_artist_categories": [], "interrogate_keep_models_in_memory": false, "interrogate_use_builtin_artists": true, "interrogate_clip_num_beams": 1, "interrogate_clip_min_length": 24, "interrogate_clip_max_length": 48, "interrogate_clip_dict_limit": 1500.0, "show_progressbar": true, "show_progress_every_n_steps": 0, "return_grid": true, "do_not_show_images": false, "add_model_hash_to_info": true, "add_model_name_to_info": false, "font": "", "js_modal_lightbox": true, "js_modal_lightbox_initially_zoomed": true, "show_progress_in_title": true, "hide_samplers": [], "eta_ddim": 0, "eta_ancestral": 1, "ddim_discretize": "uniform", "s_churn": 0, "s_tmin": 0, "s_noise": 1, "do_not_add_watermark": false, "unload_models_when_training": false, "dataset_filename_word_regex": "", "dataset_filename_join_string": " ", "training_image_repeats_per_epoch": 100, "comma_padding_backtrack": 20, "CLIP_stop_at_last_layers": 1, "interrogate_deepbooru_score_threshold": 0.5, "deepbooru_sort_alpha": true, "eta_noise_seed_delta": 0, "quicksettings": "sd_model_checkpoint", "interrogate_return_ranks": false, "deepbooru_use_spaces": false, "deepbooru_escape": true, "grid_prevent_empty_spots": false, "training_write_csv_every": 500.0, "sd_hypernetwork_strength": 1}
launch.py ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ import platform
8
+
9
+ dir_repos = "repositories"
10
+ python = sys.executable
11
+ git = os.environ.get('GIT', "git")
12
+ index_url = os.environ.get('INDEX_URL', "")
13
+
14
+
15
+ def extract_arg(args, name):
16
+ return [x for x in args if x != name], name in args
17
+
18
+
19
+ def run(command, desc=None, errdesc=None):
20
+ if desc is not None:
21
+ print(desc)
22
+
23
+ result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
24
+
25
+ if result.returncode != 0:
26
+
27
+ message = f"""{errdesc or 'Error running command'}.
28
+ Command: {command}
29
+ Error code: {result.returncode}
30
+ stdout: {result.stdout.decode(encoding="utf8", errors="ignore") if len(result.stdout)>0 else '<empty>'}
31
+ stderr: {result.stderr.decode(encoding="utf8", errors="ignore") if len(result.stderr)>0 else '<empty>'}
32
+ """
33
+ raise RuntimeError(message)
34
+
35
+ return result.stdout.decode(encoding="utf8", errors="ignore")
36
+
37
+
38
+ def check_run(command):
39
+ result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
40
+ return result.returncode == 0
41
+
42
+
43
+ def is_installed(package):
44
+ try:
45
+ spec = importlib.util.find_spec(package)
46
+ except ModuleNotFoundError:
47
+ return False
48
+
49
+ return spec is not None
50
+
51
+
52
+ def repo_dir(name):
53
+ return os.path.join(dir_repos, name)
54
+
55
+
56
+ def run_python(code, desc=None, errdesc=None):
57
+ return run(f'"{python}" -c "{code}"', desc, errdesc)
58
+
59
+
60
+ def run_pip(args, desc=None):
61
+ index_url_line = f' --index-url {index_url}' if index_url != '' else ''
62
+ return run(f'"{python}" -m pip {args} --prefer-binary{index_url_line}', desc=f"Installing {desc}", errdesc=f"Couldn't install {desc}")
63
+
64
+
65
+ def check_run_python(code):
66
+ return check_run(f'"{python}" -c "{code}"')
67
+
68
+
69
+ def git_clone(url, dir, name, commithash=None):
70
+ # TODO clone into temporary dir and move if successful
71
+
72
+ if os.path.exists(dir):
73
+ if commithash is None:
74
+ return
75
+
76
+ current_hash = run(f'"{git}" -C {dir} rev-parse HEAD', None, f"Couldn't determine {name}'s hash: {commithash}").strip()
77
+ if current_hash == commithash:
78
+ return
79
+
80
+ run(f'"{git}" -C {dir} fetch', f"Fetching updates for {name}...", f"Couldn't fetch {name}")
81
+ run(f'"{git}" -C {dir} checkout {commithash}', f"Checking out commit for {name} with hash: {commithash}...", f"Couldn't checkout commit {commithash} for {name}")
82
+ return
83
+
84
+ run(f'"{git}" clone "{url}" "{dir}"', f"Cloning {name} into {dir}...", f"Couldn't clone {name}")
85
+
86
+ if commithash is not None:
87
+ run(f'"{git}" -C {dir} checkout {commithash}', None, "Couldn't checkout {name}'s hash: {commithash}")
88
+
89
+
90
+ def prepare_enviroment():
91
+ 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")
92
+ requirements_file = os.environ.get('REQS_FILE', "requirements_versions.txt")
93
+ commandline_args = os.environ.get('COMMANDLINE_ARGS', "")
94
+
95
+ gfpgan_package = os.environ.get('GFPGAN_PACKAGE', "git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379")
96
+ clip_package = os.environ.get('CLIP_PACKAGE', "git+https://github.com/openai/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e4823fc8e1")
97
+ deepdanbooru_package = os.environ.get('DEEPDANBOORU_PACKAGE', "git+https://github.com/KichangKim/DeepDanbooru.git@edf73df4cdaeea2cf00e9ac08bd8a9026b7a7b26")
98
+
99
+ xformers_windows_package = os.environ.get('XFORMERS_WINDOWS_PACKAGE', 'https://github.com/C43H66N12O12S2/stable-diffusion-webui/releases/download/f/xformers-0.0.14.dev0-cp310-cp310-win_amd64.whl')
100
+
101
+ stable_diffusion_repo = os.environ.get('STABLE_DIFFUSION_REPO', "https://github.com/CompVis/stable-diffusion.git")
102
+ taming_transformers_repo = os.environ.get('TAMING_REANSFORMERS_REPO', "https://github.com/CompVis/taming-transformers.git")
103
+ k_diffusion_repo = os.environ.get('K_DIFFUSION_REPO', 'https://github.com/crowsonkb/k-diffusion.git')
104
+ codeformer_repo = os.environ.get('CODEFORMET_REPO', 'https://github.com/sczhou/CodeFormer.git')
105
+ blip_repo = os.environ.get('BLIP_REPO', 'https://github.com/salesforce/BLIP.git')
106
+
107
+ stable_diffusion_commit_hash = os.environ.get('STABLE_DIFFUSION_COMMIT_HASH', "69ae4b35e0a0f6ee1af8bb9a5d0016ccb27e36dc")
108
+ taming_transformers_commit_hash = os.environ.get('TAMING_TRANSFORMERS_COMMIT_HASH', "24268930bf1dce879235a7fddd0b2355b84d7ea6")
109
+ k_diffusion_commit_hash = os.environ.get('K_DIFFUSION_COMMIT_HASH', "f4e99857772fc3a126ba886aadf795a332774878")
110
+ codeformer_commit_hash = os.environ.get('CODEFORMER_COMMIT_HASH', "c5b4593074ba6214284d6acd5f1719b6c5d739af")
111
+ blip_commit_hash = os.environ.get('BLIP_COMMIT_HASH', "48211a1594f1321b00f14c9f7a5b4813144b2fb9")
112
+
113
+ args = shlex.split(commandline_args)
114
+
115
+ args, skip_torch_cuda_test = extract_arg(args, '--skip-torch-cuda-test')
116
+ args, reinstall_xformers = extract_arg(args, '--reinstall-xformers')
117
+ xformers = '--xformers' in args
118
+ deepdanbooru = '--deepdanbooru' in args
119
+ ngrok = '--ngrok' in args
120
+
121
+ try:
122
+ commit = run(f"{git} rev-parse HEAD").strip()
123
+ except Exception:
124
+ commit = "<none>"
125
+
126
+ print(f"Python {sys.version}")
127
+ print(f"Commit hash: {commit}")
128
+
129
+ if not is_installed("torch") or not is_installed("torchvision"):
130
+ run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch")
131
+
132
+ if not skip_torch_cuda_test:
133
+ 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'")
134
+
135
+ if not is_installed("gfpgan"):
136
+ run_pip(f"install {gfpgan_package}", "gfpgan")
137
+
138
+ if not is_installed("clip"):
139
+ run_pip(f"install {clip_package}", "clip")
140
+
141
+ if (not is_installed("xformers") or reinstall_xformers) and xformers and platform.python_version().startswith("3.10"):
142
+ if platform.system() == "Windows":
143
+ run_pip(f"install -U -I --no-deps {xformers_windows_package}", "xformers")
144
+ elif platform.system() == "Linux":
145
+ run_pip("install xformers", "xformers")
146
+
147
+ if not is_installed("deepdanbooru") and deepdanbooru:
148
+ run_pip(f"install {deepdanbooru_package}#egg=deepdanbooru[tensorflow] tensorflow==2.10.0 tensorflow-io==0.27.0", "deepdanbooru")
149
+
150
+ if not is_installed("pyngrok") and ngrok:
151
+ run_pip("install pyngrok", "ngrok")
152
+
153
+ os.makedirs(dir_repos, exist_ok=True)
154
+
155
+ git_clone(stable_diffusion_repo, repo_dir('stable-diffusion'), "Stable Diffusion", stable_diffusion_commit_hash)
156
+ git_clone(taming_transformers_repo, repo_dir('taming-transformers'), "Taming Transformers", taming_transformers_commit_hash)
157
+ git_clone(k_diffusion_repo, repo_dir('k-diffusion'), "K-diffusion", k_diffusion_commit_hash)
158
+ git_clone(codeformer_repo, repo_dir('CodeFormer'), "CodeFormer", codeformer_commit_hash)
159
+ git_clone(blip_repo, repo_dir('BLIP'), "BLIP", blip_commit_hash)
160
+
161
+ if not is_installed("lpips"):
162
+ run_pip(f"install -r {os.path.join(repo_dir('CodeFormer'), 'requirements.txt')}", "requirements for CodeFormer")
163
+
164
+ run_pip(f"install -r {requirements_file}", "requirements for Web UI")
165
+
166
+ sys.argv += args
167
+
168
+ if "--exit" in args:
169
+ print("Exiting because of --exit argument")
170
+ exit(0)
171
+
172
+
173
+ def start_webui():
174
+ print(f"Launching Web UI with arguments: {' '.join(sys.argv[1:])}")
175
+ import webui
176
+ webui.webui()
177
+
178
+
179
+ if __name__ == "__main__":
180
+ prepare_enviroment()
181
+ start_webui()
params.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ white_shirt, 1girl, anchor_symbol, black_legwear, black_skirt, blue_eyes, eyebrows_visible_through_hair, hat, hibiki_\(kancolle\), long_hair, long_sleeves, neckerchief, pleated_skirt, red_neckerchief, sailor_collar, school_uniform, serafuku, silver_hair, skirt, thighhighs
2
+ Negative prompt: lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, bad legs
3
+ Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 295702703, Size: 384x384, Model hash: 925997e9, Batch size: 5, Batch pos: 0
prune.bat ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @echo off
2
+
3
+ if not defined PYTHON (set PYTHON=python)
4
+ if not defined GIT (set GIT=git)
5
+ if not defined COMMANDLINE_ARGS (set COMMANDLINE_ARGS=%*)
6
+ if not defined VENV_DIR (set VENV_DIR=venv)
7
+ if not defined TORCH_COMMAND (set TORCH_COMMAND=pip install torch==1.12.1+cu113 --extra-index-url https://download.pytorch.org/whl/cu113)
8
+ if not defined REQS_FILE (set REQS_FILE=requirements_versions.txt)
9
+
10
+ mkdir tmp 2>NUL
11
+
12
+ %PYTHON% -c "" >tmp/stdout.txt 2>tmp/stderr.txt
13
+ if %ERRORLEVEL% == 0 goto :setup_venv
14
+ echo Couldn't launch python
15
+ goto :show_stdout_stderr
16
+
17
+ :setup_venv
18
+ if [%VENV_DIR%] == [-] goto :skip_venv
19
+
20
+ dir %VENV_DIR%\Scripts\Python.exe >tmp/stdout.txt 2>tmp/stderr.txt
21
+ if %ERRORLEVEL% == 0 goto :activate_venv
22
+
23
+ for /f "delims=" %%i in ('CALL %PYTHON% -c "import sys; print(sys.executable)"') do set PYTHON_FULLNAME="%%i"
24
+ echo Creating venv in directory %VENV_DIR% using python %PYTHON_FULLNAME%
25
+ %PYTHON_FULLNAME% -m venv %VENV_DIR% >tmp/stdout.txt 2>tmp/stderr.txt
26
+ if %ERRORLEVEL% == 0 goto :activate_venv
27
+ echo Unable to create venv in directory %VENV_DIR%
28
+ goto :show_stdout_stderr
29
+
30
+ :activate_venv
31
+ set PYTHON="%~dp0%VENV_DIR%\Scripts\Python.exe"
32
+ %PYTHON% --version
33
+ echo venv %PYTHON%
34
+ goto :install_torch
35
+
36
+ :skip_venv
37
+ echo Skip
38
+ %PYTHON% --version
39
+
40
+ :install_torch
41
+ %PYTHON% -c "import torch" >tmp/stdout.txt 2>tmp/stderr.txt
42
+ if %ERRORLEVEL% == 0 goto :check_gpu
43
+ echo Installing torch...
44
+ %PYTHON% -m %TORCH_COMMAND% >tmp/stdout.txt 2>tmp/stderr.txt
45
+
46
+ if %ERRORLEVEL% == 0 goto :check_gpu
47
+ echo Failed to install torch
48
+ goto :show_stdout_stderr
49
+
50
+ :check_gpu
51
+ %PYTHON% -c "import torch; assert torch.cuda.is_available(), 'CUDA is not available'" >tmp/stdout.txt 2>tmp/stderr.txt
52
+ if %ERRORLEVEL% == 0 goto :launch
53
+ echo Torch is not able to use GPU
54
+ goto :show_stdout_stderr
55
+
56
+ :launch
57
+ echo Launching prune.py...
58
+ %PYTHON% prune.py
59
+ pause
60
+ exit /b
61
+
62
+ :show_stdout_stderr
63
+
64
+ echo.
65
+ echo exit code: %errorlevel%
66
+
67
+ for /f %%i in ("tmp\stdout.txt") do set size=%%~zi
68
+ if %size% equ 0 goto :show_stderr
69
+ echo.
70
+ echo stdout:
71
+ type tmp\stdout.txt
72
+
73
+ :show_stderr
74
+ for /f %%i in ("tmp\stderr.txt") do set size=%%~zi
75
+ if %size% equ 0 goto :show_stderr
76
+ echo.
77
+ echo stderr:
78
+ type tmp\stderr.txt
79
+
80
+ :endofscript
81
+
82
+ echo.
83
+ echo Launch unsuccessful. Exiting.
84
+ pause
prune.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from pathlib import Path
3
+ import torch
4
+ import argparse
5
+ parser = argparse.ArgumentParser()
6
+ args = parser.parse_args()
7
+
8
+
9
+ def prune_it(p, keep_only_ema=True):
10
+ print(f"prunin' in path: {p}")
11
+ size_initial = os.path.getsize(p)
12
+ nsd = dict()
13
+ sd = torch.load(p, map_location="cpu")
14
+ print(sd.keys())
15
+ for k in sd.keys():
16
+ if k != "optimizer_states":
17
+ nsd[k] = sd[k]
18
+ else:
19
+ print(f"removing optimizer states for path {p}")
20
+ if "global_step" in sd:
21
+ print(f"This is global step {sd['global_step']}.")
22
+ if keep_only_ema:
23
+ sd = nsd["state_dict"].copy()
24
+ # infer ema keys
25
+ ema_keys = {k: "model_ema." + k[6:].replace(".", "") for k in sd.keys() if k.startswith('model.')}
26
+ new_sd = dict()
27
+
28
+ for k in sd:
29
+ if k in ema_keys:
30
+ print(k, ema_keys[k])
31
+ new_sd[k] = sd[ema_keys[k]]
32
+ elif not k.startswith("model_ema.") or k in ["model_ema.num_updates", "model_ema.decay"]:
33
+ new_sd[k] = sd[k]
34
+
35
+ assert len(new_sd) == len(sd) - len(ema_keys)
36
+ nsd["state_dict"] = new_sd
37
+ else:
38
+ sd = nsd['state_dict'].copy()
39
+ new_sd = dict()
40
+ for k in sd:
41
+ new_sd[k] = sd[k]
42
+ nsd['state_dict'] = new_sd
43
+
44
+ fn = f"{os.path.splitext(p)[0]}-pruned.ckpt" if not keep_only_ema else f"{os.path.splitext(p)[0]}-ema-pruned.ckpt"
45
+ print(f"saving pruned checkpoint at: {fn}")
46
+ torch.save(nsd, fn)
47
+ newsize = os.path.getsize(fn)
48
+ MSG = f"New ckpt size: {newsize*1e-9:.2f} GB. " + \
49
+ f"Saved {(size_initial - newsize)*1e-9:.2f} GB by removing optimizer states"
50
+ if keep_only_ema:
51
+ MSG += " and non-EMA weights"
52
+ print(MSG)
53
+
54
+
55
+ if __name__ == "__main__":
56
+ prune_it('wd-v1-2-full-ema.ckpt')
requirements.txt CHANGED
@@ -1,3 +1,4 @@
 
1
  transformers==4.*
2
  pytorch-lightning
3
  einops
@@ -31,3 +32,5 @@ datasets==2.*
31
  -e git+https://github.com/xinntao/Real-ESRGAN#egg=realesrgan
32
  -e git+https://github.com/CompVis/taming-transformers#egg=taming-transformers
33
  -e git+https://github.com/openai/CLIP#egg=clip
 
 
 
1
+ <<<<<<< HEAD
2
  transformers==4.*
3
  pytorch-lightning
4
  einops
 
32
  -e git+https://github.com/xinntao/Real-ESRGAN#egg=realesrgan
33
  -e git+https://github.com/CompVis/taming-transformers#egg=taming-transformers
34
  -e git+https://github.com/openai/CLIP#egg=clip
35
+ =======
36
+ >>>>>>> 28cea4f0f809fb6ae1b8e8463506afd99e2a9d19
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.5
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
script.js ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ function get_uiCurrentTabContent() {
10
+ return gradioApp().querySelector('.tabitem[id^=tab_]:not([style*="display: none"])')
11
+ }
12
+
13
+ uiUpdateCallbacks = []
14
+ uiTabChangeCallbacks = []
15
+ let uiCurrentTab = null
16
+
17
+ function onUiUpdate(callback){
18
+ uiUpdateCallbacks.push(callback)
19
+ }
20
+ function onUiTabChange(callback){
21
+ uiTabChangeCallbacks.push(callback)
22
+ }
23
+
24
+ function runCallback(x){
25
+ try {
26
+ x()
27
+ } catch (e) {
28
+ (console.error || console.log).call(console, e.message, e);
29
+ }
30
+ }
31
+ function executeCallbacks(queue) {
32
+ queue.forEach(runCallback)
33
+ }
34
+
35
+ document.addEventListener("DOMContentLoaded", function() {
36
+ var mutationObserver = new MutationObserver(function(m){
37
+ executeCallbacks(uiUpdateCallbacks);
38
+ const newTab = get_uiCurrentTab();
39
+ if ( newTab && ( newTab !== uiCurrentTab ) ) {
40
+ uiCurrentTab = newTab;
41
+ executeCallbacks(uiTabChangeCallbacks);
42
+ }
43
+ });
44
+ mutationObserver.observe( gradioApp(), { childList:true, subtree:true })
45
+ });
46
+
47
+ /**
48
+ * Add a ctrl+enter as a shortcut to start a generation
49
+ */
50
+ document.addEventListener('keydown', function(e) {
51
+ var handled = false;
52
+ if (e.key !== undefined) {
53
+ if((e.key == "Enter" && (e.metaKey || e.ctrlKey || e.altKey))) handled = true;
54
+ } else if (e.keyCode !== undefined) {
55
+ if((e.keyCode == 13 && (e.metaKey || e.ctrlKey || e.altKey))) handled = true;
56
+ }
57
+ if (handled) {
58
+ button = get_uiCurrentTabContent().querySelector('button[id$=_generate]');
59
+ if (button) {
60
+ button.click();
61
+ }
62
+ e.preventDefault();
63
+ }
64
+ })
65
+
66
+ /**
67
+ * checks that a UI element is not in another hidden element or tab content
68
+ */
69
+ function uiElementIsVisible(el) {
70
+ let isVisible = !el.closest('.\\!hidden');
71
+ if ( ! isVisible ) {
72
+ return false;
73
+ }
74
+
75
+ while( isVisible = el.closest('.tabitem')?.style.display !== 'none' ) {
76
+ if ( ! isVisible ) {
77
+ return false;
78
+ } else if ( el.parentElement ) {
79
+ el = el.parentElement
80
+ } else {
81
+ break;
82
+ }
83
+ }
84
+ return isVisible;
85
+ }
style.css ADDED
@@ -0,0 +1,518 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .container {
2
+ max-width: 100%;
3
+ }
4
+
5
+ #txt2img_token_counter {
6
+ height: 0px;
7
+ }
8
+
9
+ #img2img_token_counter {
10
+ height: 0px;
11
+ }
12
+
13
+ #sh{
14
+ min-width: 2em;
15
+ min-height: 2em;
16
+ max-width: 2em;
17
+ max-height: 2em;
18
+ flex-grow: 0;
19
+ padding-left: 0.25em;
20
+ padding-right: 0.25em;
21
+ margin: 0.1em 0;
22
+ opacity: 0%;
23
+ cursor: default;
24
+ }
25
+
26
+ .output-html p {margin: 0 0.5em;}
27
+
28
+ .row > *,
29
+ .row > .gr-form > * {
30
+ min-width: min(120px, 100%);
31
+ flex: 1 1 0%;
32
+ }
33
+
34
+ .performance {
35
+ font-size: 0.85em;
36
+ color: #444;
37
+ display: flex;
38
+ justify-content: space-between;
39
+ white-space: nowrap;
40
+ }
41
+
42
+ .performance .time {
43
+ margin-right: 0;
44
+ }
45
+
46
+ .performance .vram {
47
+ margin-left: 0;
48
+ text-align: right;
49
+ }
50
+
51
+ #txt2img_generate, #img2img_generate {
52
+ min-height: 4.5em;
53
+ }
54
+
55
+ @media screen and (min-width: 2500px) {
56
+ #txt2img_gallery, #img2img_gallery {
57
+ min-height: 768px;
58
+ }
59
+ }
60
+
61
+ #txt2img_gallery img, #img2img_gallery img{
62
+ object-fit: scale-down;
63
+ }
64
+
65
+ .justify-center.overflow-x-scroll {
66
+ justify-content: left;
67
+ }
68
+
69
+ .justify-center.overflow-x-scroll button:first-of-type {
70
+ margin-left: auto;
71
+ }
72
+
73
+ .justify-center.overflow-x-scroll button:last-of-type {
74
+ margin-right: auto;
75
+ }
76
+
77
+ #random_seed, #random_subseed, #reuse_seed, #reuse_subseed, #open_folder{
78
+ min-width: auto;
79
+ flex-grow: 0;
80
+ padding-left: 0.25em;
81
+ padding-right: 0.25em;
82
+ }
83
+
84
+ #hidden_element{
85
+ display: none;
86
+ }
87
+
88
+ #seed_row, #subseed_row{
89
+ gap: 0.5rem;
90
+ }
91
+
92
+ #subseed_show_box{
93
+ min-width: auto;
94
+ flex-grow: 0;
95
+ }
96
+
97
+ #subseed_show_box > div{
98
+ border: 0;
99
+ height: 100%;
100
+ }
101
+
102
+ #subseed_show{
103
+ min-width: auto;
104
+ flex-grow: 0;
105
+ padding: 0;
106
+ }
107
+
108
+ #subseed_show label{
109
+ height: 100%;
110
+ }
111
+
112
+ #roll_col{
113
+ min-width: unset !important;
114
+ flex-grow: 0 !important;
115
+ padding: 0.4em 0;
116
+ }
117
+
118
+ #roll, #paste, #style_create, #style_apply{
119
+ min-width: 2em;
120
+ min-height: 2em;
121
+ max-width: 2em;
122
+ max-height: 2em;
123
+ flex-grow: 0;
124
+ padding-left: 0.25em;
125
+ padding-right: 0.25em;
126
+ margin: 0.1em 0;
127
+ }
128
+
129
+ #interrogate_col{
130
+ min-width: 0 !important;
131
+ max-width: 8em !important;
132
+ }
133
+ #interrogate, #deepbooru{
134
+ margin: 0em 0.25em 0.9em 0.25em;
135
+ min-width: 8em;
136
+ max-width: 8em;
137
+ }
138
+
139
+ #style_pos_col, #style_neg_col{
140
+ min-width: 8em !important;
141
+ }
142
+
143
+ #txt2img_style_index, #txt2img_style2_index, #img2img_style_index, #img2img_style2_index{
144
+ margin-top: 1em;
145
+ }
146
+
147
+ .gr-form{
148
+ background: transparent;
149
+ }
150
+
151
+ .my-4{
152
+ margin-top: 0;
153
+ margin-bottom: 0;
154
+ }
155
+
156
+ #toprow div{
157
+ border: none;
158
+ gap: 0;
159
+ background: transparent;
160
+ }
161
+
162
+ #resize_mode{
163
+ flex: 1.5;
164
+ }
165
+
166
+ button{
167
+ align-self: stretch !important;
168
+ }
169
+
170
+ .overflow-hidden, .gr-panel{
171
+ overflow: visible !important;
172
+ }
173
+
174
+ #x_type, #y_type{
175
+ max-width: 10em;
176
+ }
177
+
178
+ #txt2img_preview, #img2img_preview, #ti_preview{
179
+ position: absolute;
180
+ width: 320px;
181
+ left: 0;
182
+ right: 0;
183
+ margin-left: auto;
184
+ margin-right: auto;
185
+ margin-top: 34px;
186
+ z-index: 100;
187
+ border: none;
188
+ border-top-left-radius: 0;
189
+ border-top-right-radius: 0;
190
+ }
191
+
192
+ @media screen and (min-width: 768px) {
193
+ #txt2img_preview, #img2img_preview, #ti_preview {
194
+ position: absolute;
195
+ }
196
+ }
197
+
198
+ @media screen and (max-width: 767px) {
199
+ #txt2img_preview, #img2img_preview, #ti_preview {
200
+ position: relative;
201
+ }
202
+ }
203
+
204
+ #txt2img_preview div.left-0.top-0, #img2img_preview div.left-0.top-0, #ti_preview div.left-0.top-0{
205
+ display: none;
206
+ }
207
+
208
+ fieldset span.text-gray-500, .gr-block.gr-box span.text-gray-500, label.block span{
209
+ position: absolute;
210
+ top: -0.6em;
211
+ line-height: 1.2em;
212
+ padding: 0 0.5em;
213
+ margin: 0;
214
+
215
+ background-color: white;
216
+ border-top: 1px solid #eee;
217
+ border-left: 1px solid #eee;
218
+ border-right: 1px solid #eee;
219
+
220
+ z-index: 300;
221
+ }
222
+
223
+ .dark fieldset span.text-gray-500, .dark .gr-block.gr-box span.text-gray-500, .dark label.block span{
224
+ background-color: rgb(31, 41, 55);
225
+ border-top: 1px solid rgb(55 65 81);
226
+ border-left: 1px solid rgb(55 65 81);
227
+ border-right: 1px solid rgb(55 65 81);
228
+ }
229
+
230
+ #settings fieldset span.text-gray-500, #settings .gr-block.gr-box span.text-gray-500, #settings label.block span{
231
+ position: relative;
232
+ border: none;
233
+ margin-right: 8em;
234
+ }
235
+
236
+ .gr-panel div.flex-col div.justify-between label span{
237
+ margin: 0;
238
+ }
239
+
240
+ #settings .gr-panel div.flex-col div.justify-between div{
241
+ position: relative;
242
+ z-index: 200;
243
+ }
244
+
245
+ input[type="range"]{
246
+ margin: 0.5em 0 -0.3em 0;
247
+ }
248
+
249
+ #txt2img_sampling label{
250
+ padding-left: 0.6em;
251
+ padding-right: 0.6em;
252
+ }
253
+
254
+ #mask_bug_info {
255
+ text-align: center;
256
+ display: block;
257
+ margin-top: -0.75em;
258
+ margin-bottom: -0.75em;
259
+ }
260
+
261
+ #txt2img_negative_prompt, #img2img_negative_prompt{
262
+ }
263
+
264
+ #txt2img_progressbar, #img2img_progressbar, #ti_progressbar{
265
+ position: absolute;
266
+ z-index: 1000;
267
+ right: 0;
268
+ padding-left: 5px;
269
+ padding-right: 5px;
270
+ display: block;
271
+ }
272
+
273
+ #txt2img_progress_row, #img2img_progress_row{
274
+ margin-bottom: 10px;
275
+ margin-top: -18px;
276
+ }
277
+
278
+ .progressDiv{
279
+ width: 100%;
280
+ height: 20px;
281
+ background: #b4c0cc;
282
+ border-radius: 8px;
283
+ }
284
+
285
+ .dark .progressDiv{
286
+ background: #424c5b;
287
+ }
288
+
289
+ .progressDiv .progress{
290
+ width: 0%;
291
+ height: 20px;
292
+ background: #0060df;
293
+ color: white;
294
+ font-weight: bold;
295
+ line-height: 20px;
296
+ padding: 0 8px 0 0;
297
+ text-align: right;
298
+ border-radius: 8px;
299
+ }
300
+
301
+ #lightboxModal{
302
+ display: none;
303
+ position: fixed;
304
+ z-index: 1001;
305
+ padding-top: 100px;
306
+ left: 0;
307
+ top: 0;
308
+ width: 100%;
309
+ height: 100%;
310
+ overflow: auto;
311
+ background-color: rgba(20, 20, 20, 0.95);
312
+ user-select: none;
313
+ -webkit-user-select: none;
314
+ }
315
+
316
+ .modalControls {
317
+ display: grid;
318
+ grid-template-columns: 32px auto 1fr 32px;
319
+ grid-template-areas: "zoom tile space close";
320
+ position: absolute;
321
+ top: 0;
322
+ left: 0;
323
+ right: 0;
324
+ padding: 16px;
325
+ gap: 16px;
326
+ background-color: rgba(0,0,0,0.2);
327
+ }
328
+
329
+ .modalClose {
330
+ grid-area: close;
331
+ }
332
+
333
+ .modalZoom {
334
+ grid-area: zoom;
335
+ }
336
+
337
+ .modalTileImage {
338
+ grid-area: tile;
339
+ }
340
+
341
+ .modalClose,
342
+ .modalZoom,
343
+ .modalTileImage {
344
+ color: white;
345
+ font-size: 35px;
346
+ font-weight: bold;
347
+ cursor: pointer;
348
+ }
349
+
350
+ .modalClose:hover,
351
+ .modalClose:focus,
352
+ .modalZoom:hover,
353
+ .modalZoom:focus {
354
+ color: #999;
355
+ text-decoration: none;
356
+ cursor: pointer;
357
+ }
358
+
359
+ #modalImage {
360
+ display: block;
361
+ margin-left: auto;
362
+ margin-right: auto;
363
+ margin-top: auto;
364
+ width: auto;
365
+ }
366
+
367
+ .modalImageFullscreen {
368
+ object-fit: contain;
369
+ height: 90%;
370
+ }
371
+
372
+ .modalPrev,
373
+ .modalNext {
374
+ cursor: pointer;
375
+ position: absolute;
376
+ top: 50%;
377
+ width: auto;
378
+ padding: 16px;
379
+ margin-top: -50px;
380
+ color: white;
381
+ font-weight: bold;
382
+ font-size: 20px;
383
+ transition: 0.6s ease;
384
+ border-radius: 0 3px 3px 0;
385
+ user-select: none;
386
+ -webkit-user-select: none;
387
+ }
388
+
389
+ .modalNext {
390
+ right: 0;
391
+ border-radius: 3px 0 0 3px;
392
+ }
393
+
394
+ .modalPrev:hover,
395
+ .modalNext:hover {
396
+ background-color: rgba(0, 0, 0, 0.8);
397
+ }
398
+
399
+ #imageARPreview{
400
+ position:absolute;
401
+ top:0px;
402
+ left:0px;
403
+ border:2px solid red;
404
+ background:rgba(255, 0, 0, 0.3);
405
+ z-index: 900;
406
+ pointer-events:none;
407
+ display:none
408
+ }
409
+
410
+ #txt2img_interrupt, #img2img_interrupt{
411
+ position: absolute;
412
+ width: 50%;
413
+ height: 72px;
414
+ background: #b4c0cc;
415
+ border-radius: 0px;
416
+ display: none;
417
+ }
418
+
419
+ #txt2img_skip, #img2img_skip{
420
+ position: absolute;
421
+ width: 50%;
422
+ right: 0px;
423
+ height: 72px;
424
+ background: #b4c0cc;
425
+ border-radius: 0px;
426
+ display: none;
427
+ }
428
+
429
+ .red {
430
+ color: red;
431
+ }
432
+
433
+ .gallery-item {
434
+ --tw-bg-opacity: 0 !important;
435
+ }
436
+
437
+ #context-menu{
438
+ z-index:9999;
439
+ position:absolute;
440
+ display:block;
441
+ padding:0px 0;
442
+ border:2px solid #a55000;
443
+ border-radius:8px;
444
+ box-shadow:1px 1px 2px #CE6400;
445
+ width: 200px;
446
+ }
447
+
448
+ .context-menu-items{
449
+ list-style: none;
450
+ margin: 0;
451
+ padding: 0;
452
+ }
453
+
454
+ .context-menu-items a{
455
+ display:block;
456
+ padding:5px;
457
+ cursor:pointer;
458
+ }
459
+
460
+ .context-menu-items a:hover{
461
+ background: #a55000;
462
+ }
463
+
464
+ #quicksettings {
465
+ gap: 0.4em;
466
+ }
467
+
468
+ #quicksettings > div{
469
+ border: none;
470
+ background: none;
471
+ flex: unset;
472
+ gap: 0.5em;
473
+ }
474
+
475
+ #quicksettings > div > div{
476
+ max-width: 32em;
477
+ min-width: 24em;
478
+ padding: 0;
479
+ }
480
+
481
+ #refresh_sd_model_checkpoint, #refresh_sd_hypernetwork, #refresh_train_hypernetwork_name, #refresh_train_embedding_name{
482
+ max-width: 2.5em;
483
+ min-width: 2.5em;
484
+ height: 2.4em;
485
+ }
486
+
487
+
488
+ canvas[key="mask"] {
489
+ z-index: 12 !important;
490
+ filter: invert();
491
+ mix-blend-mode: multiply;
492
+ pointer-events: none;
493
+ }
494
+
495
+
496
+ /* gradio 3.4.1 stuff for editable scrollbar values */
497
+ .gr-box > div > div > input.gr-text-input{
498
+ position: absolute;
499
+ right: 0.5em;
500
+ top: -0.6em;
501
+ z-index: 200;
502
+ width: 8em;
503
+ }
504
+ #quicksettings .gr-box > div > div > input.gr-text-input {
505
+ top: -1.12em;
506
+ }
507
+
508
+ .row.gr-compact{
509
+ overflow: visible;
510
+ }
511
+
512
+ #img2img_image, #img2img_image > .h-60, #img2img_image > .h-60 > div, #img2img_image > .h-60 > div > img,
513
+ img2maskimg, #img2maskimg > .h-60, #img2maskimg > .h-60 > div, #img2maskimg > .h-60 > div > img
514
+ {
515
+ height: 480px !important;
516
+ max-height: 480px !important;
517
+ min-height: 480px !important;
518
+ }
ui-config.json ADDED
@@ -0,0 +1,292 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "txt2img/Prompt/visible": true,
3
+ "txt2img/Prompt/value": "",
4
+ "txt2img/Negative prompt/visible": true,
5
+ "txt2img/Negative prompt/value": "",
6
+ "txt2img/Sampling Steps/visible": true,
7
+ "txt2img/Sampling Steps/value": 20,
8
+ "txt2img/Sampling Steps/minimum": 1,
9
+ "txt2img/Sampling Steps/maximum": 150,
10
+ "txt2img/Sampling Steps/step": 1,
11
+ "txt2img/Sampling method/visible": true,
12
+ "txt2img/Sampling method/value": "Euler a",
13
+ "txt2img/Width/visible": true,
14
+ "txt2img/Width/value": 512,
15
+ "txt2img/Width/minimum": 64,
16
+ "txt2img/Width/maximum": 2048,
17
+ "txt2img/Width/step": 64,
18
+ "txt2img/Height/visible": true,
19
+ "txt2img/Height/value": 512,
20
+ "txt2img/Height/minimum": 64,
21
+ "txt2img/Height/maximum": 2048,
22
+ "txt2img/Height/step": 64,
23
+ "txt2img/Restore faces/visible": true,
24
+ "txt2img/Restore faces/value": false,
25
+ "txt2img/Tiling/visible": true,
26
+ "txt2img/Tiling/value": false,
27
+ "txt2img/Highres. fix/visible": true,
28
+ "txt2img/Highres. fix/value": false,
29
+ "txt2img/Scale latent/visible": true,
30
+ "txt2img/Scale latent/value": false,
31
+ "txt2img/Denoising strength/visible": true,
32
+ "txt2img/Denoising strength/value": 0.7,
33
+ "txt2img/Denoising strength/minimum": 0.0,
34
+ "txt2img/Denoising strength/maximum": 1.0,
35
+ "txt2img/Denoising strength/step": 0.01,
36
+ "txt2img/Batch count/visible": true,
37
+ "txt2img/Batch count/value": 1,
38
+ "txt2img/Batch count/minimum": 1,
39
+ "txt2img/Batch count/maximum": 16,
40
+ "txt2img/Batch count/step": 1,
41
+ "txt2img/Batch size/visible": true,
42
+ "txt2img/Batch size/value": 1,
43
+ "txt2img/Batch size/minimum": 1,
44
+ "txt2img/Batch size/maximum": 8,
45
+ "txt2img/Batch size/step": 1,
46
+ "txt2img/CFG Scale/visible": true,
47
+ "txt2img/CFG Scale/value": 7.0,
48
+ "txt2img/CFG Scale/minimum": 1.0,
49
+ "txt2img/CFG Scale/maximum": 30.0,
50
+ "txt2img/CFG Scale/step": 0.5,
51
+ "txt2img/Seed/visible": true,
52
+ "txt2img/Seed/value": -1.0,
53
+ "txt2img/Extra/visible": true,
54
+ "txt2img/Extra/value": false,
55
+ "txt2img/Variation seed/visible": true,
56
+ "txt2img/Variation seed/value": -1.0,
57
+ "txt2img/Variation strength/visible": true,
58
+ "txt2img/Variation strength/value": 0.0,
59
+ "txt2img/Variation strength/minimum": 0,
60
+ "txt2img/Variation strength/maximum": 1,
61
+ "txt2img/Variation strength/step": 0.01,
62
+ "txt2img/Resize seed from width/visible": true,
63
+ "txt2img/Resize seed from width/value": 0,
64
+ "txt2img/Resize seed from width/minimum": 0,
65
+ "txt2img/Resize seed from width/maximum": 2048,
66
+ "txt2img/Resize seed from width/step": 64,
67
+ "txt2img/Resize seed from height/visible": true,
68
+ "txt2img/Resize seed from height/value": 0,
69
+ "txt2img/Resize seed from height/minimum": 0,
70
+ "txt2img/Resize seed from height/maximum": 2048,
71
+ "txt2img/Resize seed from height/step": 64,
72
+ "customscript/prompt_matrix.py/txt2img/Put variable parts at start of prompt/value": false,
73
+ "customscript/prompts_from_file.py/txt2img/Show Textbox/value": false,
74
+ "customscript/xy_grid.py/txt2img/X values/value": "",
75
+ "customscript/xy_grid.py/txt2img/Y values/value": "",
76
+ "customscript/xy_grid.py/txt2img/Draw legend/value": true,
77
+ "customscript/xy_grid.py/txt2img/Keep -1 for seeds/value": false,
78
+ "txt2img/Make Zip when Save?/visible": true,
79
+ "txt2img/Make Zip when Save?/value": false,
80
+ "img2img/Prompt/visible": true,
81
+ "img2img/Prompt/value": "",
82
+ "img2img/Negative prompt/visible": true,
83
+ "img2img/Negative prompt/value": "",
84
+ "img2img/Mask blur/visible": true,
85
+ "img2img/Mask blur/value": 4,
86
+ "img2img/Mask blur/minimum": 0,
87
+ "img2img/Mask blur/maximum": 64,
88
+ "img2img/Mask blur/step": 1,
89
+ "img2img/Mask mode/visible": true,
90
+ "img2img/Mask mode/value": "Draw mask",
91
+ "img2img/Masking mode/visible": true,
92
+ "img2img/Masking mode/value": "Inpaint masked",
93
+ "img2img/Masked content/visible": true,
94
+ "img2img/Masked content/value": "original",
95
+ "img2img/Inpaint at full resolution/visible": true,
96
+ "img2img/Inpaint at full resolution/value": false,
97
+ "img2img/Inpaint at full resolution padding, pixels/visible": true,
98
+ "img2img/Inpaint at full resolution padding, pixels/value": 32,
99
+ "img2img/Inpaint at full resolution padding, pixels/minimum": 0,
100
+ "img2img/Inpaint at full resolution padding, pixels/maximum": 256,
101
+ "img2img/Inpaint at full resolution padding, pixels/step": 4,
102
+ "img2img/Input directory/visible": true,
103
+ "img2img/Input directory/value": "",
104
+ "img2img/Output directory/visible": true,
105
+ "img2img/Output directory/value": "",
106
+ "img2img/Resize mode/visible": true,
107
+ "img2img/Resize mode/value": "Just resize",
108
+ "img2img/Sampling Steps/visible": true,
109
+ "img2img/Sampling Steps/value": 20,
110
+ "img2img/Sampling Steps/minimum": 1,
111
+ "img2img/Sampling Steps/maximum": 150,
112
+ "img2img/Sampling Steps/step": 1,
113
+ "img2img/Sampling method/visible": true,
114
+ "img2img/Sampling method/value": "Euler a",
115
+ "img2img/Width/visible": true,
116
+ "img2img/Width/value": 512,
117
+ "img2img/Width/minimum": 64,
118
+ "img2img/Width/maximum": 2048,
119
+ "img2img/Width/step": 64,
120
+ "img2img/Height/visible": true,
121
+ "img2img/Height/value": 512,
122
+ "img2img/Height/minimum": 64,
123
+ "img2img/Height/maximum": 2048,
124
+ "img2img/Height/step": 64,
125
+ "img2img/Restore faces/visible": true,
126
+ "img2img/Restore faces/value": false,
127
+ "img2img/Tiling/visible": true,
128
+ "img2img/Tiling/value": false,
129
+ "img2img/Batch count/visible": true,
130
+ "img2img/Batch count/value": 1,
131
+ "img2img/Batch count/minimum": 1,
132
+ "img2img/Batch count/maximum": 16,
133
+ "img2img/Batch count/step": 1,
134
+ "img2img/Batch size/visible": true,
135
+ "img2img/Batch size/value": 1,
136
+ "img2img/Batch size/minimum": 1,
137
+ "img2img/Batch size/maximum": 8,
138
+ "img2img/Batch size/step": 1,
139
+ "img2img/CFG Scale/visible": true,
140
+ "img2img/CFG Scale/value": 7.0,
141
+ "img2img/CFG Scale/minimum": 1.0,
142
+ "img2img/CFG Scale/maximum": 30.0,
143
+ "img2img/CFG Scale/step": 0.5,
144
+ "img2img/Denoising strength/visible": true,
145
+ "img2img/Denoising strength/value": 0.75,
146
+ "img2img/Denoising strength/minimum": 0.0,
147
+ "img2img/Denoising strength/maximum": 1.0,
148
+ "img2img/Denoising strength/step": 0.01,
149
+ "img2img/Seed/visible": true,
150
+ "img2img/Seed/value": -1.0,
151
+ "img2img/Extra/visible": true,
152
+ "img2img/Extra/value": false,
153
+ "img2img/Variation seed/visible": true,
154
+ "img2img/Variation seed/value": -1.0,
155
+ "img2img/Variation strength/visible": true,
156
+ "img2img/Variation strength/value": 0.0,
157
+ "img2img/Variation strength/minimum": 0,
158
+ "img2img/Variation strength/maximum": 1,
159
+ "img2img/Variation strength/step": 0.01,
160
+ "img2img/Resize seed from width/visible": true,
161
+ "img2img/Resize seed from width/value": 0,
162
+ "img2img/Resize seed from width/minimum": 0,
163
+ "img2img/Resize seed from width/maximum": 2048,
164
+ "img2img/Resize seed from width/step": 64,
165
+ "img2img/Resize seed from height/visible": true,
166
+ "img2img/Resize seed from height/value": 0,
167
+ "img2img/Resize seed from height/minimum": 0,
168
+ "img2img/Resize seed from height/maximum": 2048,
169
+ "img2img/Resize seed from height/step": 64,
170
+ "customscript/img2imgalt.py/img2img/Original prompt/value": "",
171
+ "customscript/img2imgalt.py/img2img/Original negative prompt/value": "",
172
+ "customscript/img2imgalt.py/img2img/Decode CFG scale/value": 1.0,
173
+ "customscript/img2imgalt.py/img2img/Decode CFG scale/minimum": 0.0,
174
+ "customscript/img2imgalt.py/img2img/Decode CFG scale/maximum": 15.0,
175
+ "customscript/img2imgalt.py/img2img/Decode CFG scale/step": 0.1,
176
+ "customscript/img2imgalt.py/img2img/Decode steps/value": 50,
177
+ "customscript/img2imgalt.py/img2img/Decode steps/minimum": 1,
178
+ "customscript/img2imgalt.py/img2img/Decode steps/maximum": 150,
179
+ "customscript/img2imgalt.py/img2img/Decode steps/step": 1,
180
+ "customscript/img2imgalt.py/img2img/Randomness/value": 0.0,
181
+ "customscript/img2imgalt.py/img2img/Randomness/minimum": 0.0,
182
+ "customscript/img2imgalt.py/img2img/Randomness/maximum": 1.0,
183
+ "customscript/img2imgalt.py/img2img/Randomness/step": 0.01,
184
+ "customscript/img2imgalt.py/img2img/Sigma adjustment for finding noise for image/value": false,
185
+ "customscript/loopback.py/img2img/Loops/value": 4,
186
+ "customscript/loopback.py/img2img/Loops/minimum": 1,
187
+ "customscript/loopback.py/img2img/Loops/maximum": 32,
188
+ "customscript/loopback.py/img2img/Loops/step": 1,
189
+ "customscript/loopback.py/img2img/Denoising strength change factor/value": 1,
190
+ "customscript/loopback.py/img2img/Denoising strength change factor/minimum": 0.9,
191
+ "customscript/loopback.py/img2img/Denoising strength change factor/maximum": 1.1,
192
+ "customscript/loopback.py/img2img/Denoising strength change factor/step": 0.01,
193
+ "customscript/outpainting_mk_2.py/img2img/Pixels to expand/value": 128,
194
+ "customscript/outpainting_mk_2.py/img2img/Pixels to expand/minimum": 8,
195
+ "customscript/outpainting_mk_2.py/img2img/Pixels to expand/maximum": 256,
196
+ "customscript/outpainting_mk_2.py/img2img/Pixels to expand/step": 8,
197
+ "customscript/outpainting_mk_2.py/img2img/Mask blur/value": 8,
198
+ "customscript/outpainting_mk_2.py/img2img/Mask blur/minimum": 0,
199
+ "customscript/outpainting_mk_2.py/img2img/Mask blur/maximum": 64,
200
+ "customscript/outpainting_mk_2.py/img2img/Mask blur/step": 1,
201
+ "customscript/outpainting_mk_2.py/img2img/Fall-off exponent (lower=higher detail)/value": 1.0,
202
+ "customscript/outpainting_mk_2.py/img2img/Fall-off exponent (lower=higher detail)/minimum": 0.0,
203
+ "customscript/outpainting_mk_2.py/img2img/Fall-off exponent (lower=higher detail)/maximum": 4.0,
204
+ "customscript/outpainting_mk_2.py/img2img/Fall-off exponent (lower=higher detail)/step": 0.01,
205
+ "customscript/outpainting_mk_2.py/img2img/Color variation/value": 0.05,
206
+ "customscript/outpainting_mk_2.py/img2img/Color variation/minimum": 0.0,
207
+ "customscript/outpainting_mk_2.py/img2img/Color variation/maximum": 1.0,
208
+ "customscript/outpainting_mk_2.py/img2img/Color variation/step": 0.01,
209
+ "customscript/poor_mans_outpainting.py/img2img/Pixels to expand/value": 128,
210
+ "customscript/poor_mans_outpainting.py/img2img/Pixels to expand/minimum": 8,
211
+ "customscript/poor_mans_outpainting.py/img2img/Pixels to expand/maximum": 256,
212
+ "customscript/poor_mans_outpainting.py/img2img/Pixels to expand/step": 8,
213
+ "customscript/poor_mans_outpainting.py/img2img/Mask blur/value": 4,
214
+ "customscript/poor_mans_outpainting.py/img2img/Mask blur/minimum": 0,
215
+ "customscript/poor_mans_outpainting.py/img2img/Mask blur/maximum": 64,
216
+ "customscript/poor_mans_outpainting.py/img2img/Mask blur/step": 1,
217
+ "customscript/poor_mans_outpainting.py/img2img/Masked content/value": "fill",
218
+ "customscript/prompt_matrix.py/img2img/Put variable parts at start of prompt/value": false,
219
+ "customscript/prompts_from_file.py/img2img/Show Textbox/value": false,
220
+ "customscript/sd_upscale.py/img2img/Tile overlap/value": 64,
221
+ "customscript/sd_upscale.py/img2img/Tile overlap/minimum": 0,
222
+ "customscript/sd_upscale.py/img2img/Tile overlap/maximum": 256,
223
+ "customscript/sd_upscale.py/img2img/Tile overlap/step": 16,
224
+ "customscript/sd_upscale.py/img2img/Upscaler/value": "None",
225
+ "customscript/xy_grid.py/img2img/X values/value": "",
226
+ "customscript/xy_grid.py/img2img/Y values/value": "",
227
+ "customscript/xy_grid.py/img2img/Draw legend/value": true,
228
+ "customscript/xy_grid.py/img2img/Keep -1 for seeds/value": false,
229
+ "img2img/Make Zip when Save?/visible": true,
230
+ "img2img/Make Zip when Save?/value": false,
231
+ "extras/Resize/visible": true,
232
+ "extras/Resize/value": 2,
233
+ "extras/Resize/minimum": 1.0,
234
+ "extras/Resize/maximum": 4.0,
235
+ "extras/Resize/step": 0.05,
236
+ "extras/Upscaler 1/visible": true,
237
+ "extras/Upscaler 1/value": "None",
238
+ "extras/Upscaler 2/visible": true,
239
+ "extras/Upscaler 2/value": "None",
240
+ "extras/Upscaler 2 visibility/visible": true,
241
+ "extras/Upscaler 2 visibility/value": 1,
242
+ "extras/Upscaler 2 visibility/minimum": 0.0,
243
+ "extras/Upscaler 2 visibility/maximum": 1.0,
244
+ "extras/Upscaler 2 visibility/step": 0.001,
245
+ "extras/GFPGAN visibility/visible": true,
246
+ "extras/GFPGAN visibility/value": 0,
247
+ "extras/GFPGAN visibility/minimum": 0.0,
248
+ "extras/GFPGAN visibility/maximum": 1.0,
249
+ "extras/GFPGAN visibility/step": 0.001,
250
+ "extras/CodeFormer visibility/visible": true,
251
+ "extras/CodeFormer visibility/value": 0,
252
+ "extras/CodeFormer visibility/minimum": 0.0,
253
+ "extras/CodeFormer visibility/maximum": 1.0,
254
+ "extras/CodeFormer visibility/step": 0.001,
255
+ "extras/CodeFormer weight (0 = maximum effect, 1 = minimum effect)/visible": true,
256
+ "extras/CodeFormer weight (0 = maximum effect, 1 = minimum effect)/value": 0,
257
+ "extras/CodeFormer weight (0 = maximum effect, 1 = minimum effect)/minimum": 0.0,
258
+ "extras/CodeFormer weight (0 = maximum effect, 1 = minimum effect)/maximum": 1.0,
259
+ "extras/CodeFormer weight (0 = maximum effect, 1 = minimum effect)/step": 0.001,
260
+ "extras/Width/visible": true,
261
+ "extras/Width/value": 512,
262
+ "extras/Height/visible": true,
263
+ "extras/Height/value": 512,
264
+ "extras/Crop to fit/visible": true,
265
+ "extras/Crop to fit/value": true,
266
+ "customscript/xy_grid.py/txt2img/Include Separate Images/value": true,
267
+ "customscript/xy_grid.py/img2img/Include Separate Images/value": true,
268
+ "customscript/img2imgalt.py/img2img/Override `Sampling method` to Euler?(this method is built for it)/value": true,
269
+ "customscript/img2imgalt.py/img2img/Override `prompt` to the same value as `original prompt`?(and `negative prompt`)/value": true,
270
+ "customscript/img2imgalt.py/img2img/Override `Sampling Steps` to the same value as `Decode steps`?/value": true,
271
+ "customscript/img2imgalt.py/img2img/Override `Denoising strength` to 1?/value": true,
272
+ "txt2img/Firstpass width/visible": true,
273
+ "txt2img/Firstpass width/value": 0,
274
+ "txt2img/Firstpass width/minimum": 0,
275
+ "txt2img/Firstpass width/maximum": 1024,
276
+ "txt2img/Firstpass width/step": 64,
277
+ "txt2img/Firstpass height/visible": true,
278
+ "txt2img/Firstpass height/value": 0,
279
+ "txt2img/Firstpass height/minimum": 0,
280
+ "txt2img/Firstpass height/maximum": 1024,
281
+ "txt2img/Firstpass height/step": 64,
282
+ "txt2img/Style 1/value": "None",
283
+ "txt2img/Style 2/value": "None",
284
+ "img2img/Style 1/value": "None",
285
+ "img2img/Style 2/value": "None",
286
+ "extras/Input directory/visible": true,
287
+ "extras/Input directory/value": "",
288
+ "extras/Output directory/visible": true,
289
+ "extras/Output directory/value": "",
290
+ "extras/Show result images/visible": true,
291
+ "extras/Show result images/value": true
292
+ }
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,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import threading
3
+ import time
4
+ import importlib
5
+ import signal
6
+ import threading
7
+
8
+ from fastapi.middleware.gzip import GZipMiddleware
9
+
10
+ from modules.paths import script_path
11
+
12
+ from modules import devices, sd_samplers
13
+ import modules.codeformer_model as codeformer
14
+ import modules.extras
15
+ import modules.face_restoration
16
+ import modules.gfpgan_model as gfpgan
17
+ import modules.img2img
18
+
19
+ import modules.lowvram
20
+ import modules.paths
21
+ import modules.scripts
22
+ import modules.sd_hijack
23
+ import modules.sd_models
24
+ import modules.shared as shared
25
+ import modules.txt2img
26
+
27
+ import modules.ui
28
+ from modules import devices
29
+ from modules import modelloader
30
+ from modules.paths import script_path
31
+ from modules.shared import cmd_opts
32
+ import modules.hypernetworks.hypernetwork
33
+
34
+
35
+ queue_lock = threading.Lock()
36
+
37
+
38
+ def wrap_queued_call(func):
39
+ def f(*args, **kwargs):
40
+ with queue_lock:
41
+ res = func(*args, **kwargs)
42
+
43
+ return res
44
+
45
+ return f
46
+
47
+
48
+ def wrap_gradio_gpu_call(func, extra_outputs=None):
49
+ def f(*args, **kwargs):
50
+ devices.torch_gc()
51
+
52
+ shared.state.sampling_step = 0
53
+ shared.state.job_count = -1
54
+ shared.state.job_no = 0
55
+ shared.state.job_timestamp = shared.state.get_job_timestamp()
56
+ shared.state.current_latent = None
57
+ shared.state.current_image = None
58
+ shared.state.current_image_sampling_step = 0
59
+ shared.state.skipped = False
60
+ shared.state.interrupted = False
61
+ shared.state.textinfo = None
62
+
63
+ with queue_lock:
64
+ res = func(*args, **kwargs)
65
+
66
+ shared.state.job = ""
67
+ shared.state.job_count = 0
68
+
69
+ devices.torch_gc()
70
+
71
+ return res
72
+
73
+ return modules.ui.wrap_gradio_call(f, extra_outputs=extra_outputs)
74
+
75
+ def initialize():
76
+ modelloader.cleanup_models()
77
+ modules.sd_models.setup_model()
78
+ codeformer.setup_model(cmd_opts.codeformer_models_path)
79
+ gfpgan.setup_model(cmd_opts.gfpgan_models_path)
80
+ shared.face_restorers.append(modules.face_restoration.FaceRestoration())
81
+ modelloader.load_upscalers()
82
+
83
+ modules.scripts.load_scripts(os.path.join(script_path, "scripts"))
84
+
85
+ shared.sd_model = modules.sd_models.load_model()
86
+ shared.opts.onchange("sd_model_checkpoint", wrap_queued_call(lambda: modules.sd_models.reload_model_weights(shared.sd_model)))
87
+ shared.opts.onchange("sd_hypernetwork", wrap_queued_call(lambda: modules.hypernetworks.hypernetwork.load_hypernetwork(shared.opts.sd_hypernetwork)))
88
+ shared.opts.onchange("sd_hypernetwork_strength", modules.hypernetworks.hypernetwork.apply_strength)
89
+
90
+
91
+ def webui():
92
+ initialize()
93
+
94
+ # make the program just exit at ctrl+c without waiting for anything
95
+ def sigint_handler(sig, frame):
96
+ print(f'Interrupted with signal {sig} in {frame}')
97
+ os._exit(0)
98
+
99
+ signal.signal(signal.SIGINT, sigint_handler)
100
+
101
+ while 1:
102
+
103
+ demo = modules.ui.create_ui(wrap_gradio_gpu_call=wrap_gradio_gpu_call)
104
+
105
+ app, local_url, share_url = demo.launch(
106
+ share=cmd_opts.share,
107
+ server_name="0.0.0.0" if cmd_opts.listen else None,
108
+ server_port=cmd_opts.port,
109
+ debug=cmd_opts.gradio_debug,
110
+ auth=[tuple(cred.split(':')) for cred in cmd_opts.gradio_auth.strip('"').split(',')] if cmd_opts.gradio_auth else None,
111
+ inbrowser=cmd_opts.autolaunch,
112
+ prevent_thread_lock=True
113
+ )
114
+
115
+ app.add_middleware(GZipMiddleware, minimum_size=1000)
116
+
117
+ while 1:
118
+ time.sleep(0.5)
119
+ if getattr(demo, 'do_restart', False):
120
+ time.sleep(0.5)
121
+ demo.close()
122
+ time.sleep(0.5)
123
+ break
124
+
125
+ sd_samplers.set_samplers()
126
+
127
+ print('Reloading Custom Scripts')
128
+ modules.scripts.reload_scripts(os.path.join(script_path, "scripts"))
129
+ print('Reloading modules: modules.ui')
130
+ importlib.reload(modules.ui)
131
+ print('Refreshing Model List')
132
+ modules.sd_models.list_models()
133
+ print('Restarting Gradio')
134
+
135
+
136
+ if __name__ == "__main__":
137
+ 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 prerequisites
86
+ for preq in "${GIT}" "${python_cmd}"
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}"