模板导出增强 + 模特性别分组 + 三合一提示词精简
1) 模板导出:识别「基码表-胸围」填 sku.bust(多个胸围列都填);申报价格模糊匹配多列统一按加价后价格填写;详情图文不再拼接 img_url_2;SPU 款式来源统一填「现货款」;商品产地国家简称映射(沙特→沙特阿拉伯) 2) 模特性别分组:model_features 按男女分组,按模板类目含男/女固定取对应性别模特(含 Pinterest 模式 pipeline) 3) 三合一提示词:去掉 DESIGN CONTENT 四要素描述(设计已由设计稿提供) 4) 生图尺寸:全部改为读 config 不再硬编码(设计图 compose.design_size / 合成图 compose.size / 种草图 seed_shot.size)
This commit is contained in:
+19
-10
@@ -134,7 +134,7 @@ def _retry_image(fn, *args, attempts: int = 3, backoff=(5, 20, 40), **kwargs):
|
||||
def _process_spu(
|
||||
db_path, basemap_root, material_root, category, prod_dir, brief, ib,
|
||||
spu, sku_code, pcfg, errors, shared_design=None, title_backend=None, country="",
|
||||
img_code="", model_img=None,
|
||||
img_code="", model_img=None, design_size="1024x1024", compose_size="1536x2048",
|
||||
) -> Optional[Dict[str, Any]]:
|
||||
"""处理单个款号:选色 → 底图 → 设计稿 → (mark==1) 模特 → 合成 → 模板导出。
|
||||
shared_design: compose 节点生成的纯印花设计稿路径(图2);为 None 时回退本节点 generate。
|
||||
@@ -210,7 +210,12 @@ def _process_spu(
|
||||
prompt = ensure_rebrand_hint(brief, sanitize_image_prompt(brief.get("image_prompt", "")))
|
||||
ib.generate(prompt, design_path,
|
||||
brief.get("composite_negative", ""),
|
||||
size="1024x1024") # 印花设计统一 1024x1024
|
||||
size=design_size) # 设计稿尺寸按 config compose.design_size
|
||||
# 全局 MD5 去重:生成了设计后,把 MD5 加入全局过滤(对所有国家生效);重复 → 跳过该产品
|
||||
from graph.pinterest import design_md5_ok
|
||||
if not design_md5_ok(design_path):
|
||||
print(f"{tag} 设计稿 MD5 全局重复,跳过该产品: {design_path}")
|
||||
return None
|
||||
result["design_path"] = design_path
|
||||
result["design_from"] = "product"
|
||||
print(f"{tag} 纯印花设计稿已生成(product 节点): {design_path}")
|
||||
@@ -252,7 +257,7 @@ def _process_spu(
|
||||
ib.print(wear_prompt, str(model_img), composite_path,
|
||||
brief.get("composite_negative", ""),
|
||||
extra_images=[design_path, str(basemap_img)], # 图2印花, 图3底图
|
||||
size="1504x2000") # 三合一统一 1504x2000
|
||||
size=compose_size) # 合成图尺寸按 config compose.size
|
||||
result["composite_path"] = composite_path
|
||||
print(f"{tag} 三图模特合成图已生成(耗时 {int(time.time()-t0)}s): {composite_path}")
|
||||
except Exception as e: # noqa: BLE001
|
||||
@@ -260,7 +265,7 @@ def _process_spu(
|
||||
print(f"{tag} 三图合成失败,退避重试…: {e}")
|
||||
retried = _retry_image(ib.print, wear_prompt, str(model_img), composite_path,
|
||||
brief.get("composite_negative", ""),
|
||||
extra_images=[design_path, str(basemap_img)], size="1504x2000")
|
||||
extra_images=[design_path, str(basemap_img)], size=compose_size)
|
||||
if retried is not None:
|
||||
result["composite_path"] = composite_path
|
||||
print(f"{tag} 三图合成重试成功(耗时 {int(time.time()-t0)}s): {composite_path}")
|
||||
@@ -280,14 +285,14 @@ def _process_spu(
|
||||
ib.print(flat_prompt, str(basemap_img), printed_path,
|
||||
brief.get("composite_negative", ""),
|
||||
extra_images=[design_path], # 图2印花
|
||||
size="1504x2000") # 合成统一 1504x2000
|
||||
size=compose_size) # 合成图尺寸按 config compose.size
|
||||
result["printed_path"] = printed_path
|
||||
print(f"{tag} 平铺服装图已生成(无模特,底图+印花): {printed_path}")
|
||||
except Exception as e: # noqa: BLE001
|
||||
print(f"{tag} 平铺服装图失败,退避重试…: {e}")
|
||||
retried = _retry_image(ib.print, flat_prompt, str(basemap_img), printed_path,
|
||||
brief.get("composite_negative", ""),
|
||||
extra_images=[design_path], size="1504x2000")
|
||||
extra_images=[design_path], size=compose_size)
|
||||
if retried is not None:
|
||||
result["printed_path"] = printed_path
|
||||
print(f"{tag} 平铺服装图重试成功: {printed_path}")
|
||||
@@ -312,7 +317,7 @@ def _process_spu(
|
||||
ib.print(MODEL_WEAR_PROMPT, str(model_img), cp,
|
||||
brief.get("composite_negative", ""),
|
||||
extra_images=[design_path, str(bm)], # 图2印花, 图3该色底图
|
||||
size="1504x2000") # 三合一统一 1504x2000
|
||||
size=compose_size) # 合成图尺寸按 config compose.size
|
||||
col = next((c["color"] for c in colors if c["sku_code"] == sc), sc)
|
||||
color_composites.append({"sku_code": sc, "color": col, "composite_path": cp})
|
||||
print(f"{tag} 颜色 {sc}({col})三合一已生成: {cp}")
|
||||
@@ -327,12 +332,14 @@ def _process_spu(
|
||||
or result.get("design_path"))
|
||||
if title_img:
|
||||
t = title_backend.generate_title(title_img, country=country)
|
||||
if t.get("en_title") or t.get("cn_title") or t.get("ja_title"):
|
||||
if t.get("en_title") or t.get("cn_title") or t.get("ja_title") or t.get("es_title"):
|
||||
result["en_title"] = t.get("en_title", "")
|
||||
result["cn_title"] = t.get("cn_title", "")
|
||||
result["ja_title"] = t.get("ja_title", "")
|
||||
result["es_title"] = t.get("es_title", "")
|
||||
print(f"{tag} 标题已生成: EN={t.get('en_title','')[:50]}... "
|
||||
f"CN={t.get('cn_title','')[:30]}... JA={t.get('ja_title','')[:30]}...")
|
||||
f"CN={t.get('cn_title','')[:30]}... JA={t.get('ja_title','')[:30]}... "
|
||||
f"ES={t.get('es_title','')[:30]}...")
|
||||
|
||||
return result
|
||||
|
||||
@@ -514,7 +521,9 @@ def product_node(state: Dict[str, Any]) -> Dict[str, Any]:
|
||||
r = _process_spu(db_path, basemap_root, material_root, category, prod_dir,
|
||||
tb, ib, spu, skus, pcfg, errors, design_path, title_backend,
|
||||
country, img_code=img_code,
|
||||
model_img=model_assign.get(spu.get("code", "")))
|
||||
model_img=model_assign.get(spu.get("code", "")),
|
||||
design_size=str((config.get("compose") or {}).get("design_size") or "1024x1024"),
|
||||
compose_size=str((config.get("compose") or {}).get("size") or "1536x2048"))
|
||||
if r:
|
||||
r["img_code"] = img_code
|
||||
return r, img_code
|
||||
|
||||
Reference in New Issue
Block a user