Merge pull request #1045 from ogmaresca/save-lora-model-to-metadata

Add LoRA model to metadata files
This commit is contained in:
cmdr2 2023-03-22 14:10:58 +05:30 committed by GitHub
commit 9c693bd76f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,6 +27,8 @@ TASK_TEXT_MAPPING = {
"use_vae_model": "VAE model", "use_vae_model": "VAE model",
"use_hypernetwork_model": "Hypernetwork model", "use_hypernetwork_model": "Hypernetwork model",
"hypernetwork_strength": "Hypernetwork Strength", "hypernetwork_strength": "Hypernetwork Strength",
"use_lora_model": "LoRA model",
#"lora_alpha": "LoRA Strength",
} }
@ -86,6 +88,7 @@ def get_metadata_entries_for_request(req: GenerateImageRequest, task_data: TaskD
"use_stable_diffusion_model": task_data.use_stable_diffusion_model, "use_stable_diffusion_model": task_data.use_stable_diffusion_model,
"use_vae_model": task_data.use_vae_model, "use_vae_model": task_data.use_vae_model,
"use_hypernetwork_model": task_data.use_hypernetwork_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_face_correction": task_data.use_face_correction,
"use_upscale": task_data.use_upscale, "use_upscale": task_data.use_upscale,
} }
@ -94,6 +97,12 @@ def get_metadata_entries_for_request(req: GenerateImageRequest, task_data: TaskD
metadata["upscale_amount"] = task_data.upscale_amount metadata["upscale_amount"] = task_data.upscale_amount
if task_data.use_hypernetwork_model is None: if task_data.use_hypernetwork_model is None:
del metadata["hypernetwork_strength"] 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"