Last active
July 27, 2025 13:26
-
-
Save yowasou/4a8c2bfe24cb569fa3d2651bda891b58 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 出力ファイル名に使っているloraの名前と年月日を付与するスクリプト | |
# webui\scriptsに設置してReload UIすると適用される | |
import re | |
from modules import scripts, script_callbacks, shared | |
from datetime import datetime | |
def filename_hook(params): | |
# StableDiffusionProcessing オブジェクトから prompt を取得 | |
prompt = getattr(params.p, "prompt", "") | |
# LoRA名を抽出 | |
lora_names = re.findall(r"<lora:([^:>]+)", prompt) | |
lora_part = "_".join(lora_names) if lora_names else "noLora" | |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") | |
ext = "." + shared.opts.samples_format | |
foldername = "outputs/withloraname/" | |
params.filename = f"{foldername}{lora_part}_{timestamp}{ext}" | |
script_callbacks.on_before_image_saved(filename_hook) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment