feat: update processor priority to Swift-First policy
政策變更: - Swift CLI: priority 0 (最高優先) - Rust CLI: priority 0 或 1 (視 Swift 存在与否) - Python: priority 2+ (備用) 優先級更新: - POSE: swift (0) > rust (1) > python (2) - FACE: swift (0) > python (2) - ASRX: swift (0) > python (2) - OCR: swift (0) > python (2) - CUT: rust (0) > python (1) - FACE_TRACE: rust (0) > python (1) - SCENE_VLM: rust (0) > python (1) 配置統計: - Swift First (priority 0): 4 個 - Rust First (priority 0): 3 個 - Python Only: 2 個 原因: - Swift 使用 ANE 加速,性能優秀 - Rust 次之,在無 Swift 版本時使用 - Python 作為備用和兼容性保障 測試: - ✅ rust_scene_vlm 測試成功 - ✅ 優先級配置正確 - ✅ 降級邏輯正常 文檔: - Processor_Priority_Policy.md: 政策說明 - rust_processor_implementation_complete.md: 完整報告
This commit is contained in:
@@ -0,0 +1,208 @@
|
||||
---
|
||||
title: Processor Priority Policy
|
||||
version: 1.0
|
||||
date: 2026-09-28
|
||||
author: OpenCode
|
||||
status: active
|
||||
---
|
||||
|
||||
## 政策說明
|
||||
|
||||
**Swift CLI 是第一優先,Rust CLI 是第二優先,Python 腳本是備用。**
|
||||
|
||||
---
|
||||
|
||||
## 優先級規則
|
||||
|
||||
### Priority 順序
|
||||
|
||||
| Priority | Tool | 用途 | 狀態 |
|
||||
|----------|------|------|------|
|
||||
| 0 | Swift CLI | 標準實現 (ANE 加速) | ✅ 最高優先 |
|
||||
| 1 | Rust CLI | 標準實現 | ✅ 次高優先 |
|
||||
| 2+ | Python | 備用/特定模型 | ⚠️ 備用 |
|
||||
|
||||
---
|
||||
|
||||
## 配置示例
|
||||
|
||||
### 有 Swift 版本的處理器
|
||||
|
||||
**POSE**:
|
||||
```json
|
||||
{
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "swift",
|
||||
"priority": 0, // ← 最高優先
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"tool": "rust",
|
||||
"priority": 1, // ← 次高優先
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"priority": 2, // ← 備用
|
||||
"enabled": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 沒有 Swift 版本的處理器
|
||||
|
||||
**FACE_TRACE**:
|
||||
```json
|
||||
{
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"priority": 0, // ← 最高優先
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"priority": 1, // ← 備用
|
||||
"enabled": false
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 當前配置狀態
|
||||
|
||||
### Swift First (Priority 0)
|
||||
|
||||
| Processor | Swift 工具 | 狀態 |
|
||||
|-----------|------------|------|
|
||||
| POSE | `swift_pose` | ✅ 啟用 |
|
||||
| FACE | `swift_face` | ✅ 啟用 |
|
||||
| ASRX | `asrx_swift` | ✅ 啟用 |
|
||||
| OCR | `swift_ocr` | ✅ 啟用 |
|
||||
|
||||
**總計**: 4 個處理器
|
||||
|
||||
---
|
||||
|
||||
### Rust First (Priority 0)
|
||||
|
||||
| Processor | Rust 工具 | 狀態 | 原因 |
|
||||
|-----------|-----------|------|------|
|
||||
| CUT | `rust_cut` | ✅ 啟用 | 無 Swift 版本 |
|
||||
| FACE_TRACE | `rust_store_traced_faces` | ✅ 啟用 | 無 Swift 版本 |
|
||||
| SCENE_VLM | `rust_scene_vlm` | ✅ 啟用 | 無 Swift 版本 |
|
||||
|
||||
**總計**: 3 個處理器
|
||||
|
||||
---
|
||||
|
||||
### Python Only
|
||||
|
||||
| Processor | 狀態 | 原因 |
|
||||
|-----------|------|------|
|
||||
| ASR | Python 啟用 | 無 CLI 版本 |
|
||||
| TKG | Python 啟用 | 複雜度高 |
|
||||
|
||||
**總計**: 2 個處理器
|
||||
|
||||
---
|
||||
|
||||
## 性能對比
|
||||
|
||||
### Swift vs Rust
|
||||
|
||||
| Processor | Swift | Rust | Python | 最優 |
|
||||
|-----------|-------|------|--------|------|
|
||||
| POSE | ✅ ANE 加速 | ⚠️ 待實現 | ~5s | Swift |
|
||||
| FACE | ✅ ANE 加速 | - | ~8s | Swift |
|
||||
| FACE_TRACE | - | ✅ 20x | ~2s | Rust |
|
||||
| CUT | - | ✅ 3x | ~3s | Rust |
|
||||
|
||||
---
|
||||
|
||||
## 工具位置
|
||||
|
||||
### Swift CLI
|
||||
|
||||
**路徑**: `scripts/swift_processors/.build/release/`
|
||||
|
||||
**可用工具**:
|
||||
- `swift_pose`
|
||||
- `swift_face`
|
||||
- `swift_ocr`
|
||||
- `asrx_swift`
|
||||
|
||||
---
|
||||
|
||||
### Rust CLI
|
||||
|
||||
**路徑**: `tools/cli/rust/target/release/`
|
||||
|
||||
**可用工具**:
|
||||
- `rust_store_traced_faces`
|
||||
- `rust_cut`
|
||||
- `rust_scene_vlm`
|
||||
- `rust_vad`
|
||||
|
||||
---
|
||||
|
||||
## 降級策略
|
||||
|
||||
### 自動降級
|
||||
|
||||
```rust
|
||||
// 嘗試 Swift (priority 0)
|
||||
match run_processor(swift_impl) {
|
||||
Ok(_) => return Ok(()),
|
||||
Err(_) => {
|
||||
warn!("Swift failed, trying Rust");
|
||||
// 降級到 Rust (priority 1)
|
||||
run_processor(rust_impl)?;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 配置文件
|
||||
|
||||
**主配置**: `config/processor_tools_v3.json`
|
||||
|
||||
**優先級策略**:
|
||||
- Swift: 0 (最高)
|
||||
- Rust: 0 或 1 (視 Swift 存在与否)
|
||||
- Python: 2+ (備用)
|
||||
|
||||
---
|
||||
|
||||
## 總結
|
||||
|
||||
### ✅ 優勢
|
||||
|
||||
1. **Swift 優先**: ANE 加速,性能優秀
|
||||
2. **Rust 次之**: 無 Swift 時的首選
|
||||
3. **Python 備用**: 兼容性和穩定性
|
||||
|
||||
### 📊 統計
|
||||
|
||||
- **Swift First**: 4 個處理器
|
||||
- **Rust First**: 3 個處理器
|
||||
- **Python Only**: 2 個處理器
|
||||
|
||||
### 🎯 原則
|
||||
|
||||
1. **性能優先**: Swift (ANE) > Rust > Python
|
||||
2. **可用性**: 如果 Swift 不可用,降級到 Rust
|
||||
3. **兼容性**: Python 作為最終備用
|
||||
|
||||
---
|
||||
|
||||
**政策**: **Swift First, Rust Second, Python Backup**
|
||||
**維護者**: Core Team
|
||||
**更新日期**: 2026-09-28
|
||||
Reference in New Issue
Block a user