remove: Portal project (Core Team 不再維護前端)
- 移除 portal/ 目錄 (Vue 3 + Tauri 前端) - 更新 AGENTS.md 移除 Portal 相關說明 - 更新代碼註釋移除 Portal 引用 - 前端開發統一由 Studio Team 負責 參考: docs_v1.0/OPERATIONS/GUI_ARCHITECTURE_REVIEW.md
This commit is contained in:
+105
-27
@@ -226,41 +226,26 @@ let swift_face_path = std::path::Path::new("/Users/accusys/momentry_core/scripts
|
||||
}
|
||||
}
|
||||
|
||||
// Store embeddings to Qdrant after FaceNet completes
|
||||
// Read the JSON (with embeddings from FaceNet)
|
||||
let json_str = std::fs::read_to_string(output_path).context("Failed to read FACE output")?;
|
||||
let mut result: FaceResult = serde_json::from_str(&json_str).context("Failed to parse FACE output")?;
|
||||
result.compute_status();
|
||||
|
||||
// Store embeddings to Qdrant and remove from JSON
|
||||
if let Some(file_uuid) = uuid {
|
||||
tracing::info!("[FACE] Storing embeddings to Qdrant for {}", file_uuid);
|
||||
let store_script = std::path::Path::new("/Users/accusys/momentry_core/scripts/store_face_embeddings_to_qdrant.py");
|
||||
if store_script.exists() {
|
||||
let store_output = tokio::process::Command::new("python3")
|
||||
.arg(store_script)
|
||||
.arg("--file-uuid")
|
||||
.arg(file_uuid)
|
||||
.output()
|
||||
.await;
|
||||
|
||||
match store_output {
|
||||
Ok(output) if output.status.success() => {
|
||||
tracing::info!("[FACE] Embeddings stored to Qdrant successfully");
|
||||
}
|
||||
Ok(output) => {
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
tracing::warn!("[FACE] Embedding storage failed: {}", stderr);
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::warn!("[FACE] Embedding storage error: {}", e);
|
||||
}
|
||||
match store_face_embeddings_to_qdrant(file_uuid, &mut result, output_path).await {
|
||||
Ok(count) => {
|
||||
tracing::info!("[FACE] Stored {} embeddings to Qdrant", count);
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::warn!("[FACE] Failed to store embeddings to Qdrant: {}", e);
|
||||
}
|
||||
} else {
|
||||
tracing::warn!("[FACE] store_face_embeddings_to_qdrant.py not found");
|
||||
}
|
||||
} else {
|
||||
tracing::warn!("[FACE] No UUID provided, skipping Qdrant storage");
|
||||
}
|
||||
|
||||
let json_str = std::fs::read_to_string(output_path).context("Failed to read FACE output")?;
|
||||
let mut result: FaceResult = serde_json::from_str(&json_str).context("Failed to parse FACE output")?;
|
||||
result.compute_status();
|
||||
|
||||
// Execute face tracking
|
||||
tracing::info!("[FACE] Starting face tracking");
|
||||
use crate::core::processor::face_tracker::track_faces;
|
||||
@@ -595,3 +580,96 @@ mod tests {
|
||||
assert_eq!(embedding[0], 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
/// Store face embeddings to Qdrant and remove them from JSON
|
||||
pub async fn store_face_embeddings_to_qdrant(
|
||||
file_uuid: &str,
|
||||
face_result: &mut FaceResult,
|
||||
output_path: &str,
|
||||
) -> Result<usize> {
|
||||
use crate::core::db::qdrant_db::QdrantDb;
|
||||
use uuid::Uuid;
|
||||
|
||||
let qdrant = QdrantDb::new();
|
||||
|
||||
let mut points: Vec<(u64, Vec<f32>, serde_json::Value)> = Vec::new();
|
||||
let fps = face_result.fps;
|
||||
|
||||
// Prepare points with embeddings
|
||||
for frame in &face_result.frames {
|
||||
let frame_num = frame.frame;
|
||||
let timestamp_secs = frame_num as f64 / fps;
|
||||
|
||||
for face in &frame.faces {
|
||||
if let Some(embedding) = &face.embedding {
|
||||
let point_id = Uuid::new_v4().as_u128() as u64;
|
||||
|
||||
let payload = serde_json::json!({
|
||||
"file_uuid": file_uuid,
|
||||
"frame": frame_num,
|
||||
"timestamp_secs": timestamp_secs,
|
||||
"face_id": face.face_id.as_deref().unwrap_or(""),
|
||||
"confidence": face.confidence,
|
||||
"x": face.x,
|
||||
"y": face.y,
|
||||
"width": face.width,
|
||||
"height": face.height,
|
||||
"trace_id": -1i32, // Will be updated by face tracing
|
||||
});
|
||||
|
||||
points.push((point_id, embedding.clone(), payload));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let total_points = points.len();
|
||||
if total_points == 0 {
|
||||
tracing::info!("[FACE] No embeddings to store for {}", file_uuid);
|
||||
return Ok(0);
|
||||
}
|
||||
|
||||
// Delete old points for this file
|
||||
let filter = serde_json::json!({
|
||||
"must": [{
|
||||
"key": "file_uuid",
|
||||
"match": {"value": file_uuid}
|
||||
}]
|
||||
});
|
||||
|
||||
if let Err(e) = qdrant.delete_points_by_filter("_faces", filter).await {
|
||||
tracing::warn!("[FACE] Failed to delete old points: {}", e);
|
||||
} else {
|
||||
tracing::info!("[FACE] Deleted old points for {}", file_uuid);
|
||||
}
|
||||
|
||||
// Upsert new points in batches
|
||||
let batch_size = 100;
|
||||
for (i, chunk) in points.chunks(batch_size).enumerate() {
|
||||
let batch_points: Vec<(u64, &[f32], Option<serde_json::Value>)> = chunk
|
||||
.iter()
|
||||
.map(|(id, vec, payload)| (*id, vec.as_slice(), Some(payload.clone())))
|
||||
.collect();
|
||||
|
||||
qdrant.upsert_vectors_batch("_faces", &batch_points).await
|
||||
.with_context(|| format!("Failed to upsert batch {}", i + 1))?;
|
||||
}
|
||||
|
||||
tracing::info!("[FACE] Stored {} embeddings to Qdrant", total_points);
|
||||
|
||||
// Remove embeddings from in-memory result
|
||||
for frame in &mut face_result.frames {
|
||||
for face in &mut frame.faces {
|
||||
face.embedding = None;
|
||||
}
|
||||
}
|
||||
|
||||
// Save cleaned JSON back
|
||||
let json_str = serde_json::to_string_pretty(&face_result)
|
||||
.context("Failed to serialize cleaned face result")?;
|
||||
std::fs::write(output_path, &json_str)
|
||||
.context("Failed to write cleaned face.json")?;
|
||||
|
||||
tracing::info!("[FACE] Removed embeddings from JSON, saved to {}", output_path);
|
||||
|
||||
Ok(total_points)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user