加载 Prompt 模板
(self, short: bool = False)
| 90 | generated_images[index] = filename |
| 91 | |
| 92 | def _load_prompt_template(self, short: bool = False) -> str: |
| 93 | """加载 Prompt 模板""" |
| 94 | filename = "image_prompt_short.txt" if short else "image_prompt.txt" |
| 95 | prompt_path = os.path.join( |
| 96 | os.path.dirname(os.path.dirname(__file__)), |
| 97 | "prompts", |
| 98 | filename |
| 99 | ) |
| 100 | if not os.path.exists(prompt_path): |
| 101 | # 如果短模板不存在,返回空字符串 |
| 102 | return "" |
| 103 | with open(prompt_path, "r", encoding="utf-8") as f: |
| 104 | return f.read() |
| 105 | |
| 106 | def _save_image(self, image_data: bytes, filename: str, task_dir: str = None) -> str: |
| 107 | """ |