Skip to content

Commit 243253f

Browse files
Merge branch 'AUTOMATIC1111:master' into master
2 parents d9e4e4d + 20a860b commit 243253f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+3146
-1529
lines changed

javascript/extensions.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
function extensions_apply(_, _){
3+
disable = []
4+
update = []
5+
gradioApp().querySelectorAll('#extensions input[type="checkbox"]').forEach(function(x){
6+
if(x.name.startsWith("enable_") && ! x.checked)
7+
disable.push(x.name.substr(7))
8+
9+
if(x.name.startsWith("update_") && x.checked)
10+
update.push(x.name.substr(7))
11+
})
12+
13+
restart_reload()
14+
15+
return [JSON.stringify(disable), JSON.stringify(update)]
16+
}
17+
18+
function extensions_check(){
19+
gradioApp().querySelectorAll('#extensions .extension_status').forEach(function(x){
20+
x.innerHTML = "Loading..."
21+
})
22+
23+
return []
24+
}
25+
26+
function install_extension_from_index(button, url){
27+
button.disabled = "disabled"
28+
button.value = "Installing..."
29+
30+
textarea = gradioApp().querySelector('#extension_to_install textarea')
31+
textarea.value = url
32+
textarea.dispatchEvent(new Event("input", { bubbles: true }))
33+
34+
gradioApp().querySelector('#install_extension_button').click()
35+
}

javascript/progressbar.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,21 @@ global_progressbars = {}
33
galleries = {}
44
galleryObservers = {}
55

6+
// this tracks laumnches of window.setTimeout for progressbar to prevent starting a new timeout when the previous is still running
7+
timeoutIds = {}
8+
69
function check_progressbar(id_part, id_progressbar, id_progressbar_span, id_skip, id_interrupt, id_preview, id_gallery){
7-
var progressbar = gradioApp().getElementById(id_progressbar)
10+
// gradio 3.8's enlightened approach allows them to create two nested div elements inside each other with same id
11+
// every time you use gr.HTML(elem_id='xxx'), so we handle this here
12+
var progressbar = gradioApp().querySelector("#"+id_progressbar+" #"+id_progressbar)
13+
var progressbarParent
14+
if(progressbar){
15+
progressbarParent = gradioApp().querySelector("#"+id_progressbar)
16+
} else{
17+
progressbar = gradioApp().getElementById(id_progressbar)
18+
progressbarParent = null
19+
}
20+
821
var skip = id_skip ? gradioApp().getElementById(id_skip) : null
922
var interrupt = gradioApp().getElementById(id_interrupt)
1023

@@ -26,18 +39,26 @@ function check_progressbar(id_part, id_progressbar, id_progressbar_span, id_skip
2639
global_progressbars[id_progressbar] = progressbar
2740

2841
var mutationObserver = new MutationObserver(function(m){
42+
if(timeoutIds[id_part]) return;
43+
2944
preview = gradioApp().getElementById(id_preview)
3045
gallery = gradioApp().getElementById(id_gallery)
3146

3247
if(preview != null && gallery != null){
3348
preview.style.width = gallery.clientWidth + "px"
3449
preview.style.height = gallery.clientHeight + "px"
50+
if(progressbarParent) progressbar.style.width = progressbarParent.clientWidth + "px"
3551

3652
//only watch gallery if there is a generation process going on
3753
check_gallery(id_gallery);
3854

3955
var progressDiv = gradioApp().querySelectorAll('#' + id_progressbar_span).length > 0;
40-
if(!progressDiv){
56+
if(progressDiv){
57+
timeoutIds[id_part] = window.setTimeout(function() {
58+
timeoutIds[id_part] = null
59+
requestMoreProgress(id_part, id_progressbar_span, id_skip, id_interrupt)
60+
}, 500)
61+
} else{
4162
if (skip) {
4263
skip.style.display = "none"
4364
}
@@ -47,13 +68,10 @@ function check_progressbar(id_part, id_progressbar, id_progressbar_span, id_skip
4768
if (galleryObservers[id_gallery]) {
4869
galleryObservers[id_gallery].disconnect();
4970
galleries[id_gallery] = null;
50-
}
71+
}
5172
}
52-
53-
5473
}
5574

56-
window.setTimeout(function() { requestMoreProgress(id_part, id_progressbar_span, id_skip, id_interrupt) }, 500)
5775
});
5876
mutationObserver.observe( progressbar, { childList:true, subtree:true })
5977
}

launch.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import platform
88

99
dir_repos = "repositories"
10+
dir_extensions = "extensions"
1011
python = sys.executable
1112
git = os.environ.get('GIT', "git")
1213
index_url = os.environ.get('INDEX_URL', "")
@@ -16,11 +17,11 @@ def extract_arg(args, name):
1617
return [x for x in args if x != name], name in args
1718

1819

19-
def run(command, desc=None, errdesc=None):
20+
def run(command, desc=None, errdesc=None, custom_env=None):
2021
if desc is not None:
2122
print(desc)
2223

23-
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
24+
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, env=os.environ if custom_env is None else custom_env)
2425

2526
if result.returncode != 0:
2627

@@ -101,9 +102,27 @@ def version_check(commit):
101102
else:
102103
print("Not a git clone, can't perform version check.")
103104
except Exception as e:
104-
print("versipm check failed",e)
105+
print("version check failed", e)
106+
107+
108+
def run_extensions_installers():
109+
if not os.path.isdir(dir_extensions):
110+
return
111+
112+
for dirname_extension in os.listdir(dir_extensions):
113+
path_installer = os.path.join(dir_extensions, dirname_extension, "install.py")
114+
if not os.path.isfile(path_installer):
115+
continue
116+
117+
try:
118+
env = os.environ.copy()
119+
env['PYTHONPATH'] = os.path.abspath(".")
120+
121+
print(run(f'"{python}" "{path_installer}"', errdesc=f"Error running install.py for extension {dirname_extension}", custom_env=env))
122+
except Exception as e:
123+
print(e, file=sys.stderr)
124+
105125

106-
107126
def prepare_enviroment():
108127
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")
109128
requirements_file = os.environ.get('REQS_FILE', "requirements_versions.txt")
@@ -189,6 +208,8 @@ def prepare_enviroment():
189208

190209
run_pip(f"install -r {requirements_file}", "requirements for Web UI")
191210

211+
run_extensions_installers()
212+
192213
if update_check:
193214
version_check(commit)
194215

localizations/de_DE.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"None": "Nichts",
7171
"Prompt matrix": "Promptmatrix",
7272
"Prompts from file or textbox": "Prompts aus Datei oder Textfeld",
73-
"X/Y plot": "X/Y Graf",
73+
"X/Y plot": "X/Y Graph",
7474
"Put variable parts at start of prompt": "Variable teile am start des Prompt setzen",
7575
"Iterate seed every line": "Iterate seed every line",
7676
"List of prompt inputs": "List of prompt inputs",
@@ -455,4 +455,4 @@
455455
"Only applies to inpainting models. Determines how strongly to mask off the original image for inpainting and img2img. 1.0 means fully masked, which is the default behaviour. 0.0 means a fully unmasked conditioning. Lower values will help preserve the overall composition of the image, but will struggle with large changes.": "Gilt nur für Inpainting-Modelle. Legt fest, wie stark das Originalbild für Inpainting und img2img maskiert werden soll. 1.0 bedeutet vollständig maskiert, was das Standardverhalten ist. 0.0 bedeutet eine vollständig unmaskierte Konditionierung. Niedrigere Werte tragen dazu bei, die Gesamtkomposition des Bildes zu erhalten, sind aber bei großen Änderungen problematisch.",
456456
"List of setting names, separated by commas, for settings that should go to the quick access bar at the top, rather than the usual setting tab. See modules/shared.py for setting names. Requires restarting to apply.": "Liste von Einstellungsnamen, getrennt durch Kommas, für Einstellungen, die in der Schnellzugriffsleiste oben erscheinen sollen, anstatt in dem üblichen Einstellungs-Tab. Siehe modules/shared.py für Einstellungsnamen. Erfordert einen Neustart zur Anwendung.",
457457
"If this values is non-zero, it will be added to seed and used to initialize RNG for noises when using samplers with Eta. You can use this to produce even more variation of images, or you can use this to match images of other software if you know what you are doing.": "Wenn dieser Wert ungleich Null ist, wird er zum Seed addiert und zur Initialisierung des RNG für Noise bei der Verwendung von Samplern mit Eta verwendet. Dies kann verwendet werden, um noch mehr Variationen von Bildern zu erzeugen, oder um Bilder von anderer Software zu erzeugen, wenn Sie wissen, was Sie tun."
458-
}
458+
}

0 commit comments

Comments
 (0)