Merge branch 'beta' of github.com:cmdr2/stable-diffusion-ui into beta

This commit is contained in:
cmdr2 2023-07-15 10:55:50 +05:30
commit 025ee49680
5 changed files with 49 additions and 7 deletions

View File

@ -104,18 +104,21 @@ call python --version
@FOR /F "tokens=* USEBACKQ" %%F IN (`python scripts\get_config.py --default=False net listen_to_network`) DO ( @FOR /F "tokens=* USEBACKQ" %%F IN (`python scripts\get_config.py --default=False net listen_to_network`) DO (
if "%%F" EQU "True" ( if "%%F" EQU "True" (
@SET ED_BIND_IP=0.0.0.0 @FOR /F "tokens=* USEBACKQ" %%G IN (`python scripts\get_config.py --default=0.0.0.0 net bind_ip`) DO (
@SET ED_BIND_IP=%%G
)
) else ( ) else (
@SET ED_BIND_IP=127.0.0.1 @SET ED_BIND_IP=127.0.0.1
) )
) )
@cd stable-diffusion @cd stable-diffusion
@rem set any overrides @rem set any overrides
set HF_HUB_DISABLE_SYMLINKS_WARNING=true set HF_HUB_DISABLE_SYMLINKS_WARNING=true
@uvicorn main:server_api --app-dir "%SD_UI_PATH%" --port %ED_BIND_PORT% --host %ED_BIND_IP% --log-level error @python -m uvicorn main:server_api --app-dir "%SD_UI_PATH%" --port %ED_BIND_PORT% --host %ED_BIND_IP% --log-level error
@pause @pause

View File

@ -72,7 +72,7 @@ export SD_UI_PATH=`pwd`/ui
export ED_BIND_PORT="$( python scripts/get_config.py --default=9000 net listen_port )" export ED_BIND_PORT="$( python scripts/get_config.py --default=9000 net listen_port )"
case "$( python scripts/get_config.py --default=False net listen_to_network )" in case "$( python scripts/get_config.py --default=False net listen_to_network )" in
"True") "True")
export ED_BIND_IP=0.0.0.0 export ED_BIND_IP=$( python scripts/get_config.py --default=0.0.0.0 net bind_ip)
;; ;;
"False") "False")
export ED_BIND_IP=127.0.0.1 export ED_BIND_IP=127.0.0.1

View File

@ -1,6 +1,8 @@
import os import os
import re import re
import time import time
import regex
from datetime import datetime from datetime import datetime
from functools import reduce from functools import reduce
@ -30,11 +32,12 @@ TASK_TEXT_MAPPING = {
"lora_alpha": "LoRA Strength", "lora_alpha": "LoRA Strength",
"use_hypernetwork_model": "Hypernetwork model", "use_hypernetwork_model": "Hypernetwork model",
"hypernetwork_strength": "Hypernetwork Strength", "hypernetwork_strength": "Hypernetwork Strength",
"use_embedding_models": "Embedding models",
"tiling": "Seamless Tiling", "tiling": "Seamless Tiling",
"use_face_correction": "Use Face Correction", "use_face_correction": "Use Face Correction",
"use_upscale": "Use Upscaling", "use_upscale": "Use Upscaling",
"upscale_amount": "Upscale By", "upscale_amount": "Upscale By",
"latent_upscaler_steps": "Latent Upscaler Steps" "latent_upscaler_steps": "Latent Upscaler Steps",
} }
time_placeholders = { time_placeholders = {
@ -202,6 +205,9 @@ def get_printable_request(req: GenerateImageRequest, task_data: TaskData):
req_metadata = req.dict() req_metadata = req.dict()
task_data_metadata = task_data.dict() task_data_metadata = task_data.dict()
app_config = app.getConfig()
using_diffusers = app_config.get("test_diffusers", False)
# Save the metadata in the order defined in TASK_TEXT_MAPPING # Save the metadata in the order defined in TASK_TEXT_MAPPING
metadata = {} metadata = {}
for key in TASK_TEXT_MAPPING.keys(): for key in TASK_TEXT_MAPPING.keys():
@ -209,6 +215,24 @@ def get_printable_request(req: GenerateImageRequest, task_data: TaskData):
metadata[key] = req_metadata[key] metadata[key] = req_metadata[key]
elif key in task_data_metadata: elif key in task_data_metadata:
metadata[key] = task_data_metadata[key] metadata[key] = task_data_metadata[key]
elif key is "use_embedding_models" and using_diffusers:
embeddings_extensions = {".pt", ".bin", ".safetensors"}
def scan_directory(directory_path: str):
used_embeddings = []
for entry in os.scandir(directory_path):
if entry.is_file():
entry_extension = os.path.splitext(entry.name)[1]
if entry_extension not in embeddings_extensions:
continue
embedding_name_regex = regex.compile(r"(^|[\s,])" + regex.escape(os.path.splitext(entry.name)[0]) + r"([+-]*$|[\s,]|[+-]+[\s,])")
if embedding_name_regex.search(req.prompt) or embedding_name_regex.search(req.negative_prompt):
used_embeddings.append(entry.path)
elif entry.is_dir():
used_embeddings.extend(scan_directory(entry.path))
return used_embeddings
used_embeddings = scan_directory(os.path.join(app.MODELS_DIR, "embeddings"))
metadata["use_embedding_models"] = ", ".join(used_embeddings) if len(used_embeddings) > 0 else None
# Clean up the metadata # Clean up the metadata
if req.init_image is None and "prompt_strength" in metadata: if req.init_image is None and "prompt_strength" in metadata:
@ -222,8 +246,7 @@ def get_printable_request(req: GenerateImageRequest, task_data: TaskData):
if task_data.use_upscale != "latent_upscaler" and "latent_upscaler_steps" in metadata: if task_data.use_upscale != "latent_upscaler" and "latent_upscaler_steps" in metadata:
del metadata["latent_upscaler_steps"] del metadata["latent_upscaler_steps"]
app_config = app.getConfig() if not using_diffusers:
if not app_config.get("test_diffusers", False):
for key in (x for x in ["use_lora_model", "lora_alpha", "clip_skip", "tiling", "latent_upscaler_steps"] if x in metadata): for key in (x for x in ["use_lora_model", "lora_alpha", "clip_skip", "tiling", "latent_upscaler_steps"] if x in metadata):
del metadata[key] del metadata[key]

View File

@ -2186,7 +2186,17 @@ function updateEmbeddingsList(filter="") {
} }
} }
embeddingsList.innerHTML = html(modelsOptions.embeddings, "", filter) // Remove after fixing https://github.com/huggingface/diffusers/issues/3922
let warning = ""
if (vramUsageLevelField.value == "low") {
warning = `
<div style="border-color: var(--accent-color); border-width: 4px; border-radius: 1em; border-style: solid; background: black; text-align: center; padding: 1em; margin: 1em; ">
<i class="fa fa-fire" style="color:#f7630c;"></i> Warning: Your GPU memory profile is set to "Low". Embeddings currently only work in "Balanced" mode!
</div>`
}
// END of remove block
embeddingsList.innerHTML = warning + html(modelsOptions.embeddings, "", filter)
embeddingsList.querySelectorAll("button").forEach( (b) => { b.addEventListener("click", onButtonClick)}) embeddingsList.querySelectorAll("button").forEach( (b) => { b.addEventListener("click", onButtonClick)})
} }

View File

@ -1074,6 +1074,12 @@ async function deleteKeys(keyToDelete) {
function modalDialogCloseOnBackdropClick(dialog) { function modalDialogCloseOnBackdropClick(dialog) {
dialog.addEventListener('mousedown', function (event) { dialog.addEventListener('mousedown', function (event) {
// Firefox creates an event with clientX|Y = 0|0 when choosing an <option>.
// Test whether the element interacted with is a child of the dialog, but not the
// dialog itself (the backdrop would be a part of the dialog)
if (dialog.contains(event.target) && dialog != event.target) {
return
}
var rect = dialog.getBoundingClientRect() var rect = dialog.getBoundingClientRect()
var isInDialog=(rect.top <= event.clientY && event.clientY <= rect.top + rect.height var isInDialog=(rect.top <= event.clientY && event.clientY <= rect.top + rect.height
&& rect.left <= event.clientX && event.clientX <= rect.left + rect.width) && rect.left <= event.clientX && event.clientX <= rect.left + rect.width)