fix(fam-edge): 人物标识清洗 - _clean_person 去括号注释(防模型输出'人物A(别名/标识:人物B)'污染人物表);prompt 明确 people 只填标识本身;events.people 与 people_mentioned 均清洗
This commit is contained in:
@@ -72,7 +72,8 @@ def build_video_prompt(known_members: str, event_start_time: str,
|
|||||||
- 表情/情绪线索(如可辨认:微笑/皱眉/哭泣/平静)
|
- 表情/情绪线索(如可辨认:微笑/皱眉/哭泣/平静)
|
||||||
- 周围环境与背景物品(电视开着/桌上水杯/地上有玩具等,辅助判断场景)
|
- 周围环境与背景物品(电视开着/桌上水杯/地上有玩具等,辅助判断场景)
|
||||||
4. people: 该时刻出现的人物标识。已知成员用真名,未知人物用「人物A」「人物B」
|
4. people: 该时刻出现的人物标识。已知成员用真名,未知人物用「人物A」「人物B」
|
||||||
本视频内连续编号(同一人保持同一编号)。
|
本视频内连续编号(同一人保持同一编号)。只填标识本身,不要带括号注释
|
||||||
|
(如只写"人物A",不要写"人物A(别名/标识:人物B)")。
|
||||||
5. people_mentioned: 必须等于 events 中所有 people 字段出现过的标识去重后的集合。
|
5. people_mentioned: 必须等于 events 中所有 people 字段出现过的标识去重后的集合。
|
||||||
一致性强制:events 里出现的标识必须都在 people_mentioned 里,反之亦然。
|
一致性强制:events 里出现的标识必须都在 people_mentioned 里,反之亦然。
|
||||||
6. is_attention_event: 跌倒、危险动作、异常哭闹、陌生人闯入、身体不适等需关注事件
|
6. is_attention_event: 跌倒、危险动作、异常哭闹、陌生人闯入、身体不适等需关注事件
|
||||||
|
|||||||
@@ -126,6 +126,16 @@ def validate_video(path: str) -> tuple:
|
|||||||
return False, f"validate_exc: {e}", None
|
return False, f"validate_exc: {e}", None
|
||||||
|
|
||||||
|
|
||||||
|
def _clean_person(s: str) -> str:
|
||||||
|
"""清洗人物标识:去掉括号注释(如 "人物A(别名/标识:人物B)" -> "人物A")。"""
|
||||||
|
s = (s or '').strip()
|
||||||
|
for sep in ('(', '('):
|
||||||
|
if sep in s:
|
||||||
|
s = s.split(sep, 1)[0].strip()
|
||||||
|
break
|
||||||
|
return s
|
||||||
|
|
||||||
|
|
||||||
class VideoProcessor:
|
class VideoProcessor:
|
||||||
def __init__(self, db: oracle_db.OracleDB):
|
def __init__(self, db: oracle_db.OracleDB):
|
||||||
self.config = load_config()
|
self.config = load_config()
|
||||||
@@ -244,11 +254,15 @@ class VideoProcessor:
|
|||||||
norm_events.append({
|
norm_events.append({
|
||||||
"timestamp": abs_ts,
|
"timestamp": abs_ts,
|
||||||
"description": str(ev.get('description', '')),
|
"description": str(ev.get('description', '')),
|
||||||
"people": [str(p) for p in ev.get('people', []) if p],
|
"people": [_clean_person(str(p)) for p in ev.get('people', []) if p],
|
||||||
"is_attention_event": bool(ev.get('is_attention_event', False)),
|
"is_attention_event": bool(ev.get('is_attention_event', False)),
|
||||||
})
|
})
|
||||||
offsets.append(off)
|
offsets.append(off)
|
||||||
|
|
||||||
|
# 清洗 people_mentioned(去掉括号注释串,防污染人物表/合并)
|
||||||
|
people = [_clean_person(str(p)) for p in people if p]
|
||||||
|
people = [p for p in people if p and p not in ('无人', '无')]
|
||||||
|
|
||||||
event_ids = self.db.mark_video_processed(video_id, summary, norm_events, people, provider)
|
event_ids = self.db.mark_video_processed(video_id, summary, norm_events, people, provider)
|
||||||
# 缩略图 + 每个事件对应时间点的画面截图(用相对偏移直接定位,避免模型绝对时间误差)
|
# 缩略图 + 每个事件对应时间点的画面截图(用相对偏移直接定位,避免模型绝对时间误差)
|
||||||
if vrow and vrow['local_path']:
|
if vrow and vrow['local_path']:
|
||||||
|
|||||||
Reference in New Issue
Block a user