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
This commit is contained in:
Accusys
2026-10-02 12:24:55 +08:00
parent e987fb8119
commit e0d04e242f
87 changed files with 11668 additions and 302 deletions
+39 -2
View File
@@ -223,13 +223,31 @@ async fn list_traces_sorted(
entry.best_confidence = confidence;
entry.best_point_id = point_id;
entry.best_frame = frame;
entry.best_bbox = payload.get("bbox").cloned();
// 先嘗試從 Qdrant 讀取 bbox
let bbox = payload.get("bbox").cloned();
if bbox.is_some() {
entry.best_bbox = bbox;
} else {
// 如果 Qdrant 沒有,從 trace_profile.json 讀取
if let Some(profile) = read_trace_profile(&file_uuid, trace_id) {
entry.best_bbox = profile.get("best_bbox").cloned();
}
}
}
if capture_quality > entry.best_capture_quality {
entry.best_capture_quality = capture_quality;
entry.best_capture_point_id = point_id;
entry.best_capture_frame = frame;
entry.best_capture_bbox = payload.get("bbox").cloned();
// 先嘗試從 Qdrant 讀取 bbox
let bbox = payload.get("bbox").cloned();
if bbox.is_some() {
entry.best_capture_bbox = bbox;
} else {
// 如果 Qdrant 沒有,從 trace_profile.json 讀取
if let Some(profile) = read_trace_profile(&file_uuid, trace_id) {
entry.best_capture_bbox = profile.get("best_bbox").cloned();
}
}
}
}
@@ -2690,3 +2708,22 @@ fn tkg_snapshot_count(before_snapshot: &serde_json::Value) -> usize {
.map(|a| a.len())
.unwrap_or(0)
}
/// Read trace_profile.json for a given file_uuid and trace_id.
fn read_trace_profile(file_uuid: &str, trace_id: i32) -> Option<serde_json::Value> {
use std::path::PathBuf;
let profile_path: PathBuf = [
crate::core::config::OUTPUT_DIR.as_str(),
file_uuid,
&format!("trace_{}", trace_id),
"trace_profile.json"
].iter().collect();
if let Ok(content) = std::fs::read_to_string(&profile_path) {
if let Ok(profile) = serde_json::from_str::<serde_json::Value>(&content) {
return Some(profile);
}
}
None
}