refactor: Face Cluster prefer Rust binary, remove global switch

- Remove MOMENTRY_USE_RUST_PROCESSORS from .env
- Face Cluster now tries Rust binary first, falls back to Python
- Appearance and Pose keep using Python (not needed currently)
- Simpler configuration: no global switch needed
This commit is contained in:
Accusys
2026-09-20 20:48:32 +08:00
parent ebee351523
commit d95857dcc7
+10 -7
View File
@@ -3,7 +3,6 @@ use serde::{Deserialize, Serialize};
use std::time::Duration; use std::time::Duration;
use super::executor::PythonExecutor; use super::executor::PythonExecutor;
use crate::core::config::USE_RUST_PROCESSORS;
const FACE_CLUSTER_TIMEOUT: Duration = Duration::from_secs(3600); const FACE_CLUSTER_TIMEOUT: Duration = Duration::from_secs(3600);
@@ -93,11 +92,10 @@ pub async fn process_face_cluster(
); );
} }
// Rust processor path (MOMENTRY_USE_RUST_PROCESSORS=1) // Try Rust binary first (preferred), fallback to Python if unavailable
if *USE_RUST_PROCESSORS {
if let Some(rust_bin) = executor.rust_binary_path("rust_face_cluster") { if let Some(rust_bin) = executor.rust_binary_path("rust_face_cluster") {
tracing::info!("[FACE_CLUSTER] Using Rust binary: {:?}", rust_bin); tracing::info!("[FACE_CLUSTER] Using Rust binary: {:?}", rust_bin);
executor match executor
.run_rust_with_output_idx_and_frames( .run_rust_with_output_idx_and_frames(
&rust_bin, &rust_bin,
&args, &args,
@@ -108,8 +106,8 @@ pub async fn process_face_cluster(
Some(FACE_CLUSTER_TIMEOUT), Some(FACE_CLUSTER_TIMEOUT),
) )
.await .await
.with_context(|| format!("Failed to run Rust binary {:?}", rust_bin))?; {
Ok(_) => {
let json_str = std::fs::read_to_string(output_path) let json_str = std::fs::read_to_string(output_path)
.context("Failed to read FACE_CLUSTER output")?; .context("Failed to read FACE_CLUSTER output")?;
let result: FaceClusterResult = let result: FaceClusterResult =
@@ -121,11 +119,16 @@ pub async fn process_face_cluster(
); );
return Ok(result); return Ok(result);
} }
Err(e) => {
tracing::warn!( tracing::warn!(
"[FACE_CLUSTER] MOMENTRY_USE_RUST_PROCESSORS=1 but rust_face_cluster binary not found, falling back to Python" "[FACE_CLUSTER] Rust binary failed: {}, falling back to Python",
e
); );
} }
}
}
// Fallback to Python script
executor executor
.run_with_output_idx_and_frames( .run_with_output_idx_and_frames(
"fast_face_clustering_processor.py", "fast_face_clustering_processor.py",