Problem: TKG Builder used deprecated face_detections table
Solution: Migrated to Qdrant _faces collection
Changes:
- Added qdrant_faces module import
- Replaced SQL queries with Qdrant API calls
- Updated build_face_track_nodes to use get_file_faces()
- Updated build_co_occurrence_edges to fetch from Qdrant
- Updated build_speaker_face_edges to calculate trace spans from Qdrant
- Updated build_face_face_edges to find co-occurrences in Python
- Updated build_face_body_edges to fetch face data from Qdrant
- Changed default schema from 'dev' to 'public'
- Changed default output_dir to /Users/accusys/momentry/output
Test results:
- ✅ Successfully created 7 face_track nodes
- ✅ Successfully created 6 face-face co-occurrence edges
- TKG Builder now works with V4.0 architecture
Related: #V4.0-migration
Features:
- New --try-common-languages flag for smart language detection
- Tries en, zh, ja when auto-detection fails or quality is poor
- Quality scoring based on avg_logprob, no_speech_prob, segment count
- Automatically selects best result from all attempts
Quality metrics:
- avg_logprob (higher is better)
- no_speech_prob (lower is better)
- segment count (more is better)
Use case:
- Fixes garbled output from wrong language detection
- Prevents Sinhala character output for Japanese audio
- Provides better language detection for common languages
- Analyze why Whisper detected 'nn' instead of Japanese
- Document root causes: poor audio quality, high noise, model confusion
- Provide diagnostic tool (analyze_whisper_language.py)
- Document 4 solutions: force language, audio preprocessing, model upgrade, parameter tuning
- Recommend integration into Momentry ASR pipeline
- Check if face.json already has trace_id (from Rust face_tracker)
- Skip Python tracking if traces already assigned
- Prevent duplicate tracking and preserve Rust results
- Support both list (FaceResult) and dict formats
- Create store_face_embeddings_to_qdrant.py script
- Add automatic Qdrant storage call after FaceNet completes
- Store 512D embeddings with metadata (frame, confidence, bbox)
- Enables downstream face tracing and clustering
This ensures embeddings are automatically stored in Qdrant without manual intervention.
- Add Swift FaceNet program using FaceNet CoreML model
- Integrate FaceNet into Rust Face processor (auto-generate embeddings)
- Adjust face_filter_defaults: min_confidence=0.5, min_size=1
- Support 512-dim embeddings with ANE acceleration
- Remove Python dependency for face embedding generation
Verified: 210 embeddings generated successfully (99.1% success rate)
Performance: 6.5s for 210 embeddings
Production ready.
- 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).
- Replace fixed 320px downscale with smart resolution handling
- Videos <= 1920px: use native resolution (no downscale)
- Videos > 1920px: downscale to 1920px width
- Improves OCR quality for small text, subtitles, and scene text
Before: All videos scaled to 320px → poor OCR for small text
After: 1080p/720p videos use native resolution, 4K scales to 1920px
Verified: swift_ocr binary builds and runs correctly
- 720x890 video: native resolution (no scaling)
- 1920x1080 video: native resolution (at threshold)
- Detects video width and applies conditional scaling
Note: PaddleOCR fallback (ocr_processor_mps.py) already uses native resolution
- Delete YOLO processor implementation (src/core/processor/yolo.rs)
- Remove YOLO from processing pipeline and worker
- Clean up YOLO-related code across multiple modules
- Add migration 033_remove_yolo.sql
YOLO functionality removed as part of architecture simplification
- Add info log in vlm_summary.rs showing VLM model name
- Add print statements in Python VLM scripts showing model name
- Applies to: trace_vlm_caption.py, scene_vlm_caption.py, interval_vlm_caption.py
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.
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.
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).
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.
- 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)
- 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
- 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)
- ASR script used output_path.replace('.asr.json', '.cut.json') to find CUT file
- Executor passes output path with .tmp suffix (xxx.asr.json.tmp)
- This produced wrong path: xxx.cut.json.tmp (doesn't exist)
- Fix: use --uuid to construct CUT path from output_dir instead
- Also added executor Full command logging for debugging
Fixed IMG_9449 (1).MOV ASR failure: status changed from failed → completed
- trace_vlm_caption.py: use MOMENTRY_LLM_VISION_URL and MOMENTRY_LLM_VISION_MODEL
- scene_vlm_caption.py: use MOMENTRY_LLM_VISION_URL and MOMENTRY_LLM_VISION_MODEL
- Changed from Ollama /api/generate to OpenAI-compatible /v1/chat/completions format
- Added embedding server environment variables
- 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
1. Add Redis PipelineProgress cleanup in unregister_internal
- Deletes progress key when file is unregistered
2. Fix ingestion_complete asr_status query
- Query ASRX first, then ASR
- Filter out NULL values to avoid false negatives
3. Fix TKG 0 nodes/edges support
- TKG is considered done if face traces are complete
- TKG may create 0 nodes/edges for videos with minimal content
4. Add ASRX fallback to ASR segments
- When ASRX has 0 segments but ASR has segments, use ASR segments
- Ensures at least one ASRX output when ASR has content
1. trace_done now checks for 'no_faces' status in face_traced.json
- Videos with no detected faces now complete correctly
- Previously stuck because trace_count=0 returned false
2. ASRX fallback to ASR segments includes start_frame/end_frame
- Added _convert_asr_segments_to_asrx helper function
- TKG can now process fallback segments correctly
This allows processing of:
- Videos with no audio track (ASR: no_audio_track)
- Videos with no faces (face_traced.json: no_faces)
When ASRX processing fails (error or exception), it now falls back to
ASR segments instead of returning silent_audio with 0 segments.
This ensures asrx_segments >= asr_segments always, fixing the bug where
ASRX would report 0 segments even when ASR detected speech.
- Fix trace_id type mismatch (INT4 vs i64) with explicit ::bigint cast
- Change build_face_track_nodes to use from_pg version
- Add skin_tone_trace_nodes to API response
- Add #[derive(Serialize)] to TkgResult
- Fix Unicode panic in text label truncation
- Add push_existing_embeddings.py script
Fix qdrant_request() to properly handle empty dict {} as body.
Python's 'if body' evaluates to False for empty dict, causing EOF error.
Changed:
- data = json.dumps(body).encode() if body is not None else None
Also cleaned up count_seeds() to use consistent body passing.