Commit Graph

651 Commits

Author SHA1 Message Date
Accusys 78eb4fb8d9 docs: studio team guide — face_artifacts completion counts (new API fields) 2026-08-16 23:14:10 +08:00
Accusys dda0b7cc7f feat: expose face artifact completion counts (trace_profile/key_frame/key_face) in scan + traces APIs 2026-08-16 23:09:12 +08:00
Accusys e2b9999cba fix: run-server-3002.sh restart — exec replaced stop's process, start never ran 2026-08-16 14:09:10 +08:00
Accusys 7c9c3ded42 feat: opt-in face trace quality filter (min_trace_len/min_confidence, default off) 2026-08-16 09:36:23 +08:00
Accusys 2466a41eb8 perf: cut face_traced Qdrant I/O — merge trace-count scan (B1) + batch 1000 (B2) 2026-08-16 09:27:46 +08:00
Accusys 6c4c645337 docs: record charade pre_chunks cleanup (9.28M→57K rows, 19G→130M) 2026-08-16 08:49:11 +08:00
Accusys 0533248f2c fix: workspace pre_chunks dedup — stop 19GB re-dispatch bloat (A1) + charade analysis 2026-08-16 08:44:29 +08:00
Accusys 5e6a7b7d51 feat: round output JSON floats to 2dp + unify ensure_ascii for asr/asrx 2026-08-16 06:38:39 +08:00
Accusys 39e9ce4c3b fix: add min_capture_quality to FaceFilterSettings + trace profile fixes
- Add min_capture_quality to FaceFilterSettings (file_profile.rs)
- Fix store_traced_faces.py: load embeddings from Qdrant with_vector=True
- Fix face_tracker.py: force new traces when frame_gap > 30
- Fix backfill_trace_profiles.py: key_frame select=eq(n,N), bbox scaling, best_frame
- Add best_frame to FaceTraceProfile (Rust + Python)
- Fix min_capture_quality persistence in file-profile API
2026-08-13 10:12:21 +08:00
Accusys 71172fa354 fix: separate confidence and captureQuality in face detection output
Apple Vision provides two distinct scores:
- confidence: detection confidence (is this a face?)
- faceCaptureQuality: capture quality (is this face suitable for recognition?)

Previously these were mixed together as 'confidence'. Now both are
stored separately in the output JSON for downstream use.
2026-08-12 11:51:10 +08:00
Accusys e88f066d65 fix: update trigger_processing face defaults to Apple Vision (0.5/1)
Hard-coded 0.75/64 in trigger_processing API was overriding the new
Apple Vision defaults when re-triggering processing. Now uses 0.5/1
consistently.
2026-08-12 09:49:59 +08:00
Accusys 86f1fe8852 fix: restore Apple Vision default detection thresholds (0.5 / 1px)
job_worker.rs was overriding Apple Vision defaults with 0.75/64 even when
no face_settings were provided, causing fewer faces to be detected.

Now detect all faces with Vision defaults (confidence 0.5, min_size 1px);
filter later for display via face_filter settings.
2026-08-12 09:16:30 +08:00
Accusys 2e4559715b fix: tkg face_track drift — trace stability check + repair script
Part B (source fix): Enhanced TKG build Qdrant readiness check in
job_worker.rs. Previously only checked point count >= expected_faces,
which could fire before short traces finished uploading. Now verifies
trace_id stability: two consecutive scroll checks (2s apart) with same
unique trace count before proceeding.

Part A (repair): New scripts/repair_tkg_face_tracks.py reconciles Qdrant
_faces traces with PG tkg_nodes face_track rows, inserts missing ones.
Fixed 233 missing traces in 44c37c (1197 → 1430).
2026-08-12 06:21:18 +08:00
Accusys c1e158a368 fix: trace-profile API SQL errors (missing FROM alias + null decoding)
Two pre-existing bugs broke rename/get operations:

1. schema.rs: DO UPDATE referenced 'tp' alias from LEFT JOIN which is
   invisible in ON CONFLICT scope → 'missing FROM-clause entry for table tp'
   Fix: use {tp_table}.column instead of tp.column

2. profile.rs: SELECT tp.properties / tn.properties can be NULL when no
   trace_profile row exists but decoder expected non-optional Value
   → 'unexpected null; try decoding as an Option'
   Fix: decode as Option<serde_json::Value> and handle None in merge logic
2026-08-12 05:51:12 +08:00
Accusys 2b1af42d06 fix: keep all traces in face clustering (remove min_faces=4 cutoff)
Large files (>1000 traces) used min_faces_per_trace=4, silently dropping
short traces (<=3 face points) from dedup. For 44c37c this excluded
484/1430 traces (34%) — walk-ons and passers-by never got a person label.

Now use min_faces=1 constant; noise is handled by the confidence>=0.5
filter in cluster_by_trace instead of dropping short appearances.

Result on 44c37c: 1430/1430 traces clustered, 21717/21717 faces assigned,
clusters 104 -> 203.
2026-08-12 05:19:54 +08:00
Accusys 258f8c4e96 fix: face clustering speaker mapping + representative face_id
- auto_bind_speakers: remove dead DB writes to nonexistent talents table,
  output speaker_person_mapping metadata into face_cluster.json instead
- fix representative_face.face_id to use face_idx (was frame_idx twice,
  causing duplicate face_ids for multi-face frames)
- fix asrx segment field names (start_time/end_time) and pass correct
  asrx path (ASRX_JSON_PATH was stale after UUID reassignment)
2026-08-12 05:04:48 +08:00
Accusys 59ca6cdf83 feat: add regenerate trace thumbnail endpoint with bbox clamping
- validator::clamp_crop: clamp crop rect to frame dims (fixes OOB shift)
- tkg.rs: use clamp_crop in key_face crop paths (root-cause fix)
- trace_agent_api: POST /api/v1/file/:file_uuid/trace/:trace_id/regenerate-thumbnail
- docs: 26_trace_thumbnail_regenerate.md for Studio team
2026-08-12 03:04:19 +08:00
Accusys aa28bf93fb fix: resolve merge silent failure by fixing upsert_trace_profile SQL and backfilling data
- Fixed upsert_trace_profile() SQL: changed trace_profiles.xxx to tp.xxx in ON CONFLICT DO UPDATE
  to fix invalid reference to FROM-clause entry error
- Fixed cluster_agent.rs error handling: replaced 'let _ =' with proper error logging
- Created migration script to backfill trace_profiles from tkg_nodes for existing files
- Migration successfully inserted 98 missing trace_profiles records
- Verified merge now works correctly: traces_merged > 0 instead of silent no-op

This fixes both the rename 500 error and the merge silent failure, as they share
the same root cause in upsert_trace_profile() SQL.
2026-08-10 01:42:34 +08:00
Accusys 65da4b451a fix: resolve trace-profile UPSERT SQL error and face-filter route syntax
- Fixed upsert_trace_profile() SQL: replaced scalar subqueries with LEFT JOIN
  to properly reference trace_profiles table in backfill logic
- Fixed face_filter routes: changed {file_uuid} to :file_uuid syntax for
  axum 0.7.9 compatibility
- Both fixes resolve HTTP 500 errors in rename and 404 errors in face filter
- Verified both APIs working correctly with test requests
2026-08-10 00:04:15 +08:00
Accusys d6f45683a0 fix: resolve trace-profile UPSERT SQL error and face-filter route syntax
- Fixed upsert_trace_profile() SQL: replaced scalar subqueries with LEFT JOIN
  to properly reference trace_profiles table in backfill logic
- Fixed face_filter routes: changed {file_uuid} to :file_uuid syntax for
  axum 0.7.9 compatibility
- Both fixes resolve HTTP 500 errors in rename and 404 errors in face filter
2026-08-09 23:41:11 +08:00
Accusys a3eba898e2 fix: update face filter API routes to avoid conflicts with identity_api
Changed routes to use /face-filter/ prefix to avoid conflicts:
- /api/v1/file/{uuid}/face-filter/faces
- /api/v1/file/{uuid}/face-filter/{faceId}/report
- /api/v1/file/{uuid}/face-filter/apply
- /api/v1/file/{uuid}/face-filter/stats
- /api/v1/file/{uuid}/face-filter/rules
2026-08-09 22:34:12 +08:00
Accusys 56ce009d84 docs: add hybrid mode implementation guide for Studio team
- Comprehensive guide for implementing hybrid filtering mode
- Includes architecture design with data layering
- Complete TypeScript code examples for all components
- Performance optimization strategies (LRU cache, lazy loading, virtual scroll)
- Best practices and common pitfalls to avoid
- Extension suggestions for future features

This document enables Studio team to implement the hybrid mode
efficiently with clear guidelines and examples.
2026-08-09 19:53:32 +08:00
Accusys 4fc7d0cf6d docs: add Studio team face filter usage guide
- Comprehensive API usage guide for Studio team
- Includes all 6 API endpoints with examples
- Complete TypeScript code examples
- Filtering strategies and best practices
- Performance optimization recommendations
- Based on FaceNet analysis results from WD and KOBA videos

This document enables Studio team to integrate face filtering
functionality efficiently.
2026-08-09 19:27:35 +08:00
Accusys dfa515f249 feat: add bbox_size field for frontend filtering
- Database: Added bbox_size column (min(width, height)) to face_filter_features
- API: Updated all endpoints to include bbox_size in responses
- Documentation: Added bbox_size explanation and frontend filtering examples
- Maintains current Swift implementation calculation method
- Enables efficient frontend filtering without backend threshold

This allows the frontend to do real-time filtering using bbox_size
while the backend pre-computes and stores the value.
2026-08-09 19:05:09 +08:00
Accusys 9b6750b85e feat: implement face filter API for GUI filtering mechanism
- Database schema: face_filter_features and filter_rules tables
- Core engine: FilterEngine with 4 filter rules (landmark, mediapipe, embedding, temporal)
- API endpoints:
  - GET /faces - Get faces with filtering
  - GET /face/{id}/filter-report - Get filter report for single face
  - POST /faces/filter - Apply filter rules
  - GET /filter-stats - Get filter statistics
  - GET/POST /filter-rules - Manage filter rules
- API documentation for Studio team with examples
- Based on FaceNet analysis results from WD and KOBA videos
2026-08-09 17:11:07 +08:00
Accusys 575623c765 docs: add cross-video FaceNet analysis report (WD vs KOBA)
- Completed FaceNet experiments on KOBA video (120 samples)
- Cross-video analysis confirms:
  - Face size impact on stability is CONSISTENT (Large > Medium > Small)
  - Bbox quality is CONSISTENT (Apple Vision ≈ MediaPipe)
  - Recognition accuracy depends on video content
- Key recommendations:
  - Minimum face size: 80px
  - Bbox strategy: Apple Vision (default) or MediaPipe (efficient)
  - Quality metric: Minimum similarity > 0.70
- Based on 240 total samples across 2 videos
2026-08-09 15:57:10 +08:00
Accusys 1f71ab4e14 docs: add FaceNet retest analysis report
- Completed 3 experiments using real FaceNet model (Inception ResNet V1)
- Key findings:
  - Large faces (>150px) have highest stability (0.9995)
  - Apple Vision and MediaPipe bboxes produce identical quality (0.899)
  - Face size affects recognition accuracy lower bound (0.760 vs 0.648)
- Recommendations:
  - Minimum face size: 80px
  - Ideal face size: >150px
  - Both AV and MP bboxes are acceptable
- Included detailed comparison with simplified model results
2026-08-09 14:43:33 +08:00
Accusys 61b774ab0b docs: add embedding vs face size analysis report
- Completed 3 experiments on WD video with 120 samples
- Key findings:
  - Apple Vision bbox produces higher quality embeddings (0.841 vs 0.748)
  - MediaPipe bbox is more precise but lower quality
  - Recommendation: Use Apple Vision bbox for embedding calculation
- Included detailed methodology, results, and recommendations
- Suggested bbox selection strategy and size filtering thresholds
2026-08-09 14:25:44 +08:00
Accusys 496895422f docs: add MediaPipe threshold POC report
- Tested confidence thresholds: 0.1, 0.2, 0.3, 0.4, 0.5
- Key finding: 0.3 is optimal threshold
  - Zero false positives (correctly rejects frames 671, 1116)
  - Same detection rate as 0.5 (100%)
  - More permissive than 0.5, may detect more faces in other videos
- Recommendation: Use 0.3 as default min_confidence for MediaPipe
- Updated dual-source filtering strategy:
  - Apple Vision: primary detector (min_confidence=0.5, min_size=1)
  - MediaPipe: verifier (min_confidence=0.3)
2026-08-09 13:36:51 +08:00
Accusys e1eae6a3d9 test: MediaPipe 1.0.0 vs 0.10.35 comparison results
- Upgraded MediaPipe from 0.10.35 to 1.0.0
- Re-ran same frame comparison experiment
- Key finding: MediaPipe 1.0.0 and 0.10.35 have identical performance
- Both versions: 2.5% recall, 100% precision (zero false positives)
- Apple Vision: 96.1% recall, 0% precision (3 false positives)
- Conclusion: MediaPipe is very conservative but reliable for false positive rejection
2026-08-09 12:55:49 +08:00
Accusys c7690f43d2 docs: add MediaPipe vs Apple Vision landmark comparison report
- Parallel detection on same frames (0, 3, 6, 9, 100, 200, 300, 400, 500, 671, 800, 1000, 1116, 1500)
- MediaPipe saves results as .mp_face.json format
- Key finding: MediaPipe 100% rejects false positives (frames 671, 1116)
- Trade-off: MediaPipe has lower recall (62.5% vs 100% for Apple Vision)
- Recommendation: Consider combining both detectors for best precision/recall balance
2026-08-09 12:42:56 +08:00
Accusys 5045d9f679 docs: update face_settings guide with correct log verification steps
- Updated log paths and examples to match actual implementation
- Added [WORKER] log verification
- Fixed swift_face log path (file_uuid.face_detect.json.log)
2026-08-08 23:24:08 +08:00
Accusys 1571f675a5 fix: worker reads face_settings from job and sets env vars for face processor
- job_worker.rs: Read face_settings from monitor_jobs before processing
- job_worker.rs: Set FACE_MIN_CONFIDENCE and FACE_MIN_SIZE env vars
- job_worker.rs: Restore env vars after processing completes
- Add detailed logging: [WORKER] face_settings and env var changes

This ensures the executor receives the correct face settings from the job.
2026-08-08 23:16:35 +08:00
Accusys 658f509500 fix: pass face_settings to create_monitor_job in register and process endpoints
- files.rs: register_file now converts FaceSettings to json and passes to create_monitor_job
- processing.rs: ProcessRequest now includes face_settings field
- processing.rs: trigger_processing now passes face_settings to create_monitor_job and updates existing jobs
- docs: updated API examples to use correct endpoints (/api/v1/files/register and /api/v1/files/:uuid/process)
2026-08-08 22:16:06 +08:00
Accusys d5c7fd91d9 docs: add face_settings studio guide for Studio team reference
- Complete guide for FACE_MIN_CONFIDENCE and FACE_MIN_SIZE configuration
- Includes environment variable setup (shell export + launchd plist)
- API parameter examples with curl commands
- Log verification steps for all three layers (Rust/Python/Swift)
- Recommended values for different scenarios
- Database schema documentation
- FAQ section for common issues
2026-08-08 21:55:25 +08:00
Accusys 8d83d9f217 fix: replace dev schema defaults with public
- schema.rs: Change DATABASE_SCHEMA default from 'dev' to 'public'
- rule2_ingest.rs, files.rs, tools.rs, scan.rs: Same schema default fix
- files.rs, watcher.rs, processing.rs: Change output_dev to output
- identities.rs: Change API schema parameter default from 'dev' to 'public'
- postgres_db.rs: Add face_settings column to SELECT query (fix ColumnIndexOutOfBounds panic)

This fixes worker not processing jobs due to missing dev schema.
2026-08-08 17:35:23 +08:00
Accusys 8dada662e8 fix: add parameter logging for face detection settings
- swift_face.swift: Log MIN_CONFIDENCE and MIN_SIZE at startup
- face_processor.py: Log settings passed to swift_face subprocess
- executor.rs: Log face settings being passed to Python subprocesses (4 run methods)
- Enables debugging of face detection parameter chain

Test results:
- FACE_MIN_CONFIDENCE=0.5, FACE_MIN_SIZE=1 → 392 faces (195 frames with 2 faces)
- SwiftFace log shows: MIN_CONFIDENCE=0.5, MIN_SIZE=1
- face_processor.py log shows: Settings passed to swift_face: FACE_MIN_CONFIDENCE=0.5, FACE_MIN_SIZE=1
2026-08-08 16:10:47 +08:00
Accusys a06973484b fix: pass FACE_MIN_CONFIDENCE and FACE_MIN_SIZE env vars to swift_face subprocess
- executor.rs: Add cmd.env() for FACE_MIN_CONFIDENCE and FACE_MIN_SIZE in all 4 run methods
- face_processor.py: Pass os.environ to subprocess.Popen to inherit env vars
- Fixes multi-face detection issue where second face was being filtered out
- Tested: CONFIDENCE=0.5 preserves both faces (392 total), CONFIDENCE=0.75 filters second face (196 total), SIZE=100 filters small faces (201 total)
2026-08-08 15:41:26 +08:00
Accusys 256e872fd9 fix: swift_face.swift reads MIN_CONFIDENCE and MIN_SIZE from env vars
- FACE_MIN_CONFIDENCE env var (default 0.75)
- FACE_MIN_SIZE env var (default 64)
- Allows per-file threshold configuration via environment
2026-08-08 04:19:45 +08:00
Accusys 606f4ce5be feat: add per-file face_settings (min_confidence, min_size) support
- DB: Added face_settings jsonb column to monitor_jobs
- API: RegisterFileRequest accepts face_settings
- DB: create_monitor_job accepts and stores face_settings
- MonitorJob struct includes face_settings field
- Swift face processor will read from FACE_MIN_CONFIDENCE and FACE_MIN_SIZE env vars
2026-08-08 04:17:05 +08:00
Accusys c184711bfc fix: thumbnail cache headers - no-cache + ETag for browser revalidation
- Changed Cache-Control from 'public, max-age=86400' to 'no-cache, must-revalidate'
- Added ETag header (sha256 hash of image bytes)
- Browser will revalidate on each request
- If file unchanged → 304 Not Modified (save bandwidth)
- If file changed → 200 with new image
- Applied to all thumbnail endpoints (trace, face, chunk, live extraction)
2026-08-08 02:13:14 +08:00
Accusys 1d3638649b fix: trace-thumbnail cache-control changed to no-cache for testing
- Changed from 'public, max-age=86400' to 'no-cache'
- Allows immediate verification of rebuilt key_face.jpg files
- Can be changed back to max-age=300 after verification
2026-08-07 19:28:50 +08:00
Accusys 9244dbc853 fix: rebuild key_face.jpg for KOBA file with VFR-correct frames
- Force rebuilt all 37 traces for file 5e207a246fd6a2a65ee0a267440465ee
- Used select=eq(n\,frame) for VFR compatibility
- Each trace now uses best face (highest confidence) frame
2026-08-07 16:46:22 +08:00
Accusys ca8b910d59 fix: schema.rs COALESCE加固 + rebuild_trace_thumbs tool
- schema.rs: ON CONFLICT 加入 COALESCE 避免 edge case 把回填值打回 NULL
- rebuild_trace_thumbs: 從 Qdrant _faces 找 best face 重建 key_face.jpg
- 已完成 61/10184 traces(工具運作中,大檔案需較長時間)
2026-08-07 15:55:30 +08:00
Accusys b52777ac03 feat: add backfill_trace_profiles tool + backfill 8250 traces avg_confidence
- Created src/bin/backfill_trace_profiles.rs
- Queries Qdrant _faces once per file (optimized)
- Calculates avg confidence per trace
- Updates trace_profiles.avg_confidence and tkg_nodes.properties
- Backfilled 8250/9877 NULL traces (remaining 102 are edge cases without Qdrant data)
2026-08-07 14:26:39 +08:00
Accusys cd8df324be fix: tkg.rs avg_confidence moved before props construction + schema.rs ON CONFLICT backfill derived fields
- tkg.rs: avg_confidence calculation moved to line 1207 (before props json)
- tkg.rs: Added 'avg_confidence' to props json (round4)
- schema.rs: ON CONFLICT DO UPDATE expanded to backfill start_frame, end_frame,
  frame_count, key_frame, key_face, avg_confidence from tkg_nodes.properties

This fixes trace_profiles.avg_confidence always being NULL, and enables
automatic self-healing when upsert_trace_profile is called from any caller.
2026-08-07 14:04:54 +08:00
Accusys 64f5e3f543 feat: add request logging middleware for all API calls
- Added request_logger middleware in middleware.rs
- Logs every API request with method, path, and query string
- Logs every API response with status code and duration
- Skips health checks and static files to reduce noise
- Error responses (4xx/5xx) logged at warn/error level
- Added to server router as global middleware
2026-08-06 09:50:20 +08:00
Accusys 23c6f63742 feat: add face search API at trace level for People page FS filtering
- GET /api/v1/file/:file_uuid/faces/search
- q parameter: trace_id substring, frame fall-through, range overlap, name substring
- binding filter: assigned/unassigned
- min_confidence filter
- Pagination with page/page_size
- Response includes trace_id, file_uuid, file_name, name, start_frame, end_frame, frame_count, thumbnail_url
- SQL-based filtering with indexes on name/file_uuid for performance
2026-08-05 21:40:07 +08:00
Accusys a6d705abf1 fix: VFR frame extraction - use select=eq(n) instead of -ss frame/fps
- tkg.rs key_frame: select=eq(n\,best_frame) instead of -ss frame/fps
- tkg.rs retry: same fix for need_retry block
- tools.rs agent frame: select=eq(n\,frame_number)
- media_api.rs segment video: select=between(n\,sf\,ef-1) for frame mode

VFR videos (r_frame_rate != actual fps) now get correct frames.
CFR videos unaffected: select=eq(n) produces same result as -ss frame/fps.

Fixes: face card / face-detail thumbnail mismatch for VFR files.
2026-08-05 12:36:25 +08:00
Accusys 2117ca60b8 fix: trace thumbnail now uses trace_profile key_face.jpg for consistency
- Thumbnail endpoint was using select_rep_face (blurdetect) which could pick
  a different frame than the trace_profile's key_frame/key_face
- This caused mismatch between Face Detail modal and thumbnail in trace list
- Fix: add Step 1.5 to check trace_profile's key_face.jpg before falling back
  to select_rep_face
- Ensures thumbnail always matches what Face Detail modal shows

Verified: trace_21 thumbnail now matches key_face.jpg (same hash)
2026-08-05 02:42:38 +08:00