Merge beta

This commit is contained in:
JeLuF 2023-07-16 11:16:58 +02:00
commit de36489444
10 changed files with 134 additions and 43 deletions

View File

@ -22,6 +22,7 @@
Our focus continues to remain on an easy installation experience, and an easy user-interface. While still remaining pretty powerful, in terms of features and speed. Our focus continues to remain on an easy installation experience, and an easy user-interface. While still remaining pretty powerful, in terms of features and speed.
### Detailed changelog ### Detailed changelog
* 2.5.45 - 16 Jul 2023 - (beta-only) Fix the image quality of LoRAs, which had degraded in v2.5.44.
* 2.5.44 - 15 Jul 2023 - (beta-only) Support for multiple LoRA files. * 2.5.44 - 15 Jul 2023 - (beta-only) Support for multiple LoRA files.
* 2.5.43 - 9 Jul 2023 - (beta-only) Support for loading Textual Inversion embeddings. You can find the option in the Image Settings panel. Thanks @JeLuf. * 2.5.43 - 9 Jul 2023 - (beta-only) Support for loading Textual Inversion embeddings. You can find the option in the Image Settings panel. Thanks @JeLuf.
* 2.5.43 - 9 Jul 2023 - Improve the startup time of the UI. * 2.5.43 - 9 Jul 2023 - Improve the startup time of the UI.

View File

@ -18,7 +18,7 @@ os_name = platform.system()
modules_to_check = { modules_to_check = {
"torch": ("1.11.0", "1.13.1", "2.0.0"), "torch": ("1.11.0", "1.13.1", "2.0.0"),
"torchvision": ("0.12.0", "0.14.1", "0.15.1"), "torchvision": ("0.12.0", "0.14.1", "0.15.1"),
"sdkit": "1.0.128", "sdkit": "1.0.131",
"stable-diffusion-sdkit": "2.1.4", "stable-diffusion-sdkit": "2.1.4",
"rich": "12.6.0", "rich": "12.6.0",
"uvicorn": "0.19.0", "uvicorn": "0.19.0",

View File

@ -5,7 +5,7 @@ import shutil
import socket import socket
import sys import sys
import traceback import traceback
import shlex import copy
from ruamel.yaml import YAML from ruamel.yaml import YAML
import urllib import urllib
@ -102,7 +102,6 @@ def init_render_threads():
update_render_threads() update_render_threads()
def getConfig(default_val=APP_CONFIG_DEFAULTS): def getConfig(default_val=APP_CONFIG_DEFAULTS):
config_yaml_path = os.path.join(CONFIG_DIR, "..", "config.yaml") config_yaml_path = os.path.join(CONFIG_DIR, "..", "config.yaml")
@ -111,6 +110,11 @@ def getConfig(default_val=APP_CONFIG_DEFAULTS):
if os.path.isfile(config_legacy_yaml): if os.path.isfile(config_legacy_yaml):
shutil.move(config_legacy_yaml, config_yaml_path) shutil.move(config_legacy_yaml, config_yaml_path)
def set_config_on_startup(config: dict):
if (getConfig.__config_on_startup is None):
getConfig.__config_on_startup = copy.deepcopy(config)
config["config_on_startup"] = getConfig.__config_on_startup
if os.path.isfile(config_yaml_path): if os.path.isfile(config_yaml_path):
try: try:
yaml = YAML() yaml = YAML()
@ -126,9 +130,13 @@ def getConfig(default_val=APP_CONFIG_DEFAULTS):
config["net"]["listen_to_network"] = os.getenv("SD_UI_BIND_IP") == "0.0.0.0" config["net"]["listen_to_network"] = os.getenv("SD_UI_BIND_IP") == "0.0.0.0"
else: else:
config["net"]["listen_to_network"] = True config["net"]["listen_to_network"] = True
set_config_on_startup(config)
return config return config
except Exception as e: except Exception as e:
log.warn(traceback.format_exc()) log.warn(traceback.format_exc())
set_config_on_startup(default_val)
return default_val return default_val
else: else:
try: try:
@ -149,8 +157,11 @@ def getConfig(default_val=APP_CONFIG_DEFAULTS):
return getConfig(default_val) return getConfig(default_val)
except Exception as e: except Exception as e:
log.warn(traceback.format_exc()) log.warn(traceback.format_exc())
set_config_on_startup(default_val)
return default_val return default_val
getConfig.__config_on_startup = None
def setConfig(config): def setConfig(config):
try: # config.yaml try: # config.yaml

View File

@ -192,7 +192,14 @@ def get_metadata_entries_for_request(req: GenerateImageRequest, task_data: TaskD
# if text, format it in the text format expected by the UI # if text, format it in the text format expected by the UI
is_txt_format = task_data.metadata_output_format and "txt" in task_data.metadata_output_format.lower().split(",") is_txt_format = task_data.metadata_output_format and "txt" in task_data.metadata_output_format.lower().split(",")
if is_txt_format: if is_txt_format:
metadata = {TASK_TEXT_MAPPING[key]: val for key, val in metadata.items() if key in TASK_TEXT_MAPPING} def format_value(value):
if isinstance(value, list):
return ", ".join([ str(it) for it in value ])
return value
metadata = {
TASK_TEXT_MAPPING[key]: format_value(val) for key, val in metadata.items() if key in TASK_TEXT_MAPPING
}
entries = [metadata.copy() for _ in range(req.num_outputs)] entries = [metadata.copy() for _ in range(req.num_outputs)]
for i, entry in enumerate(entries): for i, entry in enumerate(entries):
@ -232,7 +239,7 @@ def get_printable_request(req: GenerateImageRequest, task_data: TaskData):
used_embeddings.extend(scan_directory(entry.path)) used_embeddings.extend(scan_directory(entry.path))
return used_embeddings return used_embeddings
used_embeddings = scan_directory(os.path.join(app.MODELS_DIR, "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 metadata["use_embedding_models"] = 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:

View File

@ -31,7 +31,7 @@
<h1> <h1>
<img id="logo_img" src="/media/images/icon-512x512.png" > <img id="logo_img" src="/media/images/icon-512x512.png" >
Easy Diffusion Easy Diffusion
<small><span id="version">v2.5.44</span> <span id="updateBranchLabel"></span></small> <small><span id="version">v2.5.45</span> <span id="updateBranchLabel"></span></small>
</h1> </h1>
</div> </div>
<div id="server-status"> <div id="server-status">
@ -147,7 +147,7 @@
</td></tr> </td></tr>
<tr class="pl-5 displayNone" id="clip_skip_config"> <tr class="pl-5 displayNone" id="clip_skip_config">
<td><label for="clip_skip">Clip Skip:</label></td> <td><label for="clip_skip">Clip Skip:</label></td>
<td> <td class="diffusers-restart-needed">
<input id="clip_skip" name="clip_skip" type="checkbox"> <input id="clip_skip" name="clip_skip" type="checkbox">
<a href="https://github.com/easydiffusion/easydiffusion/wiki/Clip-Skip" target="_blank"><i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Click to learn more about Clip Skip</span></i></a> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Clip-Skip" target="_blank"><i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Click to learn more about Clip Skip</span></i></a>
</td> </td>
@ -237,7 +237,10 @@
<td> <td>
<label for="lora_model">LoRA:</label> <label for="lora_model">LoRA:</label>
</td> </td>
<td class="model_entries"></td> <td class="diffusers-restart-needed">
<div class="model_entries"></div>
<button class="add_model_entry"><i class="fa-solid fa-plus"></i> add another LoRA</button>
</td>
</tr> </tr>
<tr class="pl-5"><td><label for="hypernetwork_model">Hypernetwork:</label></td><td> <tr class="pl-5"><td><label for="hypernetwork_model">Hypernetwork:</label></td><td>
<input id="hypernetwork_model" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" /> <input id="hypernetwork_model" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" />
@ -246,7 +249,9 @@
<td><label for="hypernetwork_strength_slider">Hypernetwork Strength:</label></td> <td><label for="hypernetwork_strength_slider">Hypernetwork Strength:</label></td>
<td> <input id="hypernetwork_strength_slider" name="hypernetwork_strength_slider" class="editor-slider" value="100" type="range" min="0" max="100"> <input id="hypernetwork_strength" name="hypernetwork_strength" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)"><br/></td> <td> <input id="hypernetwork_strength_slider" name="hypernetwork_strength_slider" class="editor-slider" value="100" type="range" min="0" max="100"> <input id="hypernetwork_strength" name="hypernetwork_strength" size="4" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)"><br/></td>
</tr> </tr>
<tr id="tiling_container" class="pl-5"><td><label for="tiling">Seamless Tiling:</label></td><td> <tr id="tiling_container" class="pl-5">
<td><label for="tiling">Seamless Tiling:</label></td>
<td class="diffusers-restart-needed">
<select id="tiling" name="tiling"> <select id="tiling" name="tiling">
<option value="none" selected>None</option> <option value="none" selected>None</option>
<option value="x">Horizontal</option> <option value="x">Horizontal</option>
@ -254,7 +259,8 @@
<option value="xy">Both</option> <option value="xy">Both</option>
</select> </select>
<a href="https://github.com/easydiffusion/easydiffusion/wiki/Seamless-Tiling" target="_blank"><i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Click to learn more about Seamless Tiling</span></i></a> <a href="https://github.com/easydiffusion/easydiffusion/wiki/Seamless-Tiling" target="_blank"><i class="fa-solid fa-circle-question help-btn"><span class="simple-tooltip top-left">Click to learn more about Seamless Tiling</span></i></a>
</td></tr> </td>
</tr>
<tr class="pl-5"><td><label for="output_format">Output Format:</label></td><td> <tr class="pl-5"><td><label for="output_format">Output Format:</label></td><td>
<select id="output_format" name="output_format"> <select id="output_format" name="output_format">
<option value="jpeg" selected>jpeg</option> <option value="jpeg" selected>jpeg</option>

View File

@ -900,6 +900,10 @@ div.img-preview img {
white-space: nowrap; white-space: nowrap;
} }
#editor-settings-entries table {
width: 93%;
}
#negative_prompt { #negative_prompt {
width: 100%; width: 100%;
} }
@ -1666,7 +1670,7 @@ body.wait-pause {
} }
.model_entry .model_name { .model_entry .model_name {
width: 70%; width: 65%;
} }
.split-toolbar { display: grid; .split-toolbar { display: grid;
@ -1692,3 +1696,16 @@ body.wait-pause {
#negative-embeddings-button { #negative-embeddings-button {
float: right; float: right;
} }
.diffusers-disabled-on-startup .diffusers-restart-needed {
font-size: 0;
}
.diffusers-disabled-on-startup .diffusers-restart-needed * {
display: none;
}
.diffusers-disabled-on-startup .diffusers-restart-needed::after {
content: "Please restart Easy Diffusion!";
font-size: 10pt;
}

View File

@ -16,9 +16,6 @@ const SETTINGS_IDS_LIST = [
"clip_skip", "clip_skip",
"vae_model", "vae_model",
"hypernetwork_model", "hypernetwork_model",
"lora_model_0",
"lora_model_1",
"lora_model_2",
"sampler_name", "sampler_name",
"width", "width",
"height", "height",
@ -26,9 +23,6 @@ const SETTINGS_IDS_LIST = [
"guidance_scale", "guidance_scale",
"prompt_strength", "prompt_strength",
"hypernetwork_strength", "hypernetwork_strength",
"lora_alpha_0",
"lora_alpha_1",
"lora_alpha_2",
"tiling", "tiling",
"output_format", "output_format",
"output_quality", "output_quality",

View File

@ -292,6 +292,11 @@ const TASK_MAPPING = {
use_lora_model: { use_lora_model: {
name: "LoRA model", name: "LoRA model",
setUI: (use_lora_model) => { setUI: (use_lora_model) => {
// create rows
for (let i = loraModels.length; i < use_lora_model.length; i++) {
createLoraEntry()
}
use_lora_model.forEach((model_name, i) => { use_lora_model.forEach((model_name, i) => {
let field = loraModels[i][0] let field = loraModels[i][0]
const oldVal = field.value const oldVal = field.value
@ -304,9 +309,13 @@ const TASK_MAPPING = {
}) })
// clear the remaining entries // clear the remaining entries
let container = document.querySelector("#lora_model_container .model_entries")
for (let i = use_lora_model.length; i < loraModels.length; i++) { for (let i = use_lora_model.length; i < loraModels.length; i++) {
loraModels[i][0].value = "" let modelEntry = loraModels[i][2]
container.removeChild(modelEntry)
} }
loraModels.splice(use_lora_model.length)
}, },
readUI: () => { readUI: () => {
let values = loraModels.map((e) => e[0].value) let values = loraModels.map((e) => e[0].value)
@ -323,15 +332,23 @@ const TASK_MAPPING = {
lora_alpha: { lora_alpha: {
name: "LoRA Strength", name: "LoRA Strength",
setUI: (lora_alpha) => { setUI: (lora_alpha) => {
for (let i = loraModels.length; i < lora_alpha.length; i++) {
createLoraEntry()
}
lora_alpha.forEach((model_strength, i) => { lora_alpha.forEach((model_strength, i) => {
let field = loraModels[i][1] let field = loraModels[i][1]
field.value = model_strength field.value = model_strength
}) })
// clear the remaining entries // clear the remaining entries
let container = document.querySelector("#lora_model_container .model_entries")
for (let i = lora_alpha.length; i < loraModels.length; i++) { for (let i = lora_alpha.length; i < loraModels.length; i++) {
loraModels[i][1].value = 0 let modelEntry = loraModels[i][2]
container.removeChild(modelEntry)
} }
loraModels.splice(lora_alpha.length)
}, },
readUI: () => { readUI: () => {
let models = loraModels.filter((e) => e[0].value.trim() !== "") let models = loraModels.filter((e) => e[0].value.trim() !== "")

View File

@ -2255,31 +2255,59 @@ promptField.focus()
promptField.selectionStart = promptField.value.length promptField.selectionStart = promptField.value.length
// multi-models // multi-models
function addModelEntry(i, modelContainer, modelsList, modelType, defaultValue, strengthStep) { let modelCount = 0
let nameId = modelType + "_model_" + i
let strengthId = modelType + "_alpha_" + i
const modelEntry = document.createElement("div") function addModelEntry(modelContainer, modelsList, modelType, defaultValue, strengthStep) {
modelEntry.className = "model_entry" let idx = modelCount++
modelEntry.innerHTML = ` let nameId = modelType + "_model_" + idx
let strengthId = modelType + "_alpha_" + idx
const modelElement = document.createElement("div")
modelElement.className = "model_entry"
modelElement.innerHTML = `
<input id="${nameId}" class="model_name" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" /> <input id="${nameId}" class="model_name" type="text" spellcheck="false" autocomplete="off" class="model-filter" data-path="" />
<input id="${strengthId}" class="model_strength" type="number" step="${strengthStep}" style="width: 50pt" value="${defaultValue}" pattern="^-?[0-9]*\.?[0-9]*$" onkeypress="preventNonNumericalInput(event)"><br/> <input id="${strengthId}" class="model_strength" type="number" step="${strengthStep}" style="width: 50pt" value="${defaultValue}" pattern="^-?[0-9]*\.?[0-9]*$" onkeypress="preventNonNumericalInput(event)">
` `
modelContainer.appendChild(modelElement)
let modelName = new ModelDropdown(modelEntry.querySelector(".model_name"), modelType, "None") let modelName = new ModelDropdown(modelElement.querySelector(".model_name"), modelType, "None")
let modelStrength = modelEntry.querySelector(".model_strength") let modelStrength = modelElement.querySelector(".model_strength")
let entry = [modelName, modelStrength, modelElement]
modelContainer.appendChild(modelEntry) let removeBtn = document.createElement("button")
modelsList.push([modelName, modelStrength]) removeBtn.innerHTML = '<i class="fa-solid fa-minus"></i>'
}
function createLoRAEntries() { if (modelsList.length === 0) {
let container = document.querySelector("#lora_model_container .model_entries") removeBtn.classList.add("displayNone")
for (let i = 0; i < 3; i++) {
addModelEntry(i, container, loraModels, "lora", 0.5, 0.02)
} }
removeBtn.addEventListener("click", function() {
let entryIdx = modelsList.indexOf(entry)
modelsList.splice(entryIdx, 1)
modelContainer.removeChild(modelElement)
})
modelElement.appendChild(removeBtn)
modelsList.push(entry)
return modelElement
} }
createLoRAEntries()
function createLoraEntry() {
let container = document.querySelector("#lora_model_container .model_entries")
return addModelEntry(container, loraModels, "lora", 0.5, 0.02)
}
function createLoraEntries() {
let firstEntry = createLoraEntry()
let addLoraBtn = document.querySelector("#lora_model_container .add_model_entry")
addLoraBtn.addEventListener("click", () => {
createLoraEntry()
})
}
createLoraEntries()
// chrome-like spinners only on hover // chrome-like spinners only on hover
// function showSpinnerOnlyOnHover(e) { // function showSpinnerOnlyOnHover(e) {

View File

@ -424,6 +424,16 @@ async function getAppConfig() {
const testDiffusersEnabled = config.test_diffusers && config.update_branch !== "main" const testDiffusersEnabled = config.test_diffusers && config.update_branch !== "main"
testDiffusers.checked = testDiffusersEnabled testDiffusers.checked = testDiffusersEnabled
if (config.config_on_startup) {
if (config.config_on_startup?.test_diffusers && config.update_branch !== "main") {
document.body.classList.add("diffusers-enabled-on-startup");
document.body.classList.remove("diffusers-disabled-on-startup");
} else {
document.body.classList.add("diffusers-disabled-on-startup");
document.body.classList.remove("diffusers-enabled-on-startup");
}
}
if (!testDiffusersEnabled) { if (!testDiffusersEnabled) {
document.querySelector("#lora_model_container").style.display = "none" document.querySelector("#lora_model_container").style.display = "none"
document.querySelector("#tiling_container").style.display = "none" document.querySelector("#tiling_container").style.display = "none"