feat: Swift Face Pose integration + TKG 方案 B

Major Changes:
- swift_face_pose: output pose angles (yaw/pitch/roll) in face.json
- face_processor.py: call swift_face_pose (dual output: face.json + pose.json)
- Face struct: add pose_angle field
- TKG 方案 B: gaze/lip_track nodes from face.json (no face_detections dependency)
- Chunk cleanup: delete old data before rebuild (avoid duplicate key)
- Hand nodes: classify by hand_type + gesture (15 combinations)
- HAND_OBJECT edges: bbox spatial matching (174 matches)

Test Results:
- Blake Jones: 8 faces, pose_angle ✓, 66 nodes, 174 edges
- FilmRiot: 394 faces, pose_angle ✓, 35 nodes, 39 edges
- Left hands: 132, Right hands: 2

Architecture:
- All TKG nodes built from JSON files (face.json, hand.json, yolo.json)
- Swift processors: sample_interval=3 (Face/Pose/Hand sync)
- Cleanup functions: delete_tkg_nodes_by_uuid, delete_tkg_edges_by_uuid
This commit is contained in:
Accusys
2026-06-23 05:47:24 +08:00
parent e1e2da2140
commit 766a1d9a6d
17 changed files with 1108 additions and 47 deletions
+83 -1
View File
@@ -441,6 +441,7 @@ pub enum ProcessorType {
Ocr,
Face,
Pose,
Hand,
Asrx,
Scene,
Story,
@@ -479,6 +480,7 @@ impl ProcessorType {
ProcessorType::Ocr => "ocr",
ProcessorType::Face => "face",
ProcessorType::Pose => "pose",
ProcessorType::Hand => "hand",
ProcessorType::Asrx => "asrx",
ProcessorType::Scene => "scene",
ProcessorType::Story => "story",
@@ -496,6 +498,7 @@ impl ProcessorType {
"ocr" => Some(ProcessorType::Ocr),
"face" => Some(ProcessorType::Face),
"pose" => Some(ProcessorType::Pose),
"hand" => Some(ProcessorType::Hand),
"asrx" => Some(ProcessorType::Asrx),
"scene" => Some(ProcessorType::Scene),
"story" => Some(ProcessorType::Story),
@@ -514,6 +517,7 @@ impl ProcessorType {
ProcessorType::Ocr => 0.8,
ProcessorType::Face => 0.6,
ProcessorType::Pose => 0.4,
ProcessorType::Hand => 0.4,
ProcessorType::Asrx => 0.8,
ProcessorType::Scene => 0.3,
ProcessorType::Story => 0.1,
@@ -525,7 +529,7 @@ impl ProcessorType {
pub fn uses_gpu(&self) -> bool {
match self {
ProcessorType::Yolo | ProcessorType::Face | ProcessorType::Pose => true,
ProcessorType::Yolo | ProcessorType::Face | ProcessorType::Pose | ProcessorType::Hand => true,
ProcessorType::MediaPipe => false,
_ => false,
}
@@ -539,6 +543,7 @@ impl ProcessorType {
ProcessorType::Ocr => 1024,
ProcessorType::Face => 1536,
ProcessorType::Pose => 1024,
ProcessorType::Hand => 1024,
ProcessorType::Asrx => 2048,
ProcessorType::Scene => 512,
ProcessorType::Story => 256,
@@ -556,6 +561,7 @@ impl ProcessorType {
ProcessorType::Ocr => Some("paddleocr"),
ProcessorType::Face => Some("insightface/buffalo_l"),
ProcessorType::Pose => Some("mediapipe/pose"),
ProcessorType::Hand => Some("vision/hand_pose"),
ProcessorType::Asrx => Some("speechbrain/ecapa-tdnn"),
ProcessorType::Scene => Some("places365"),
ProcessorType::Story => None,
@@ -577,6 +583,7 @@ impl ProcessorType {
],
ProcessorType::FiveW1H => vec![ProcessorType::Story],
ProcessorType::Appearance => vec![ProcessorType::Pose],
ProcessorType::Hand => vec![],
ProcessorType::MediaPipe => vec![],
_ => vec![],
}
@@ -591,6 +598,7 @@ impl ProcessorType {
ProcessorType::Ocr,
ProcessorType::Face,
ProcessorType::Pose,
ProcessorType::Hand,
ProcessorType::Appearance,
]
}
@@ -601,6 +609,7 @@ impl ProcessorType {
| ProcessorType::Ocr
| ProcessorType::Face
| ProcessorType::Pose
| ProcessorType::Hand
| ProcessorType::Appearance
| ProcessorType::MediaPipe => PipelineType::Frame,
@@ -3623,6 +3632,79 @@ impl PostgresDb {
}))
}
pub async fn delete_pre_chunks_by_uuid(&self, uuid: &str) -> Result<i64> {
let table = schema::table_name("pre_chunks");
let result = sqlx::query(&format!(
"DELETE FROM {} WHERE file_uuid = $1",
table
))
.bind(uuid)
.execute(&self.pool)
.await?;
Ok(result.rows_affected() as i64)
}
pub async fn delete_frames_by_uuid(&self, uuid: &str) -> Result<i64> {
let table = schema::table_name("frames");
let file_id = self.get_file_id_by_uuid(uuid).await?;
let result = sqlx::query(&format!(
"DELETE FROM {} WHERE file_id = $1",
table
))
.bind(file_id)
.execute(&self.pool)
.await?;
Ok(result.rows_affected() as i64)
}
pub async fn delete_chunks_by_uuid(&self, uuid: &str) -> Result<i64> {
let table = schema::table_name("chunks_rule1");
let result = sqlx::query(&format!(
"DELETE FROM {} WHERE file_uuid = $1",
table
))
.bind(uuid)
.execute(&self.pool)
.await?;
Ok(result.rows_affected() as i64)
}
pub async fn delete_tkg_nodes_by_uuid(&self, uuid: &str) -> Result<i64> {
let table = schema::table_name("tkg_nodes");
let result = sqlx::query(&format!(
"DELETE FROM {} WHERE file_uuid = $1",
table
))
.bind(uuid)
.execute(&self.pool)
.await?;
Ok(result.rows_affected() as i64)
}
pub async fn delete_tkg_edges_by_uuid(&self, uuid: &str) -> Result<i64> {
let table = schema::table_name("tkg_edges");
let result = sqlx::query(&format!(
"DELETE FROM {} WHERE file_uuid = $1",
table
))
.bind(uuid)
.execute(&self.pool)
.await?;
Ok(result.rows_affected() as i64)
}
async fn get_file_id_by_uuid(&self, uuid: &str) -> Result<i32> {
let table = schema::table_name("videos");
let result: (i32,) = sqlx::query_as(&format!(
"SELECT id FROM {} WHERE file_uuid = $1",
table
))
.bind(uuid)
.fetch_one(&self.pool)
.await?;
Ok(result.0)
}
pub async fn store_pre_chunk(
&self,
uuid: &str,