Add tiling and latent upscaler steps to metadata

Also fix txt metadata labels when also embedding metadata
This commit is contained in:
Olivia Godone-Maresca 2023-05-26 19:51:30 -04:00
parent edd92b724f
commit 69d937e0b1
3 changed files with 25 additions and 10 deletions

View File

@ -30,9 +30,11 @@ 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",
"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"
} }
time_placeholders = { time_placeholders = {
@ -169,7 +171,9 @@ def save_images_to_disk(images: list, filtered_images: list, req: GenerateImageR
output_quality=task_data.output_quality, output_quality=task_data.output_quality,
output_lossless=task_data.output_lossless, output_lossless=task_data.output_lossless,
) )
if task_data.metadata_output_format.lower() in ["json", "txt", "embed"]: if task_data.metadata_output_format:
for metadata_output_format in task_data.metadata_output_format.split(","):
if metadata_output_format.lower() in ["json", "txt", "embed"]:
save_dicts( save_dicts(
metadata_entries, metadata_entries,
save_dir_path, save_dir_path,
@ -183,7 +187,7 @@ def get_metadata_entries_for_request(req: GenerateImageRequest, task_data: TaskD
metadata = get_printable_request(req, task_data) metadata = get_printable_request(req, task_data)
# 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 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} metadata = {TASK_TEXT_MAPPING[key]: val for key, val in metadata.items() if key in TASK_TEXT_MAPPING}
@ -215,10 +219,12 @@ def get_printable_request(req: GenerateImageRequest, task_data: TaskData):
del metadata["hypernetwork_strength"] del metadata["hypernetwork_strength"]
if task_data.use_lora_model is None and "lora_alpha" in metadata: if task_data.use_lora_model is None and "lora_alpha" in metadata:
del metadata["lora_alpha"] del metadata["lora_alpha"]
if task_data.use_upscale is not "latent_upscaler" and "latent_upscaler_steps" in metadata:
del metadata["latent_upscaler_steps"]
app_config = app.getConfig() app_config = app.getConfig()
if not app_config.get("test_diffusers", False): 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): 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]
return metadata return metadata

View File

@ -35,6 +35,7 @@ const SETTINGS_IDS_LIST = [
"gfpgan_model", "gfpgan_model",
"use_upscale", "use_upscale",
"upscale_amount", "upscale_amount",
"latent_upscaler_steps",
"block_nsfw", "block_nsfw",
"show_only_filtered_image", "show_only_filtered_image",
"upscale_model", "upscale_model",

View File

@ -221,6 +221,14 @@ const TASK_MAPPING = {
readUI: () => upscaleAmountField.value, readUI: () => upscaleAmountField.value,
parse: (val) => val, parse: (val) => val,
}, },
latent_upscaler_steps: {
name: "Latent Upscaler Steps",
setUI: (latent_upscaler_steps) => {
latentUpscalerStepsField.value = latent_upscaler_steps
},
readUI: () => latentUpscalerStepsField.value,
parse: (val) => val,
},
sampler_name: { sampler_name: {
name: "Sampler", name: "Sampler",
setUI: (sampler_name) => { setUI: (sampler_name) => {