Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3c782f89d1 | |||
| 2b4f11036f | |||
| 2881da65cf | |||
| 1037e218bb | |||
| f0514d7487 | |||
| bf8f62ec5b | |||
| cb911f5eba | |||
| f6fa3ea653 | |||
| 6a7709ba43 | |||
| 2c70dd4c29 | |||
| 5548e78eee | |||
| 44bd96b148 | |||
| dda67cd10f | |||
| afd6b9c0b8 |
@@ -404,6 +404,190 @@ def _analyze_single_image(
|
||||
product_nodes = [n for n in nodes if n["tag"] == "product"]
|
||||
scene = xp.text_of(raw_text, "scene") or "通用"
|
||||
mood = xp.text_of(raw_text, "mood") or ""
|
||||
# #2184: #2177 XML 重构后人物信息放在顶层 <people has_person count gender age_range pose expression/>,
|
||||
# 不再是 <product> 的 portrait_prompt 属性。需从顶层 people 标签提取并拼装 portrait_prompt。
|
||||
portrait_prompt = "无人像"
|
||||
try:
|
||||
people_node = xp.find_first(raw_text, "people")
|
||||
if people_node:
|
||||
_pa = people_node.get("attrs") or {}
|
||||
_has_person = xp.attr_bool(_pa.get("has_person"), False)
|
||||
if _has_person:
|
||||
_gender = _pa.get("gender", "无法判断") or "无法判断"
|
||||
_age = _pa.get("age_range", "无法判断") or "无法判断"
|
||||
_hair = _pa.get("hair", "无法判断") or "无法判断"
|
||||
_skin = _pa.get("skin_tone", "无法判断") or "无法判断"
|
||||
_face = _pa.get("face_shape", "无法判断") or "无法判断"
|
||||
_outfit = _pa.get("outfit", "无法判断") or "无法判断"
|
||||
_pose = _pa.get("pose", "无法判断") or "无法判断"
|
||||
_expr = _pa.get("expression", "无法判断") or "无法判断"
|
||||
_count = xp.attr_int(_pa.get("count"), 1)
|
||||
# #2185: VLM有时对外貌属性输出"无法判断",用通用兜底值确保portrait_prompt始终有完整外貌描述
|
||||
if _hair == "无法判断":
|
||||
_hair = "自然发型"
|
||||
if _skin == "无法判断":
|
||||
_skin = "自然"
|
||||
if _face == "无法判断":
|
||||
_face = "标准"
|
||||
if _outfit == "无法判断":
|
||||
_outfit = "日常服装"
|
||||
_parts = []
|
||||
if _gender != "无法判断":
|
||||
_g = _gender + ("性" if not _gender.endswith("性") else "")
|
||||
_parts.append(_g)
|
||||
else:
|
||||
_parts.append("成年人")
|
||||
if _age != "无法判断":
|
||||
_parts.append(_age)
|
||||
_parts.append("人物")
|
||||
_parts.append(_hair)
|
||||
_parts.append(f"{_skin}肤色")
|
||||
_parts.append(f"{_face}脸型")
|
||||
_parts.append(f"身着{_outfit}")
|
||||
if _pose != "无法判断":
|
||||
_parts.append(f"姿态{_pose}")
|
||||
if _expr != "无法判断":
|
||||
_parts.append(f"表情{_expr}")
|
||||
else:
|
||||
_parts.append("表情自然")
|
||||
# #2186: 智能回填——VLM有时省略hair/outfit等外貌属性,但product.name/features/colors里已有相关信息
|
||||
# 从product名字和features中提取服装关键词回填outfit
|
||||
if _outfit in ("日常服装", "无法判断"):
|
||||
for _ppn in product_nodes:
|
||||
_pn = (_ppn.get("attrs") or {}).get("name", "") or ""
|
||||
_pf = (_ppn.get("attrs") or {}).get("features", "") or ""
|
||||
_ptxt = _pn + " " + _pf
|
||||
# 服装关键词识别(常见上装/下装/裙装/套装)
|
||||
_cloth_kws = [
|
||||
"衬衫",
|
||||
"T恤",
|
||||
"毛衣",
|
||||
"针织衫",
|
||||
"卫衣",
|
||||
"外套",
|
||||
"西装",
|
||||
"夹克",
|
||||
"风衣",
|
||||
"大衣",
|
||||
"羽绒服",
|
||||
"马甲",
|
||||
"背心",
|
||||
"连衣裙",
|
||||
"半身裙",
|
||||
"短裙",
|
||||
"长裙",
|
||||
"牛仔裤",
|
||||
"休闲裤",
|
||||
"西裤",
|
||||
"运动裤",
|
||||
"短裤",
|
||||
"旗袍",
|
||||
"汉服",
|
||||
"制服",
|
||||
"polo衫",
|
||||
"POLO衫",
|
||||
"针织",
|
||||
"毛衫",
|
||||
"开衫",
|
||||
"帽衫",
|
||||
"皮夹克",
|
||||
"皮衣",
|
||||
]
|
||||
for _ckw in _cloth_kws:
|
||||
if _ckw in _ptxt:
|
||||
_ci = _ptxt.find(_ckw)
|
||||
# 向前找颜色/材质/款式形容词(白/黑/米/红/蓝/灰/棉/麻/长/短/厚/薄/长袖/短袖/翻领/圆领/V领/印花/条纹等)
|
||||
_start = max(0, _ci - 8)
|
||||
# 向后包含款式词(长袖/短袖/外套/套装/上衣等后续修饰)
|
||||
_end = min(len(_ptxt), _ci + len(_ckw) + 4)
|
||||
_outfit_extract = _ptxt[_start:_end].strip(" ,,。.、")
|
||||
# 仅清理明确的品牌/产品类前缀(不清理颜色/款式/尺寸形容词)
|
||||
_outfit_extract = re.sub(
|
||||
r"^(\S{0,4}牌|\S{0,3}品牌|\S{0,3}款|产品|商品|的)", "", _outfit_extract
|
||||
).strip()
|
||||
# 尾部清理:去掉残留的品牌字/型号字(如"标""ml""g""装"等单字杂字)
|
||||
_outfit_extract = re.sub(
|
||||
r"(标[0-9a-zA-Z]*|\d+\s*(?:ml|g|L|斤|件|个|瓶|盒|包|袋|装)|\s+\d+\s*)$",
|
||||
"",
|
||||
_outfit_extract,
|
||||
flags=re.IGNORECASE,
|
||||
).strip()
|
||||
if len(_outfit_extract) >= 2:
|
||||
_outfit = _outfit_extract
|
||||
break
|
||||
if _outfit not in ("日常服装", "无法判断"):
|
||||
break
|
||||
# 从color标签中提取头发颜色回填hair
|
||||
if _hair in ("自然发型", "无法判断"):
|
||||
_hair_color = ""
|
||||
_color_nodes = [n for n in nodes if n["tag"] == "color"]
|
||||
_hair_kws_map = {
|
||||
"黑": "黑色",
|
||||
"棕": "棕色",
|
||||
"金": "金色",
|
||||
"栗": "栗色",
|
||||
"红": "红色",
|
||||
"白": "白色",
|
||||
"灰": "灰色",
|
||||
"蓝": "蓝色",
|
||||
"黄": "黄色",
|
||||
"紫": "紫色",
|
||||
}
|
||||
for _cn in _color_nodes:
|
||||
_cname = (_cn.get("attrs") or {}).get("name", "") or ""
|
||||
# 小占比颜色更可能是发色(非主色的小面积色),且名称含头发/黑/棕/金等
|
||||
_ccov = 0.0
|
||||
try:
|
||||
_ccov = float((_cn.get("attrs") or {}).get("coverage", "0") or 0)
|
||||
except Exception:
|
||||
pass
|
||||
for _hk, _hv in _hair_kws_map.items():
|
||||
if _hk in _cname and _ccov < 0.3:
|
||||
_hair_color = _hv
|
||||
break
|
||||
if _hair_color:
|
||||
break
|
||||
if _hair_color:
|
||||
_hair = f"{_hair_color}头发"
|
||||
else:
|
||||
_hair = "自然发型"
|
||||
# 重新拼装_parts(回填后)
|
||||
_parts = []
|
||||
if _gender != "无法判断":
|
||||
_g = _gender + ("性" if not _gender.endswith("性") else "")
|
||||
_parts.append(_g)
|
||||
else:
|
||||
_parts.append("成年人")
|
||||
if _age != "无法判断":
|
||||
_parts.append(_age)
|
||||
_parts.append("人物")
|
||||
_parts.append(_hair)
|
||||
_parts.append(f"{_skin}肤色")
|
||||
_parts.append(f"{_face}脸型")
|
||||
_parts.append(f"身着{_outfit}")
|
||||
if _pose != "无法判断":
|
||||
_parts.append(f"姿态{_pose}")
|
||||
if _expr != "无法判断":
|
||||
_parts.append(f"表情{_expr}")
|
||||
else:
|
||||
_parts.append("表情自然")
|
||||
portrait_prompt = ",".join(_parts)
|
||||
logger.info(
|
||||
"[爆款视频] 图片 #%d 解析<people>(回填后): count=%d gender=%s age=%s hair=%s skin=%s face=%s outfit=%s pose=%s expr=%s → %s",
|
||||
idx,
|
||||
_count,
|
||||
_gender,
|
||||
_age,
|
||||
_hair,
|
||||
_skin,
|
||||
_face,
|
||||
_outfit,
|
||||
_pose,
|
||||
_expr,
|
||||
portrait_prompt,
|
||||
)
|
||||
except Exception as _pe:
|
||||
logger.warning("[爆款视频] 图片 #%d 解析<people>标签异常: %s,回退无人像", idx, _pe)
|
||||
for p in product_nodes:
|
||||
a = p["attrs"]
|
||||
text_on_pkg = a.get("text_on_package", "")
|
||||
@@ -419,6 +603,10 @@ def _analyze_single_image(
|
||||
appearance = a.get("appearance", "") or "无法判断"
|
||||
packaging = a.get("packaging", "") or "无法判断"
|
||||
summary = a.get("summary", "") or f"{brand} {name}"
|
||||
# 优先取 product 属性上的 portrait_prompt(兼容旧schema),否则用顶层 <people> 解析结果
|
||||
_pp_from_attr = a.get("portrait_prompt", "")
|
||||
if _pp_from_attr and _pp_from_attr != "无人像":
|
||||
portrait_prompt = _pp_from_attr
|
||||
return {
|
||||
"name": name,
|
||||
"brand": brand,
|
||||
@@ -429,10 +617,26 @@ def _analyze_single_image(
|
||||
"key_features": feat_list or [features] if features else ["无法判断"],
|
||||
"scene": scene,
|
||||
"mood": mood,
|
||||
"portrait_prompt": a.get("portrait_prompt", "无人像"),
|
||||
"portrait_prompt": portrait_prompt,
|
||||
"summary": summary,
|
||||
"_source": "xml",
|
||||
}
|
||||
# 没有 product 标签但有 <people has_person="true"> 也要能取到人物描述(兜底)
|
||||
if portrait_prompt != "无人像":
|
||||
return {
|
||||
"name": "未识别",
|
||||
"brand": "无法判断",
|
||||
"category": "无法判断",
|
||||
"appearance": "无法判断",
|
||||
"packaging": "无法判断",
|
||||
"text_on_package": [],
|
||||
"key_features": ["无法判断"],
|
||||
"scene": scene,
|
||||
"mood": mood,
|
||||
"portrait_prompt": portrait_prompt,
|
||||
"summary": "未识别",
|
||||
"_source": "xml_no_product",
|
||||
}
|
||||
return _vision_fallback(idx, "no_product_tag")
|
||||
|
||||
def _normalize(raw, source: str) -> dict:
|
||||
@@ -617,7 +821,7 @@ def _step_intent_parsing(job: ViralVideoJob, image_analysis: dict) -> dict:
|
||||
temperature=0.4,
|
||||
max_tokens=1024,
|
||||
model=_m,
|
||||
timeout=45,
|
||||
timeout=60,
|
||||
) # #2180: 意图解析 LLM 实测需更长响应,原25s太紧
|
||||
if not raw:
|
||||
continue
|
||||
@@ -1037,15 +1241,16 @@ def _step_script_generation(job: ViralVideoJob, intent: dict, image_analysis: di
|
||||
_pro = getattr(_s, "doubao_model", None) or _fast
|
||||
try:
|
||||
# 第一次:快模型 25s
|
||||
normalized = _try_gen(_fast, 0.8, 2500, "fast-first", tmo=45)
|
||||
normalized = _try_gen(_fast, 0.8, 2500, "fast-first", tmo=90)
|
||||
if normalized is not None:
|
||||
return normalized
|
||||
# 第二次:快模型降温度+加大 max_tokens,25s
|
||||
normalized = _try_gen(_fast, 0.6, 3200, "fast-retry", tmo=45)
|
||||
# #2183: 实测pro 1500tok输出需75.8s,单次timeout提到90s
|
||||
normalized = _try_gen(_fast, 0.6, 3200, "fast-retry", tmo=90)
|
||||
if normalized is not None:
|
||||
return normalized
|
||||
# 第三次:用主力模型兜底,给 120s
|
||||
if _pro and _pro != _fast:
|
||||
normalized = _try_gen(_pro, 0.7, 3500, "pro-fallback", tmo=60)
|
||||
normalized = _try_gen(_pro, 0.7, 3500, "pro-fallback", tmo=120)
|
||||
if normalized is not None:
|
||||
return normalized
|
||||
logger.warning("[爆款视频] 编导脚本三次都未生成合格结果,使用兜底脚本")
|
||||
@@ -1310,13 +1515,47 @@ def _step_render(job: ViralVideoJob, copy_result: dict, tts_audio_url: str | Non
|
||||
pre_trusted = list(pti)
|
||||
logger.info("[爆款视频] 使用信任链预热结果 n=%d,跳过现场 Seedream AI 化", len(pre_trusted))
|
||||
elif all_portrait_urls and _mcfg.get("provider", "doubao") == "doubao":
|
||||
# #2183: 真·现场跑信任链——同步调用 Seedream t2i,拿到 AI 人像 URL 后再传 Seedance
|
||||
logger.info(
|
||||
"[爆款视频] 预热结果不可用(%s/%d张),将现场跑信任链",
|
||||
"[爆款视频] 预热结果不可用(%s/%d张),现场同步跑信任链Seedream t2i",
|
||||
"缺失" if not pti else f"{len(pti)}/{len(all_portrait_urls)}",
|
||||
len(all_portrait_urls),
|
||||
)
|
||||
try:
|
||||
from packages.shared.ai_service import preheat_trust_chain
|
||||
|
||||
# 第一次调用:带参考图/首帧/音频/参考视频
|
||||
_ia = getattr(job, "image_analysis", None) or {}
|
||||
_prods = (_ia.get("products") if isinstance(_ia, dict) else None) or []
|
||||
_pdescs = []
|
||||
if _prods:
|
||||
_pdescs = [(pp.get("portrait_prompt") or "无人像") for pp in _prods]
|
||||
elif isinstance(_ia, dict):
|
||||
_pp0 = _ia.get("portrait_prompt") or "无人像"
|
||||
if _pp0 and _pp0 != "无人像":
|
||||
_pdescs = [_pp0]
|
||||
_valid = [d for d in _pdescs if d and isinstance(d, str) and "无人像" not in d and len(d) >= 10]
|
||||
if _valid:
|
||||
_t0 = time.time()
|
||||
_live_urls = preheat_trust_chain(_valid, timeout=120)
|
||||
if _live_urls and len(_live_urls) == len(all_portrait_urls):
|
||||
pre_trusted = list(_live_urls)
|
||||
logger.info(
|
||||
"[爆款视频] 现场信任链t2i完成 %d张 耗时%.1fs,将用AI人像传Seedance",
|
||||
len(pre_trusted),
|
||||
time.time() - _t0,
|
||||
)
|
||||
else:
|
||||
logger.warning(
|
||||
"[爆款视频] 现场信任链t2i返回不匹配 urls=%s n_portraits=%d,回退原图+400降级纯t2v",
|
||||
_live_urls,
|
||||
len(all_portrait_urls),
|
||||
)
|
||||
else:
|
||||
logger.info("[爆款视频] 无有效人物描述(可能是商品图),无需现场跑信任链")
|
||||
except Exception as _te:
|
||||
logger.warning("[爆款视频] 现场跑信任链异常: %s,回退原图+400降级纯t2v", _te, exc_info=True)
|
||||
|
||||
# 第一次调用:带参考图/首帧/音频/参考视频(pre_trusted有值→走信任链;无值→原图;若400 ai_client内部自动降级纯t2v)
|
||||
result = call_video_generation(
|
||||
prompt=prompt,
|
||||
image_url=first_image,
|
||||
@@ -1609,8 +1848,26 @@ def run_viral_video_analyze(self: Task, job_id: str) -> dict:
|
||||
|
||||
image_analysis = _step_image_analysis(job)
|
||||
job.image_analysis = image_analysis
|
||||
# #2183/#2174: VLM完成后立即启动信任链t2i预热(后台daemon线程,与后续阶段并行)
|
||||
if job.images:
|
||||
try:
|
||||
_products = (image_analysis or {}).get("products", []) or []
|
||||
_portrait_descs = [(p.get("portrait_prompt") or "无人像") for p in _products] if _products else []
|
||||
if not _portrait_descs and isinstance(image_analysis, dict):
|
||||
_pp = image_analysis.get("portrait_prompt") or "无人像"
|
||||
if _pp and _pp != "无人像":
|
||||
_portrait_descs = [_pp]
|
||||
_start_trust_chain_preheat(job.id, _portrait_descs)
|
||||
except Exception as _e:
|
||||
logger.warning("[爆款视频][阶段1] 启动信任链t2i预热失败: %s", _e)
|
||||
_save_job(repo, job, session)
|
||||
_emit_progress(job_id, ViralVideoStage.IMAGE_ANALYSIS, 60.0, "图片分析完成", {"result": image_analysis})
|
||||
_emit_progress(
|
||||
job_id,
|
||||
ViralVideoStage.IMAGE_ANALYSIS,
|
||||
60.0,
|
||||
"图片分析完成,AI人像预热中...",
|
||||
{"result": image_analysis, "trust_chain_preheating": True},
|
||||
)
|
||||
|
||||
style_guide = None
|
||||
if job.reference_video_url or job.style_template_id:
|
||||
@@ -1657,8 +1914,8 @@ def run_viral_video_analyze(self: Task, job_id: str) -> dict:
|
||||
bind=True,
|
||||
max_retries=1,
|
||||
name="worker.run_viral_video_generate_copy",
|
||||
soft_time_limit=360, # #2173: 6min(编导脚本含意图+三级重试+审核,fast超时转pro)
|
||||
time_limit=420, # #2173: 7min hard limit
|
||||
soft_time_limit=600, # #2183: pro长脚本~120s+三级重试最坏300s+intent/review ~105s,给到10min
|
||||
time_limit=660, # #2183: 11min hard limit
|
||||
)
|
||||
def run_viral_video_generate_copy(self: Task, job_id: str) -> dict:
|
||||
"""v1.6 阶段2(v1.6.1 提速版):意图解析 → 编导分镜脚本生成 → 直接返回,合规审核后置到出片前。
|
||||
|
||||
@@ -50,14 +50,25 @@ _IMAGE_ANALYSIS_SYSTEM = f"""你是电商商品视觉分析师,负责从商品
|
||||
请严格按下面的标签格式输出,标签名一个都不能改,不要输出任何解释,不要用代码块:
|
||||
<products> 下面每个产品用一个 <product> 标签,属性 name 是产品名、features 是外观特征、position 是 main 或 secondary、image_index 是第几张图(从0开始)。
|
||||
<colors> 下面每个主要颜色用一个 <color> 标签,属性 hex 是色值、name 是颜色名、coverage 是占比小数。
|
||||
<people> 用一个标签,属性 has_person、count、gender、age_range、pose、expression 分别描述人物情况。
|
||||
<people> 用一个标签,属性 has_person、count、gender、age_range、hair(发型发色)、skin_tone(肤色)、face_shape(脸型)、outfit(穿着)、pose(姿态)、expression(表情)分别描述人物外貌。有人物时属性尽量具体(如hair="黑色长直发"、outfit="白色衬衫"),无人像时除has_person=false外其他填"无法判断"。
|
||||
<mood> 标签写画面整体情绪氛围。
|
||||
<visible_text> 下面每处可见文字用一个 <text_item> 标签,属性 text 是文字内容、position 是位置。
|
||||
<scene> 标签写场景描述。
|
||||
<quality> 用一个标签,属性 resolution、lighting、composition、blur 描述画质。
|
||||
<key_selling_points> 下面每个卖点用一个 <point> 标签。
|
||||
|
||||
看不到或无法判断的内容,属性值填“无法判断”,布尔值填 false,不要留空标签。"""
|
||||
【人物属性硬性要求(has_person=true时必须遵守)】
|
||||
hair/skin_tone/face_shape/outfit四项绝对禁止填“无法判断”,必须基于图片可见特征给出具体中文描述:
|
||||
- hair:必须描述发型+发色,如“黑色齐肩直发”“棕色微卷中长发”“深棕色短发”
|
||||
- skin_tone:必须描述肤色,如“暖调自然肤色”“白皙肤色”“小麦色”
|
||||
- face_shape:必须描述脸型,如“鹅蛋脸”“圆脸”“瓜子脸”“方脸”
|
||||
- outfit:必须描述可见穿着,如“米色翻领衬衫”“白色T恤”“黑色连衣裙”
|
||||
即使局部被遮挡也要根据可见部分合理推断;确实看不清时按最接近的直观印象描述。
|
||||
|
||||
其他非人物属性看不到或无法判断时填“无法判断”,布尔值填false,不要留空标签。
|
||||
|
||||
【有人物场景输出参考(女性手持商品示例,必须写全10个属性,禁止省略)】
|
||||
<people has_person="true" count="1" gender="女" age_range="青年" hair="黑色齐肩直发" skin_tone="暖调自然肤色" face_shape="鹅蛋脸" outfit="米色翻领衬衫" pose="正面半身,手持商品" expression="面带微笑"/>"""
|
||||
|
||||
_IMAGE_ANALYSIS_USER = """请分析以下商品图片,共 {image_count} 张。
|
||||
所属行业:{industry}
|
||||
@@ -73,7 +84,7 @@ _IMAGE_ANALYSIS_EXAMPLE = """<products>
|
||||
<color hex="#D32F2F" name="红色" coverage="0.4"/>
|
||||
<color hex="#FFFFFF" name="白色" coverage="0.5"/>
|
||||
</colors>
|
||||
<people has_person="false" count="0" gender="无法判断" age_range="无法判断" pose="无法判断" expression="无法判断"/>
|
||||
<people has_person="false" count="0" gender="无法判断" age_range="无法判断" hair="无法判断" skin_tone="无法判断" face_shape="无法判断" outfit="无法判断" pose="无法判断" expression="无法判断"/>
|
||||
<mood>干净、实用</mood>
|
||||
<visible_text>
|
||||
<text_item text="多功能油污净" position="瓶身正面"/>
|
||||
|
||||
@@ -92,7 +92,7 @@ class SharedSettings(BaseSettings):
|
||||
doubao_api_key: str = ""
|
||||
doubao_model: str = "doubao-seed-2-1-pro-260915" # 推理模型(Seed 2.1 Pro,深度思考+多模态;原 seed-1-6 已下线)
|
||||
doubao_fast_model: str = (
|
||||
"doubao-seed-2-1-lite-260915" # 快速模型(Seed 2.1 Lite,高 RPM,编导/审核/VLM lite;原 1-5-pro-32k 已 Retiring)
|
||||
"doubao-seed-2-1-pro-260915" # #2181: lite方舟侧100%超时,默认fast_model也走pro;方舟恢复lite后通过ENV DOUBAO_FAST_MODEL切回
|
||||
)
|
||||
doubao_base_url: str = "https://ark.cn-beijing.volces.com/api/v3"
|
||||
doubao_timeout: int = 45 # #2180: 方舟LLM高峰期响应6-8s,原30s太紧提到45s
|
||||
|
||||
@@ -585,7 +585,7 @@ class DoubaoClient:
|
||||
# #2172/#2174: 信任链——使用预热好的 Seedream t2i 文生图(纯模型生成人像,是方舟信任产物,
|
||||
# 不会触发肖像审核)。预热在 VLM 分析后由 daemon 线程后台完成,结果通过 pre_trusted_images 传入。
|
||||
# - 预热结果有效 → 替换原参考图,走 omni_ref 模式
|
||||
# - 预热结果不可用 → 直接用原图(若被400肖像拦截,#2166自动降级纯t2v),避免现场跑t2i阻塞渲染
|
||||
# - 预热结果不可用 → 直接用原图(上层 _step_render 已现场同步跑 Seedream t2i 兜底;若再被400拦截,下方自动降级纯t2v)
|
||||
# 信任链只作用于 doubao provider;DashScope(Wan) 保持原行为。
|
||||
trust_chain_applied = False
|
||||
if provider == "doubao" and getattr(self, "trust_chain_enabled", True) and pre_trusted_images:
|
||||
@@ -763,6 +763,26 @@ class DoubaoClient:
|
||||
# 保留第二次的错误信息
|
||||
sc, body = sc2, body2
|
||||
|
||||
# #2183: portrait_intercept / 真人肖像审核拦截 → 去掉所有参考图(含image_url首帧),纯 t2v 重试一次
|
||||
# 信任链预热或现场 t2i 都失败时的最后兜底,保证能出片
|
||||
if not task_id and sc == 400:
|
||||
_err_code_for_400, _ = _classify_video_error(sc, body, last_err)
|
||||
if _err_code_for_400 == "portrait_intercept" and (image_url or ref_imgs):
|
||||
logger.warning(
|
||||
"Seedance 创建因 portrait_intercept 失败,降级纯 t2v(移除所有参考图)重试: img=%d ref=%d",
|
||||
1 if image_url else 0,
|
||||
len(ref_imgs),
|
||||
)
|
||||
_t2v_payload = dict(create_payload)
|
||||
_t2v_payload["content"] = [{"type": "text", "text": prompt.strip()}]
|
||||
_t2v_payload["ratio"] = ratio or "9:16"
|
||||
task_id, last_err, sc3, body3 = _do_create(_t2v_payload)
|
||||
if task_id:
|
||||
sc, body = sc3, body3
|
||||
logger.info("[trust-chain] portrait_intercept 降级纯 t2v 成功 task_id=%s", task_id)
|
||||
else:
|
||||
sc, body = sc3, body3
|
||||
|
||||
if not task_id:
|
||||
err_code, user_msg = _classify_video_error(sc, body, last_err)
|
||||
self.last_video_error = {
|
||||
|
||||
Reference in New Issue
Block a user