forked from extern/easydiffusion
Merge branch 'beta' of github.com:cmdr2/stable-diffusion-ui into beta
This commit is contained in:
commit
29ec34169c
@ -1,5 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import argparse
|
import argparse
|
||||||
|
import sys
|
||||||
|
|
||||||
# The config file is in the same directory as this script
|
# The config file is in the same directory as this script
|
||||||
config_directory = os.path.dirname(__file__)
|
config_directory = os.path.dirname(__file__)
|
||||||
@ -21,16 +22,16 @@ if os.path.isfile(config_yaml):
|
|||||||
try:
|
try:
|
||||||
config = yaml.safe_load(configfile)
|
config = yaml.safe_load(configfile)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e, file=sys.stderr)
|
||||||
exit()
|
config = {}
|
||||||
elif os.path.isfile(config_json):
|
elif os.path.isfile(config_json):
|
||||||
import json
|
import json
|
||||||
with open(config_json, 'r') as configfile:
|
with open(config_json, 'r') as configfile:
|
||||||
try:
|
try:
|
||||||
config = json.load(configfile)
|
config = json.load(configfile)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e, file=sys.stderr)
|
||||||
exit()
|
config = {}
|
||||||
else:
|
else:
|
||||||
config = {}
|
config = {}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ def make_images(
|
|||||||
|
|
||||||
|
|
||||||
def print_task_info(req: GenerateImageRequest, task_data: TaskData):
|
def print_task_info(req: GenerateImageRequest, task_data: TaskData):
|
||||||
req_str = pprint.pformat(get_printable_request(req)).replace("[", "\[")
|
req_str = pprint.pformat(get_printable_request(req, task_data)).replace("[", "\[")
|
||||||
task_str = pprint.pformat(task_data.dict()).replace("[", "\[")
|
task_str = pprint.pformat(task_data.dict()).replace("[", "\[")
|
||||||
log.info(f"request: {req_str}")
|
log.info(f"request: {req_str}")
|
||||||
log.info(f"task data: {task_str}")
|
log.info(f"task data: {task_str}")
|
||||||
|
@ -15,23 +15,24 @@ img_number_regex = re.compile("([0-9]{5,})")
|
|||||||
# keep in sync with `ui/media/js/dnd.js`
|
# keep in sync with `ui/media/js/dnd.js`
|
||||||
TASK_TEXT_MAPPING = {
|
TASK_TEXT_MAPPING = {
|
||||||
"prompt": "Prompt",
|
"prompt": "Prompt",
|
||||||
|
"negative_prompt": "Negative Prompt",
|
||||||
|
"seed": "Seed",
|
||||||
|
"use_stable_diffusion_model": "Stable Diffusion model",
|
||||||
|
"clip_skip": "Clip Skip",
|
||||||
|
"use_vae_model": "VAE model",
|
||||||
|
"sampler_name": "Sampler",
|
||||||
"width": "Width",
|
"width": "Width",
|
||||||
"height": "Height",
|
"height": "Height",
|
||||||
"seed": "Seed",
|
|
||||||
"num_inference_steps": "Steps",
|
"num_inference_steps": "Steps",
|
||||||
"guidance_scale": "Guidance Scale",
|
"guidance_scale": "Guidance Scale",
|
||||||
"prompt_strength": "Prompt Strength",
|
"prompt_strength": "Prompt Strength",
|
||||||
|
"use_lora_model": "LoRA model",
|
||||||
|
"lora_alpha": "LoRA Strength",
|
||||||
|
"use_hypernetwork_model": "Hypernetwork model",
|
||||||
|
"hypernetwork_strength": "Hypernetwork Strength",
|
||||||
"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",
|
||||||
"sampler_name": "Sampler",
|
|
||||||
"negative_prompt": "Negative Prompt",
|
|
||||||
"use_stable_diffusion_model": "Stable Diffusion model",
|
|
||||||
"use_vae_model": "VAE model",
|
|
||||||
"use_hypernetwork_model": "Hypernetwork model",
|
|
||||||
"hypernetwork_strength": "Hypernetwork Strength",
|
|
||||||
"use_lora_model": "LoRA model",
|
|
||||||
"lora_alpha": "LoRA Strength",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
time_placeholders = {
|
time_placeholders = {
|
||||||
@ -179,27 +180,7 @@ def save_images_to_disk(images: list, filtered_images: list, req: GenerateImageR
|
|||||||
|
|
||||||
|
|
||||||
def get_metadata_entries_for_request(req: GenerateImageRequest, task_data: TaskData):
|
def get_metadata_entries_for_request(req: GenerateImageRequest, task_data: TaskData):
|
||||||
metadata = get_printable_request(req)
|
metadata = get_printable_request(req, task_data)
|
||||||
metadata.update(
|
|
||||||
{
|
|
||||||
"use_stable_diffusion_model": task_data.use_stable_diffusion_model,
|
|
||||||
"use_vae_model": task_data.use_vae_model,
|
|
||||||
"use_hypernetwork_model": task_data.use_hypernetwork_model,
|
|
||||||
"use_lora_model": task_data.use_lora_model,
|
|
||||||
"use_face_correction": task_data.use_face_correction,
|
|
||||||
"use_upscale": task_data.use_upscale,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
if metadata["use_upscale"] is not None:
|
|
||||||
metadata["upscale_amount"] = task_data.upscale_amount
|
|
||||||
if task_data.use_hypernetwork_model is None:
|
|
||||||
del metadata["hypernetwork_strength"]
|
|
||||||
if task_data.use_lora_model is None:
|
|
||||||
if "lora_alpha" in metadata:
|
|
||||||
del metadata["lora_alpha"]
|
|
||||||
app_config = app.getConfig()
|
|
||||||
if not app_config.get("test_diffusers", False) and "use_lora_model" in metadata:
|
|
||||||
del metadata["use_lora_model"]
|
|
||||||
|
|
||||||
# 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.lower() == "txt"
|
is_txt_format = task_data.metadata_output_format.lower() == "txt"
|
||||||
@ -213,12 +194,33 @@ def get_metadata_entries_for_request(req: GenerateImageRequest, task_data: TaskD
|
|||||||
return entries
|
return entries
|
||||||
|
|
||||||
|
|
||||||
def get_printable_request(req: GenerateImageRequest):
|
def get_printable_request(req: GenerateImageRequest, task_data: TaskData):
|
||||||
metadata = req.dict()
|
req_metadata = req.dict()
|
||||||
del metadata["init_image"]
|
task_data_metadata = task_data.dict()
|
||||||
del metadata["init_image_mask"]
|
|
||||||
if req.init_image is None:
|
# Save the metadata in the order defined in TASK_TEXT_MAPPING
|
||||||
|
metadata = {}
|
||||||
|
for key in TASK_TEXT_MAPPING.keys():
|
||||||
|
if key in req_metadata:
|
||||||
|
metadata[key] = req_metadata[key]
|
||||||
|
elif key in task_data_metadata:
|
||||||
|
metadata[key] = task_data_metadata[key]
|
||||||
|
|
||||||
|
# Clean up the metadata
|
||||||
|
if req.init_image is None and "prompt_strength" in metadata:
|
||||||
del metadata["prompt_strength"]
|
del metadata["prompt_strength"]
|
||||||
|
if task_data.use_upscale is None and "upscale_amount" in metadata:
|
||||||
|
del metadata["upscale_amount"]
|
||||||
|
if task_data.use_hypernetwork_model is None and "hypernetwork_strength" in metadata:
|
||||||
|
del metadata["hypernetwork_strength"]
|
||||||
|
if task_data.use_lora_model is None and "lora_alpha" in metadata:
|
||||||
|
del metadata["lora_alpha"]
|
||||||
|
|
||||||
|
app_config = app.getConfig()
|
||||||
|
if not app_config.get("test_diffusers", False):
|
||||||
|
for key in (x for x in ["use_lora_model", "lora_alpha", "clip_skip"] if x in metadata):
|
||||||
|
del metadata[key]
|
||||||
|
|
||||||
return metadata
|
return metadata
|
||||||
|
|
||||||
|
|
||||||
|
@ -169,6 +169,22 @@ function loadSettings() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
CURRENTLY_LOADING_SETTINGS = false
|
CURRENTLY_LOADING_SETTINGS = false
|
||||||
|
} else if (localStorage.length < 2) {
|
||||||
|
// localStorage is too short for OldSettings
|
||||||
|
// So this is likely the first time Easy Diffusion is running.
|
||||||
|
// Initialize vram_usage_level based on the available VRAM
|
||||||
|
function initGPUProfile(event) {
|
||||||
|
if ( "detail" in event
|
||||||
|
&& "active" in event.detail
|
||||||
|
&& "cuda:0" in event.detail.active
|
||||||
|
&& event.detail.active["cuda:0"].mem_total <4.5 )
|
||||||
|
{
|
||||||
|
vramUsageLevelField.value = "low"
|
||||||
|
vramUsageLevelField.dispatchEvent(new Event("change"))
|
||||||
|
}
|
||||||
|
document.removeEventListener("system_info_update", initGPUProfile)
|
||||||
|
}
|
||||||
|
document.addEventListener("system_info_update", initGPUProfile)
|
||||||
} else {
|
} else {
|
||||||
CURRENTLY_LOADING_SETTINGS = true
|
CURRENTLY_LOADING_SETTINGS = true
|
||||||
tryLoadOldSettings()
|
tryLoadOldSettings()
|
||||||
|
@ -37,6 +37,7 @@ function parseBoolean(stringValue) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// keep in sync with `ui/easydiffusion/utils/save_utils.py`
|
||||||
const TASK_MAPPING = {
|
const TASK_MAPPING = {
|
||||||
prompt: {
|
prompt: {
|
||||||
name: "Prompt",
|
name: "Prompt",
|
||||||
|
@ -239,7 +239,7 @@ function setServerStatus(event) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
if (SD.serverState.devices) {
|
if (SD.serverState.devices) {
|
||||||
setDeviceInfo(SD.serverState.devices)
|
document.dispatchEvent(new CustomEvent("system_info_update", { detail: SD.serverState.devices}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,8 +181,8 @@ var PARAMETERS = [
|
|||||||
{
|
{
|
||||||
id: "listen_to_network",
|
id: "listen_to_network",
|
||||||
type: ParameterType.checkbox,
|
type: ParameterType.checkbox,
|
||||||
label: "Make Stable Diffusion available on your network. Please restart the program after changing this.",
|
label: "Make Stable Diffusion available on your network",
|
||||||
note: "Other devices on your network can access this web page",
|
note: "Other devices on your network can access this web page. Please restart the program after changing this.",
|
||||||
icon: "fa-network-wired",
|
icon: "fa-network-wired",
|
||||||
default: true,
|
default: true,
|
||||||
saveInAppConfig: true,
|
saveInAppConfig: true,
|
||||||
@ -586,7 +586,7 @@ async function getSystemInfo() {
|
|||||||
$("#use_gpus").val(activeDeviceIds)
|
$("#use_gpus").val(activeDeviceIds)
|
||||||
}
|
}
|
||||||
|
|
||||||
setDeviceInfo(devices)
|
document.dispatchEvent(new CustomEvent("system_info_update", { detail: devices}))
|
||||||
setHostInfo(res["hosts"])
|
setHostInfo(res["hosts"])
|
||||||
let force = false
|
let force = false
|
||||||
if (res["enforce_output_dir"] !== undefined) {
|
if (res["enforce_output_dir"] !== undefined) {
|
||||||
@ -657,3 +657,5 @@ saveSettingsBtn.addEventListener("click", function() {
|
|||||||
saveSettingsBtn.classList.add("active")
|
saveSettingsBtn.classList.add("active")
|
||||||
Promise.all([savePromise, asyncDelay(300)]).then(() => saveSettingsBtn.classList.remove("active"))
|
Promise.all([savePromise, asyncDelay(300)]).then(() => saveSettingsBtn.classList.remove("active"))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
document.addEventListener("system_info_update", (e) => setDeviceInfo(e.detail))
|
||||||
|
Loading…
Reference in New Issue
Block a user