Files
momentry_core/docs/YOLO_RESUME_INTEGRATION.md
accusys 383201cacd feat: Initial v0.9 release with API Key authentication
## v0.9.20260325_144654

### Features
- API Key Authentication System
- Job Worker System
- V2 Backup Versioning

### Bug Fixes
- get_processor_results_by_job column mapping

Co-authored-by: OpenCode
2026-03-25 14:53:41 +08:00

2.9 KiB

YOLO Resume 功能整合規劃

現有資源

1. video_yolo_player 專案

位置: /Users/accusys/video_yolo_player/video_yolo_object_prescan.py

功能:

  • Ctrl+C 暫停並保存進度
  • 自動從上一次繼續 (自動偵測 last_processed_frame)
  • 可配置自動保存間隔 (預設 30 秒)
  • 完整 metadata 追蹤 (處理時間、檢測數量等)
  • 互動式詢問是否繼續

2. momentry_core_0.1 專案

位置: /Users/accusys/momentry_core_0.1/scripts/yolo_processor.py

整合狀態

項目 狀態 完成日期
Python script 整合 已完成 2026-03-22
Rust JSON 格式支援 已完成 2026-03-22
Auto-save 功能 (時間) 已完成 2026-03-22
Auto-save 功能 (frame) 已完成 2026-03-22
Ctrl+C 信號處理 已完成 2026-03-22
--force 參數 已完成 2026-03-22
--auto-save-frames 參數 已完成 2026-03-22

已實作功能

momentry_core_0.1/scripts/yolo_processor.py

# 新增功能:
def load_existing_data(output_file)  # 載入現有資料
def save_detection_data(output_file)   # 保存進度
def signal_handler(signum, frame)    # Ctrl+C 處理

# 新增參數:
--auto-save 30        # 自動保存間隔 (秒)
--auto-save-frames 300 # 每 N frames 保存一次 (先到為準)
--force               # 強制從頭開始

輸出格式

{
  "metadata": {
    "video_path": "...",
    "fps": 24.0,
    "total_frames": 1000,
    "status": "in_progress" | "completed" | "interrupted",
    "total_detections": 5000,
    "processing_time": 120.5,
    "auto_save_count": 4,
    "auto_save_interval": 30,
    "auto_save_frames": 300,
    "last_saved_frame": 12500,
    "last_saved_at": "ISO timestamp"
  },
  "frames": {
    "1": { "frame_number": 1, "time_seconds": 0.0, "detections": [...] },
    "2": { "frame_number": 2, "time_seconds": 0.042, "detections": [...] }
  }
}

Auto-save 觸發條件

滿足以下任一條件就會寫入磁碟:

  1. 距離上次儲存已超過 --auto-save 秒數
  2. 距離上次儲存已處理超過 --auto-save-frames 個 frames

使用方式

# 第一次執行 (預設: 30秒 或 300 frames)
python yolo_processor.py video.mp4 output.json --uuid "abc123"

# 中斷後繼續 (自動偵測)
python yolo_processor.py video.mp4 output.json --uuid "abc123"

# 強制從頭開始
python yolo_processor.py video.mp4 output.json --force

# 自訂自動保存間隔
python yolo_processor.py video.mp4 output.json --auto-save 10 --auto-save-frames 100

Rust 端支援

check_json_completeness() 已更新以支援新格式:

  • 讀取 frames dict 的最後一個 key 作為 last_processed_frame
  • 檢查 metadata.status 判斷是否完成

待測試項目

  • 實際執行中斷後繼續
  • 驗證 large video (如 Old_Time_Movie_Show) 繼續處理
  • 驗證 Rust --resume 參數正確傳遞