修正 PhotoMagazine 節點:加回 features 參數 + DesignPrompt 資料夾
- 加回 features 參數(人物特徵描述)
- 模板移至 DesignPrompt/ 資料夾(避免與其他 Prompt 混淆)
- 更新文件說明
- 模板支援 {features} 和 {features_description} 變數
This commit is contained in:
@@ -46,6 +46,7 @@ class PhotoMagazinePromptGenerator:
|
||||
"photo_style": ("STRING", {"default": "自然清新", "placeholder": "拍攝風格(自由輸入)"}),
|
||||
"custom_scene": ("STRING", {"default": "", "placeholder": "場景設定(可選)"}),
|
||||
"content_pages": ("INT", {"default": 8, "min": 3, "max": 30, "step": 1}),
|
||||
"features": ("STRING", {"default": "", "placeholder": "人物特徵描述(例如:戴著黑框眼鏡的長髮女性)"}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,11 +55,11 @@ class PhotoMagazinePromptGenerator:
|
||||
FUNCTION = "generate_prompt"
|
||||
CATEGORY = "DesignPack"
|
||||
|
||||
def generate_prompt(self, model_name, photo_style, custom_scene, content_pages):
|
||||
def generate_prompt(self, model_name, photo_style, custom_scene, content_pages, features):
|
||||
"""讀取模板並注入參數"""
|
||||
try:
|
||||
# 讀取模板檔案
|
||||
template_path = os.path.join(os.path.dirname(__file__), "prompts", "photomagazine_json_output.md")
|
||||
# 讀取模板檔案(從 DesignPrompt 資料夾)
|
||||
template_path = os.path.join(os.path.dirname(__file__), "DesignPrompt", "photomagazine_json_output.md")
|
||||
|
||||
if not os.path.exists(template_path):
|
||||
return (f"錯誤:找不到模板檔案 {template_path}",)
|
||||
@@ -66,16 +67,22 @@ class PhotoMagazinePromptGenerator:
|
||||
with open(template_path, 'r', encoding='utf-8') as f:
|
||||
template = f.read()
|
||||
|
||||
# 準備人物特徵描述
|
||||
features_description = f"人物特徵:{features}" if features else "人物特徵:根據模特兒名稱自行判斷"
|
||||
|
||||
# 注入參數
|
||||
prompt = template.format(
|
||||
model_name=model_name,
|
||||
features=features if features else "根據模特兒名稱自行判斷",
|
||||
photo_style=photo_style,
|
||||
custom_scene=custom_scene if custom_scene else "自動判定",
|
||||
content_pages=content_pages
|
||||
content_pages=content_pages,
|
||||
features_description=features_description
|
||||
)
|
||||
|
||||
print("📝 提示詞生成完成")
|
||||
print(f" 模特兒:{model_name}")
|
||||
print(f" 特徵:{features if features else '自動判定'}")
|
||||
print(f" 風格:{photo_style}")
|
||||
print(f" 場景:{custom_scene if custom_scene else '自動判定'}")
|
||||
print(f" 頁數:{content_pages}")
|
||||
|
||||
Reference in New Issue
Block a user