v110-v112 自定义模式完善 + 模板导出增强 + 多模态兼容优化
- 自定义模式:分析模型输出 delta 唯一改动指令,生图模板 custom_image_prompt.md({delta} 占位符),不再使用负向提示词;generate_design 按 custom_mode 分支,Pinterest 模式保留原创化指令,两模式互不影响
- 多模态分析 response_format 三级回退(json_schema → json_object → none),兼容 DeepSeek
- 模板导出:details 扩展列(细节1/2/3)、target_audience 扩展列(适用人群1)、固定值风格1=休闲/风格2=运动
- 童装特征库更新 + 标题模板外部化 + 图源映射增强
This commit is contained in:
+22
-12
@@ -125,7 +125,8 @@ def generate_design(ib, brief: Dict[str, Any], design_dir: Path, out_stem: str,
|
||||
seed: Optional[int] = None,
|
||||
on_400=None,
|
||||
on_503=None,
|
||||
size: str = "1024x1024") -> Optional[str]:
|
||||
size: str = "1024x1024",
|
||||
custom_mode: bool = False) -> Optional[str]:
|
||||
"""生成单张纯印花设计稿(图2)。返回设计稿路径;失败 / 全局 MD5 重复返回 None。
|
||||
|
||||
out_stem: 输出文件名主干(不含扩展名),最终文件 = {out_stem}_design.png。
|
||||
@@ -146,16 +147,24 @@ def generate_design(ib, brief: Dict[str, Any], design_dir: Path, out_stem: str,
|
||||
ref_images = [str(p) for p in (brief.get("ref_images") or []) if str(p)]
|
||||
if ref_images and hasattr(ib, "print"):
|
||||
try:
|
||||
# 图生图:以爬取图为参考,按分析简报生成原创设计(不复制原图)
|
||||
ref_prompt = img_prompt + (
|
||||
" Create an ORIGINAL, non-copying flat print design inspired ONLY by "
|
||||
"the reference image's style and mood. Do NOT reproduce the reference "
|
||||
"image, its characters, logos, or any text.")
|
||||
out_path = ib.print(
|
||||
ref_prompt, ref_images[0], out_path,
|
||||
brief.get("composite_negative", ""),
|
||||
extra_images=ref_images[1:] or None,
|
||||
size=size, seed=seed) # 设计稿尺寸按 config compose.design_size
|
||||
if custom_mode:
|
||||
# 自定义模式:按 image_prompt 图生图(模板已内置防复制/防服装约束,不追加原创化指令)
|
||||
out_path = ib.print(
|
||||
img_prompt, ref_images[0], out_path,
|
||||
brief.get("composite_negative", ""),
|
||||
extra_images=ref_images[1:] or None,
|
||||
size=size, seed=seed) # 设计稿尺寸按 config compose.design_size
|
||||
else:
|
||||
# Pinterest 模式:追加原创化指令(防止复制原图,保持原有行为)
|
||||
ref_prompt = img_prompt + (
|
||||
" Create an ORIGINAL, non-copying flat print design inspired ONLY by "
|
||||
"the reference image's style and mood. Do NOT reproduce the reference "
|
||||
"image, its characters, logos, or any text.")
|
||||
out_path = ib.print(
|
||||
ref_prompt, ref_images[0], out_path,
|
||||
brief.get("composite_negative", ""),
|
||||
extra_images=ref_images[1:] or None,
|
||||
size=size, seed=seed) # 设计稿尺寸按 config compose.design_size
|
||||
except Exception as e: # noqa: BLE001
|
||||
print(f"[compose] 图生图(参考图)失败,回退文生图 {brief.get('topic','')}: {e}")
|
||||
_notify_400(on_400, e)
|
||||
@@ -255,7 +264,8 @@ def compose_node(state: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"""单张设计稿生成(并发线程内调用,每设计一线程)。"""
|
||||
out_path = generate_design(ib, b, design_dir, f"{country}_{i:02d}",
|
||||
_safe_errors, seed=_seed,
|
||||
size=compose_cfg.get("design_size", "1024x1024"))
|
||||
size=compose_cfg.get("design_size", "1024x1024"),
|
||||
custom_mode=bool(state.get("custom_mode")))
|
||||
if out_path is None:
|
||||
return i, b, None, None
|
||||
return i, b, out_path, None
|
||||
|
||||
Reference in New Issue
Block a user