docs: report face deduplication format mismatch bug
問題: - Face Deduplication 多次失敗 - AttributeError: 'list' object has no attribute 'items' 根本原因: - face_clustering_processor.py 生成的 frames 是列表 - store_traced_faces.py 期望 frames 是字典 - 格式不匹配導致崩潰 修復: - ✅ 已修復 store_traced_faces.py - ✅ 支持列表和字典兩種格式 - ✅ 腳本可以成功運行 測試結果: - ✅ TRACE_STORE completed successfully - ✅ Face trace + DB store completed - ⚠️ no traces generated (another issue) 下一步: - 檢查 face tracing 邏輯 - 確認 traces 正確生成
This commit is contained in:
@@ -0,0 +1,205 @@
|
||||
---
|
||||
title: Face Deduplication 失敗問題報告
|
||||
version: 1.0
|
||||
date: 2026-09-27
|
||||
author: OpenCode
|
||||
status: bug_confirmed
|
||||
---
|
||||
|
||||
## 問題描述
|
||||
|
||||
**Face Deduplication 多次失敗,無法成功執行**
|
||||
|
||||
---
|
||||
|
||||
## 測試案例
|
||||
|
||||
**文件**: 020.mp4 (14.2M, 528 frames)
|
||||
**UUID**: b496a68800f90770aa7246c877f38985
|
||||
|
||||
---
|
||||
|
||||
## 錯誤信息
|
||||
|
||||
```
|
||||
AttributeError: 'list' object has no attribute 'items'
|
||||
File: /Users/accusys/momentry_core/scripts/store_traced_faces.py, line 288
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 根本原因
|
||||
|
||||
### 格式不匹配
|
||||
|
||||
#### face_clustering_processor.py 生成的格式
|
||||
|
||||
```json
|
||||
{
|
||||
"status": "has_faces",
|
||||
"frames": [ // ← 列表(數組)
|
||||
{
|
||||
"frame": 0,
|
||||
"timestamp": 0.0,
|
||||
"faces": [...]
|
||||
},
|
||||
...
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### store_traced_faces.py 期望的格式
|
||||
|
||||
```python
|
||||
# Line 288
|
||||
for frame_num_str, frame_data in sorted(frames.items(), key=lambda x: int(x[0])):
|
||||
# 期望 frames 是字典(對象)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 問題分析
|
||||
|
||||
### 數據流
|
||||
|
||||
```
|
||||
Face Detection
|
||||
↓
|
||||
Face Tracing (生成 face.json)
|
||||
↓
|
||||
Face Clustering (生成 face_traced.json)
|
||||
↓
|
||||
store_traced_faces.py (讀取 face_traced.json) ← 錯誤在這裡
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 錯誤代碼位置
|
||||
|
||||
**文件**: `/Users/accusys/momentry_core/scripts/store_traced_faces.py`
|
||||
|
||||
```python
|
||||
# Line 284-288
|
||||
frames = data.get("frames", {})
|
||||
|
||||
# 期望 frames 是字典,但實際是列表
|
||||
for frame_num_str, frame_data in sorted(frames.items(), key=lambda x: int(x[0])):
|
||||
# ❌ AttributeError: 'list' object has no attribute 'items'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 日誌證據
|
||||
|
||||
```
|
||||
[TRACE_STORE stderr] AttributeError: 'list' object has no attribute 'items'
|
||||
[TRACE_STORE] Process failed: exit status: 1
|
||||
❌ Face trace + DB store failed for b496a68800f90770aa7246c877f38985
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 影響
|
||||
|
||||
### ❌ Face Deduplication 失敗
|
||||
|
||||
- `face_cluster` processor 完成但輸出為空
|
||||
- `face_clusters` 表中沒有記錄
|
||||
- Face Dedup 無法執行
|
||||
|
||||
---
|
||||
|
||||
### ❌ 後續流程阻塞
|
||||
|
||||
```
|
||||
Face Dedup failed
|
||||
↓
|
||||
TKG Nodes cannot be built
|
||||
↓
|
||||
TKG Edges cannot be built
|
||||
↓
|
||||
Rule2 Ingestion cannot run
|
||||
↓
|
||||
VLM Summary cannot run
|
||||
↓
|
||||
moment_chunks cannot be generated
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 修復方案
|
||||
|
||||
### 方案 A: 修改 store_traced_faces.py(推薦)
|
||||
|
||||
**修改**: Line 284-288
|
||||
|
||||
```python
|
||||
frames = data.get("frames", {})
|
||||
|
||||
# 判斷 frames 是列表還是字典
|
||||
if isinstance(frames, list):
|
||||
# 新格式:frames 是列表
|
||||
for frame_data in frames:
|
||||
frame_num = frame_data.get("frame")
|
||||
# 處理...
|
||||
else:
|
||||
# 舊格式:frames 是字典
|
||||
for frame_num_str, frame_data in sorted(frames.items(), key=lambda x: int(x[0])):
|
||||
frame_num = int(frame_num_str)
|
||||
# 處理...
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 方案 B: 修改 face_clustering_processor.py
|
||||
|
||||
**修改**: 輸出格式為字典
|
||||
|
||||
```python
|
||||
output_frames_dict = {}
|
||||
for frame_obj in output_frames:
|
||||
frame_num = frame_obj["frame"]
|
||||
output_frames_dict[str(frame_num)] = frame_obj
|
||||
|
||||
output_data = {
|
||||
"status": "has_faces",
|
||||
"file_uuid": file_uuid,
|
||||
"clusters": clusters,
|
||||
"frames": output_frames_dict, # ← 改為字典
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 建議
|
||||
|
||||
### 推薦方案 A
|
||||
|
||||
**理由**:
|
||||
1. 更靈活,兼容兩種格式
|
||||
2. 不影響其他依賴 face_clustering_processor.py 的代碼
|
||||
3. 向後兼容
|
||||
|
||||
---
|
||||
|
||||
## 下一步
|
||||
|
||||
1. **修復 store_traced_faces.py**
|
||||
2. **重新測試 020.mp4**
|
||||
3. **驗證 Face Dedup 成功**
|
||||
4. **檢查後續流程是否恢復**
|
||||
|
||||
---
|
||||
|
||||
## 相關文件
|
||||
|
||||
- `/Users/accusys/momentry_core/scripts/store_traced_faces.py`
|
||||
- `/Users/accusys/momentry_core/scripts/face_clustering_processor.py`
|
||||
- `/Users/accusys/momentry/output/b496a68800f90770aa7246c877f38985.face_traced.json`
|
||||
|
||||
---
|
||||
|
||||
**優先級**: **High**
|
||||
**狀態**: **確認,待修復**
|
||||
Reference in New Issue
Block a user