修复: VLM 非机动车违停 prompt 参数缺失 + 返回格式兼容

- 移除 non_motor_vehicle_parking prompt 中未传递的 {timestamp} 占位符
- 统一该算法的 prompt 输出格式为 confirmed/description(与其他算法一致)
- 解析时兼容 is_real/reason 字段,防止旧版 prompt 或模型返回不一致
This commit is contained in:
2026-04-13 10:21:33 +08:00
parent f8b4b65ced
commit 33e272cbc7

View File

@@ -61,15 +61,18 @@ description要求≤15字直接说结论注明大致车辆数。
仅输出JSON{{"confirmed":true,"description":"..."}}""",
"non_motor_vehicle_parking": """你是安防监控AI复核员。算法类型非机动车违停检测监控区域{roi_name}
截图显示时间:{timestamp}
任务:判断图中是否有非机动车(自行车、电动车、摩托车等)违规停放在禁停区域。
分析要点:
1. 是否存在非机动车(自行车、电动车、共享单车等)
2. 非机动车是否处于静止停放状态(而非骑行经过)
3. 是否在禁停区域/消防通道内
4. 停放是否造成通道阻塞
请用JSON回复{{"is_real": true/false, "confidence": 0.0-1.0, "reason": "判断依据"}}""",
- confirmed=true有非机动车违停告警成立
- confirmed=false无非机动车违停误报
description要求≤15字直接说结论。
告警成立示例:"电动车违停在消防通道"
误报示例:"该区域无非机动车违停"
仅输出JSON{{"confirmed":true,"description":"..."}}""",
}
# 通用降级 prompt未知算法类型时使用
@@ -184,13 +187,16 @@ class VLMService:
content = content.strip()
result = json.loads(content)
# 兼容不同 prompt 返回格式is_real/reason vs confirmed/description
confirmed = result.get("confirmed") if "confirmed" in result else result.get("is_real", True)
description = result.get("description") or result.get("reason", "")
logger.info(
f"VLM 复核完成: confirmed={result.get('confirmed')}, "
f"desc={result.get('description', '')[:30]}"
f"VLM 复核完成: confirmed={confirmed}, "
f"desc={description[:30]}"
)
return {
"confirmed": result.get("confirmed", True),
"description": result.get("description", ""),
"confirmed": confirmed,
"description": description,
"skipped": False,
}