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
+14
View File
@@ -0,0 +1,14 @@
{
"pins" : [
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser.git",
"state" : {
"revision" : "6a52f3251125d74daf04fcbd5e6f08a75d074382",
"version" : "1.8.2"
}
}
],
"version" : 2
}
+11
View File
@@ -6,11 +6,22 @@ let package = Package(
platforms: [.macOS(.v12)],
products: [
.executable(name: "swift_scene_detector", targets: ["swift_scene_detector"]),
.executable(name: "swift_face", targets: ["swift_face"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.0"),
],
targets: [
.executableTarget(
name: "swift_scene_detector",
path: "Sources/swift_scene_detector"
),
.executableTarget(
name: "swift_face",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
],
path: "Sources/swift_face"
),
]
)
@@ -170,6 +170,23 @@ struct SwiftFace: ParsableCommand {
}
}
}
// Fallback: Calculate quality from size, confidence, pose if API didn't provide it
if captureQ == 0.0 {
let faceArea = Double(faceW * faceH)
let imgArea = Double(imgW * imgH)
let sizeScore = min(1.0, (faceArea / imgArea) * 4.0) // Normalize, larger = better
let confScore = lmConf // Already 0-1
// Pose score (frontal = 1.0, profile = 0.0)
var poseScore = 1.0
if let yaw = lmObs.yaw?.doubleValue {
poseScore = max(0.0, 1.0 - abs(yaw) / 90.0)
}
// Weighted combination
captureQ = sizeScore * 0.3 + confScore * 0.4 + poseScore * 0.3
}
// Match face observation by bbox to extract faceprint (embedding)
var embedding: [Float]? = nil
@@ -312,6 +329,17 @@ struct SwiftFace: ParsableCommand {
}
}
}
// Fallback: Calculate quality from size and confidence if API didn't provide it
if captureQ == 0.0 {
let faceArea = Double(faceW * faceH)
let imgArea = Double(imgW * imgH)
let sizeScore = min(1.0, (faceArea / imgArea) * 4.0) // Normalize, larger = better
let confScore = Double(faceObs.confidence) // Already 0-1
// Weighted combination (no pose available for unmatched faces)
captureQ = sizeScore * 0.5 + confScore * 0.5
}
var faceData: [String: Any] = [
"bbox": ["x": max(0, faceX), "y": max(0, faceY),