Commit Graph

51 Commits

Author SHA1 Message Date
Accusys b331a3d0cd docs: A-8 design - configuration-driven processor list
- Analyze three approaches: database table, config file, environment variable
- Recommend: Phase 1 (config file) → Phase 2 (database table)
- Provide implementation plan and acceptance criteria

References:
- A-8 in Momentry_Release_Requirements_20261004.md v1.1
- Quick fix (remove pose): commit d7df19e2
2026-10-04 14:32:49 +08:00
Accusys e0d04e242f feat: face clustering pipeline improvements and Rust/Swift face processing
- Add Rust face processor module (detection, embedding, tracking, qdrant)
- Add Facenet CoreML/ONNX conversion scripts and tests
- Refactor swift_face into Sources/swift_face with ArgumentParser support
- Update store_traced_faces to handle face.json correctly
- Fix ASRX parsing and TKG bbox reading from Qdrant
- Improve admin_config and trace_agent APIs
- Add M4 workspace docs for face clustering, dedup, and Facenet validation
- Fix worker heartbeat TTL (poll_interval x 3, min 60s) for offline detection
2026-10-02 12:24:55 +08:00
Accusys 9823cd4328 analysis: deep scan trace_id=-1 issue
問題鏈:
1. Qdrant trace_id 全部為 -1 (40 個 faces)
2. rust_face_cluster 過濾所有 faces (trace_id >= 0)
3. 沒有 trace_profiles 生成
4. Worker 無限循環 (trace_stability = 0)
5. Deep scan 卡死

數據證據:
- Qdrant: trace_id=-1: 40 faces (100%)
- rust_face_cluster: Found 0 unique traces
- processor_results: 只有 scene_vlm
- 輸出文件: 全部缺失
- Worker: 無限循環,每 2 秒檢查一次

修復:
- ✅ Python 腳本修復 (face_clustering_processor.py)
- ✅ 問題定位完成
- ⏳ 等待決策: 方案 A (重置) 或 方案 B (調試)

文檔:
- docs_v1.0/M4_workspace/2026-09-28_deep_scan_trace_id_issue.md
- docs_v1.0/M4_workspace/2026-09-28_deep_scan_final_summary.md

狀態: ⚠️ Critical - 等待 M4 決策
2026-09-28 20:55:35 +08:00
Accusys 6c705df0d9 design: Swift Face Trace with Apple Vision + ANE
目標:
- 實現 Swift 版本的 Face Trace
- 使用 Apple Vision + ANE 加速
- 統一所有 face 工具使用 Swift

技術方案:
1. VNTrackFaceLandmarksRequest (推薦)
   - 原生追蹤 API
   - ANE 加速
   - 自動 face ID 分配

2. VNDetectFaceLandmarksRequest + 自定義追蹤
   - 更靈活
   - 需要自己實現追蹤邏輯

當前狀態:
- FACE: Swift ✅ (default)
- FACE_TRACE: Rust (因為沒有 Swift 版本)

設計內容:
- API 選擇 (VNTrackFaceLandmarksRequest)
- 架構設計
- 性能預期
- 實現步驟
- 風險評估

實現計劃:
- Phase 1: 原型 (2-3 天)
- Phase 2: 優化 (1-2 天)
- Phase 3: 集成 (1 天)

配置更新:
- face_trace: Swift (priority 0) > Rust (priority 1)

預期收益:
- Apple Vision + ANE 加速
- 統一 face 工具架構
- 可能的性能提升

風險:
- ⚠️ Apple Vision API 穩定性
- ⚠️ faceID 跨幀連續性

建議:
- 短期: 繼續使用 Rust (已驗證)
- 中期: 實現 Swift 原型
- 長期: 根據性能決定
2026-09-28 16:36:48 +08:00
Accusys c122913492 docs: add Apple native video performance analysis
性能對比測試:
- Rust (ffmpeg): 0.81s
- Swift (Apple Native): 6.18s
- 差異: ffmpeg 7.65x 更快

原因分析:
1. ffmpeg 高度優化 (C + SIMD)
2. Swift 原型開銷大:
   - CVPixelBuffer 創建
   - Core Image 處理
   - CGImage 創建
   - CPU-GPU 傳輸

優化方向:
1. Phase 1: 快速優化 (3x, 1天)
   - 減少幀處理頻率
   - 直接訪問像素
   - 跳過 Core Image

2. Phase 2: Vision + ANE (5x, 2-3天)
   - 使用 Vision Framework
   - ANE 加速

3. Phase 3: Metal GPU (10x, 1周)
   - Metal shader
   - GPU 並行

建議:
- 短期: 繼續使用 ffmpeg (性能優)
- 中期: 優化 Apple Native
- 長期: 根據需求選擇

結論: 可行但需優化
2026-09-28 15:06:50 +08:00
Accusys 3ff45f983e research: Apple native video analysis for CUT processor
研究目標:
- 評估使用 Apple native video API 替代 ffmpeg 的可行性
- 利用 Apple Vision + ANE 加速

實現方案:
- 方案 A: Swift 幀差異法 (已實現原型)
- 方案 B: Vision + Core ML (ANE 加速)
- 方案 C: Metal GPU 加速

原型實現:
- swift_scene_detector: AVFoundation + Core Image
- 功能: 場景檢測
- 測試: ✅ 成功

技術:
- AVAssetReader: 視頻幀提取
- Core Image: 幀差異計算
- CIDifferenceBlendMode: 差異混合

測試結果:
- Duration: 8.8s, FPS: 60.0, Frames: 529
- Detected: 1 scene
- ✅ 原型驗證成功

優勢:
- ✅ Apple native 實現
- ✅ 無外部依賴
- ✅ GPU 加速 (Core Image)
- ⚠️ 準確性待優化

下一步:
- 優化算法 (提高準確性)
- 性能對比 (vs ffmpeg)
- 考慮方案 B (Vision + Core ML)
2026-09-28 14:35:09 +08:00
Accusys 7d5afba1cd docs: add processor configuration v2/v3 with full commands
新增配置文件:
- processor_tools_v2.json: Tool/Model 分離設計
- processor_tools_v3.json: 完整命令和參數

新增文檔:
- Processor_Config_V2_Design.md: V2 設計文檔
- Processor_Commands_Reference.md: 完整命令參考

V3 配置特點:
- 明確區分 tool (python/rust/swift) 和 model (whisper/mediapipe)
- 包含完整執行命令和參數
- 支持變量替換 ({video_path}, {file_uuid}, etc.)
- 包含環境變量配置

命令示例:
- POSE (Python): python3.11 scripts/pose_processor_mediapipe.py {video} {output} --model-complexity 2
- FACE_TRACE (Rust): rust_store_traced_faces {uuid} --output-dir {dir}
- ASR (Python): python3.11 scripts/asr_processor_simplified.py {video} {output} --model large-v3

下一步:
- 更新 ToolSelector 支持 V3 格式
- 更新 Worker 使用新配置
2026-09-28 11:04:33 +08:00
Accusys 8ec5fc61d8 docs: add pipeline CLI execution feasibility analysis
結論:
- ✅ 100% 處理器有 CLI 對應 (14/14)
- ✅ 可以完全使用 CLI 執行
- 推薦: Hybrid 模式 (部分外部 CLI + 內部調用)
- 預期性能: 3x 加速

架構方案:
- Swift CLI: ASR, Face, OCR, Pose, ASRX
- Rust CLI: Face Cluster, Pose
- 主項目 Rust: CUT, Scene VLM, Face Tracing, TKG, Rule1/2, VLM Summary, Moment Chunks

實施步驟:
1. 啟用 Hybrid 模式
2. 性能關鍵處理器優先遷移
3. 保留 Python 作為 fallback
4. 監控並優化性能
2026-09-27 12:25:14 +08:00
Accusys 5efa09a2b5 docs: add Python vs CLI processor mapping analysis
對照表內容:
- 核心處理器對應關係
- Swift CLI: 11 個處理器
- Rust CLI: 4 個處理器
- 覆蓋率: 90% (9/10 核心功能)

性能對比:
- Swift vs Python: 3-5x 加速
- Rust vs Python: 3-10x 加速

建議:
- 生產環境使用 CLI
- 開發環境可使用 Python
- 部分處理器已集成到主項目 (Cut, Lip, TKG)
2026-09-27 12:19:56 +08:00
Accusys af028ab8f4 feat: restructure tools directory
新結構:
- tools/script/ (Python 處理器腳本)
- tools/cli/ (Swift/Rust CLI 工具)

遷移內容:
- Python 腳本: ASR, Face, Pose, Cut, OCR, VLM, Embedding, Identity
- Swift CLI: 24 個 Swift 處理器和測試文件
- Rust CLI: Face Cluster, Appearance, Pose

保留向後兼容:
- 舊路徑 scripts/ 仍然存在
- 環境變數可配置新路徑

文檔:
- tools/README.md
- docs_v1.0/DESIGN/Tools_Directory_Restructure.md
2026-09-27 12:04:23 +08:00
Accusys 3d54f0ba41 docs: TKG Builder Rust migration analysis
發現:
- ✅ Rust 版本已經存在 (tkg.rs, 3498行)
- ✅ Rust 版本功能更先進
- ⚠️ 缺少 4 個 Python 函數

功能對比:
- Python: 5 node builders, 5 edge builders
- Rust: 8 node builders, 4 edge builders
- Rust 獨有: gaze, lip, text, appearance, mutual_gaze

Rust 優勢:
- 性能: 10-100x faster
- 類型安全
- 更多高級功能

缺失功能:
1. build_body_track_nodes (pose.json)
2. build_detected_object_nodes (yolo.json)
3. build_co_occurrence_edges
4. build_face_body_edges

建議:
- 使用 Rust 版本
- 補充 4 個缺失函數
- 廢棄 Python 版本

工作量: 3-5 天
2026-09-27 11:40:53 +08:00
Accusys 357e585399 fix: Face processor now saves status and total_faces to face.json 2026-09-26 23:06:11 +08:00
Accusys 31d1b4050f fix: correct face detection threshold defaults
- Changed min_confidence from 50.0 to 0.5 (Vision uses 0.0-1.0 range)
- Changed min_size from 32 to 1 (was filtering out all small faces)
- Changed min_capture_quality from 25.0 to 0.25
- Fixes issue where all videos showed 0 faces detected

Root cause: admin_config.rs used wrong defaults (50.0/32) instead of
config.rs constants (0.5/1), causing Vision framework to filter out
ALL faces because confidence threshold exceeded valid range.

Verified: IMG_9449 now correctly detects 191 faces (was 0).
2026-09-18 02:42:21 +08:00
Accusys 3d13a06bd9 feat: face fix deployment + trace_* regeneration + executor stderr filter fix
- swift_face.swift: frame rounding (.rounded()), conf 0.75, min_size 64
- trace_* directories regenerated for KOBA (37 traces, start_frame 5307)
- executor.rs: stderr filter now logs all non-empty stderr (was discarding)
- VAD not skippable in ASRX (main_fixed.py Step 2 always runs)
- Step 2.5 sentence boundary refinement added
- Cluster agent async endpoints + similarity transparency
- Keyword search: relationship text extraction, priority ordering
- Face fix handoff doc for Studio team
2026-08-05 00:13:50 +08:00
Accusys 39a2cbc65b fix: face group name read consistency, sync_file_status fix, cleanup ghost records, identity_agent replaced with face_dedup
- get_face_groups_handler: COALESCE(tp.name, tn.label) for name consistency
- sync_file_status: compare JSON vs pre_chunks (not chunk table)
- face consistency: compare frames.len() not total_faces
- cleanup 2 ghost records with NULL file_name/file_path
- replace identity_agent with face_dedup in pipeline stages
- remove identity_agent_api.rs and all references
- update required_processors to match actual processors
- update AGENTS.md with team responsibilities
- add Studio pipeline changes documentation
2026-07-27 02:15:51 +08:00
Accusys 87aa7e0c40 feat: add source prefix to search results
- Add [OCR], [ASRX], [ASRX+OCR] prefix to text_content
- Add content field to SemanticSearchResult struct
- Update SQL queries to include content field
- Helps users distinguish the source of search results
2026-07-19 14:06:06 +08:00
Accusys 619b056ada fix: TKG stats API returning 0 - count_by_type used wrong column
- tkg_nodes has no edge_type column, query was failing silently
- Split into count_nodes(node_type) and count_edges(edge_type)
- Fixed text_region → text_trace node type name
- Also: OCR frame fix in rule1 (end_frame computed from end_time+FPS)
2026-07-02 14:53:47 +08:00
Accusys 0c3f385b1f remove: skin_tone_trace node type
- skin_tone is a person attribute (like height), not trace attribute
- Remove build_skin_tone_trace_nodes function
- Remove skin_tone_trace_nodes from TkgResult and API response
- Remove skin_tone_trace from documentation tables
2026-06-25 19:21:05 +08:00
Accusys 4273576612 feat: implement skin_tone_trace node builder and standardize TKG node naming
- Add build_skin_tone_trace_nodes() to tkg.rs (Fitzpatrick I-VI classification)
- Add skin_tone_trace_nodes field to TkgResult
- Standardize node naming: _trace -> _track (text uses _region)
- Add external_id format column to Node Types table
- Add storage names to Edge Types table
- Create TKG_FORMATION_V1.0.md with Phase 0-4 definition, flow diagram, queries
- Add cross-reference from identity_agent_v4.0.md to TKG Formation
- Update Python scripts to executable mode
2026-06-25 03:09:16 +08:00
Accusys 7e548f8b08 release: v1.3.0 - TKG node type renaming
Changes:
- Rust: face_trace → face_track (45 occurrences in 8 files)
- Rust: gaze_trace → gaze_track, lip_trace → lip_track
- Python: tkg_builder.py unified + pipeline_checklist.py fixed
- Swift: swift_hand.swift hand state detection (empty vs holding)

Node type changes:
  face_trace    → face_track
  person_trace  → body_track
  gaze_trace    → gaze_track
  lip_trace     → lip_track
  hand_trace    → hand_track
  speaker       → speaker_segment
  object        → detected_object
  text_trace    → text_region

Migration:
  PUBLIC schema: 12970 + 892 + 305 rows updated
2026-06-22 07:18:21 +08:00
Accusys d0858f288a docs: add CLI usage for TKG Level 1 builder
- Add Usage section with CLI commands
- TKG Level 1 builder: python scripts/tkg_level1_builder.py
- Query example for person_trace nodes
2026-06-22 03:24:04 +08:00
Accusys 9e0a0227ea docs: update Appearance_Feature_System with shot type detection
- Add reference units table (eye/head/shoulder width)
- Add BODY_PROPORTIONS constants for validation
- Add shot type detection section (full_body/medium_shot/close_up)
- Add height estimation strategies per shot type
- Update code examples with head_width and proportion_ratios
2026-06-22 02:50:45 +08:00
Accusys 606f31f13c feat: add appearance feature system with coordinate/scale fixes
- Add Appearance_Feature_System_V1.0.md design doc
- Add proportion_calculator.py for body proportions (height, body shape)
- Add feature_extractor.py for hierarchical feature extraction
- Add tkg_level1_builder.py for TKG person_trace nodes
- Fix mediapipe_holistic_processor.py to output Top-Left pixels
- Add MediaPipe format conversion in proportion_calculator

Coordinate system alignment:
- Swift Pose: Top-Left pixels (Y-flip done in swift_pose.swift)
- MediaPipe: Top-Left pixels (norm→pixel conversion added)
2026-06-22 02:27:03 +08:00
Accusys e949ac793d docs: face_detections deprecation plan - analysis and future migration
Analysis Results:
- 12 PostgreSQL fallback functions (TKG builders)
- 11 API modules with direct queries
- Identity binding: critical dependency

Current Status:
- Cannot deprecate now (Production stability)
- PostgreSQL fallback necessary
- Qdrant collection empty (0 points)

Recommendations:
- Keep PostgreSQL fallback for safety
- Document migration path
- New features use Qdrant/TKG
- Gradual migration in future (6+ months)

Migration Priority:
- P1: identity_binding.rs (TKG-based)
- P2: identity_agent_api.rs
- P3: identity_api.rs
- P4: Other APIs

Conclusion: face_detections cannot be deprecated yet due to:
- Production Qdrant empty
- API dependencies (identity binding)
- Stability requirements

Status: Draft (no immediate deprecation)
2026-06-21 05:24:12 +08:00
Accusys e214106d48 feat: Phase 2.7 identity resolution for gaze/lip trace nodes
Implementation:
- gaze_trace nodes: Query face_trace identity_id, add to properties
- lip_trace nodes: Query face_trace identity_id, add to properties
- Rule2: Extend identity resolution to support gaze_trace/lip_trace node types

Architecture:
- All face-related nodes now have identity_id in TKG properties
- Rule2 unified identity resolution for face_trace/gaze_trace/lip_trace
- TKG-only approach (no face_detections dependency for identity)

Code Changes:
- src/core/processor/tkg.rs: Add identity_id query in gaze/lip builders
- src/core/chunk/rule2_ingest.rs: Extend node_type condition

Docs:
- docs_v1.0/DESIGN/TKG_PHASE2_7_IDENTITY_RESOLUTION.md

Status: Implementation complete, pending test with valid file
2026-06-21 05:12:13 +08:00
Accusys 2cfcfdd1af feat: Phase 2.6 edges migration to Qdrant (TKG-only architecture)
Phase 2.6.1: co_occurrence_edges migration
- build_co_occurrence_edges_from_qdrant()
- Qdrant embeddings → frame grouping → YOLO objects
- Result: 6679 edges (vs 6701 PostgreSQL)

Phase 2.6.2: face_face_edges migration
- build_face_face_edges_from_qdrant()
- Qdrant embeddings → frame grouping → face pairs
- mutual_gaze detection preserved
- Result: 6 edges (exact match)

Phase 2.6.3: speaker_face_edges migration
- build_speaker_face_edges_from_qdrant()
- Qdrant embeddings → trace_id frame ranges
- SPEAKS_AS edge creation

Architecture:
- All edges use Qdrant payload (no face_detections queries)
- PostgreSQL fallback for empty Qdrant
- Estimated 3.6x performance improvement

Testing:
- Playground (3003): ✓ All Phase 2.6 logs verified
- Edge counts: ✓ Close match with PostgreSQL
- Fallback: ✓ Working

Docs:
- docs_v1.0/DESIGN/TKG_PHASE2_6_EDGES_MIGRATION.md
- docs_v1.0/M4_workspace/2026-06-21_phase2_6_test.md
2026-06-21 04:47:49 +08:00
Accusys c39805bb8e feat: Phase 2.5 gaze_trace and lip_trace Qdrant migration + Charade Q&A test
Phase 2.5.1: gaze_trace_nodes from Qdrant
- build_gaze_trace_nodes_from_qdrant()
- Read trace_id, frame, bbox from Qdrant payload
- Compute gaze stats (yaw, pitch, roll, gaze direction, blink)
- No PostgreSQL face_detections dependency

Phase 2.5.2: lip_trace_nodes from Qdrant + face.json
- build_lip_trace_nodes_from_qdrant()
- Match trace_id using Qdrant embeddings + face.json bbox
- Compute lip stats (openness, variance, speaking frames)
- Fixed face.json bbox structure (x,y,width,height not bbox object)

Test results:
- 23 gaze_trace nodes from Qdrant
- 23 lip_trace nodes from Qdrant + face.json
- 51 lip_sync edges created
- Charade Q&A: 20 identities, 75 relationship chunks

Docs:
- TKG_PHASE2_NONFACE_MIGRATION_V1.0.md (migration plan)
- 2026-06-21_charade_qa_test.md (Q&A test report)
2026-06-21 02:17:08 +08:00
Accusys 3ad6f8740a feat: Rule2 TKG relationship chunks + Phase0-1 Qdrant integration
Phase 0: TKG builder populate face_detections from face.json
- Fix face.json parser for pose_angle format
- Call store_traced_faces.py to set trace_id
- Skip if trace_id already populated

Phase 1: Qdrant face embeddings integration
- Add FaceEmbeddingDb module (src/core/db/face_embedding_db.rs)
- Create dev_face_embeddings collection (dim=512)
- Store 1122 face embeddings with pose metadata
- API: init_collection, batch_upsert, search_similar

Rule2: TKG edges → relationship chunks
- Design: RULE2_TKG_RELATIONSHIP_V1.0.md
- Implementation: rule2_ingest.rs
- ChunkType::Relationship added
- Edge types: SPEAKS_AS, MUTUAL_GAZE, CO_OCCURS_WITH, HAS_APPEARANCE, WEARS
- Auto-trigger on TKG rebuild

API:
- POST /api/v1/file/:file_uuid/rule2 (vectorization)
- POST /api/v1/file/:file_uuid/tkg/rebuild (auto Rule2)

Test: 75 relationship chunks created + vectorized
2026-06-21 00:22:41 +08:00
Accusys e1572907ae feat: ASRX hybrid pipeline, identity history, worker fixes, checkpoint system 2026-06-02 07:13:23 +08:00
Accusys 08167d73b2 docs: add Processor State Machine V1.0 design 2026-05-30 10:03:48 +08:00
Accusys 3d13d1390e Merge branch 'main' of http://192.168.110.200:3000/admin/momentry_core 2026-05-29 23:14:14 +08:00
M5Max128 f5cf12409b docs: expand JPEG validation plan to include Python scripts 2026-05-27 15:55:20 +08:00
M5Max128 ea20e27a4d docs: add JPEG validation implementation plan for M5Max48 2026-05-27 15:40:15 +08:00
M5Max128 a036d985b7 docs: add Thumbnail QA Analysis for M5Max48 implementation 2026-05-27 14:35:53 +08:00
M5Max128 c85794292a docs: add processor refactoring assessment from M5Max128 workspace research 2026-05-27 03:59:13 +08:00
M5Max128 955282e587 docs: add LaunchDaemon architecture reference for M5Max128/M5Max48 collaboration 2026-05-27 01:12:37 +08:00
M5Max128 f8bcc0356c feat: frame/time pipeline split + output validation
- Add PipelineType enum + pipeline() to ProcessorType
- Split ProcessorPool into frame_slots (max 2) and time_slots (max 1)
- Add can_start_for() for pipeline-aware scheduling
- Add validate_output_file() — checks JSON validity before marking complete
- Add 3 unit tests for validate_output_file()
- Create DESIGN/FRAME_TIME_PIPELINE_V1.0.md (492 lines)
2026-05-23 21:14:28 +08:00
M5Max128 e1619c724a Merge branch 'main' of http://192.168.110.200:3000/admin/momentry_core 2026-05-22 08:51:08 +08:00
M5Max128 701e71463d feat: identity PATCH update, alias system, name UNIQUE removal
- Add PATCH /api/v1/identity/:identity_uuid endpoint
- Migration 030: remove name UNIQUE, add tmdb_id index
- TMDb upsert: ON CONFLICT (name) -> ON CONFLICT (tmdb_id)
- get_or_create_identity: pre-check by name
- upload_identity: ON CONFLICT (name) -> ON CONFLICT (uuid)
- Search: include aliases in identity text search
- Add scripts/llm_metadata_enhancer.py
- Add DESIGN/IdentityUpdateAndAliasSystem.md
2026-05-22 08:35:32 +08:00
Accusys deb9516796 feat: TKG extension - pose data + mutual gaze detection 2026-05-22 07:09:54 +08:00
Accusys a9e9285032 docs: add TKG_QUERY_API_V1.0 design document 2026-05-22 06:29:25 +08:00
Accusys eec2eea880 docs: file_uuid generation rules for M4 2026-05-17 02:26:09 +08:00
Accusys 4ee8a42e76 docs: unified file probe SOP design — PyPDF2, python-docx, openpyxl, python-pptx 2026-05-15 13:52:09 +08:00
Accusys 79265dfb86 docs: unify file_uuid/identity_uuid naming in FILE_LIFECYCLE design doc 2026-05-15 13:30:43 +08:00
Accusys 5d899b7ada docs: FILE_LIFECYCLE — mtime, watcher detection-only, version V1.2 2026-05-15 13:28:05 +08:00
Accusys 7686ed0df7 fix: use mtime (not birthtime) for UUID birthday — rsync preserves mtime across systems 2026-05-15 13:26:36 +08:00
Accusys 66658b1156 docs: credential management design — classification, current state, recommended architecture 2026-05-15 12:22:56 +08:00
Accusys 9c47bb331f docs: FILE_LIFECYCLE is draft design → DESIGN/, not finalized standard 2026-05-15 12:20:07 +08:00
Accusys 9cf20d3f8e docs: reclassify — DESIGN→STANDARDS, conversion→M5_workspace, cleanup 2026-05-15 12:18:29 +08:00
Accusys 33b6f3cc66 docs: set document_type to design_doc 2026-05-15 12:10:47 +08:00