視覺 AI 支援
使用視覺模型為影像和影片標註提供 AI 輔助。
v2.1.0 新增
Potato 使用各種視覺模型為影像和影片標註任務提供 AI 輔助,包括用於目標檢測的 YOLO 和視覺語言模型(VLLM),如 GPT-4o、Claude 和 Ollama 視覺模型。
概述
視覺 AI 支援可實現:
- 目標檢測:使用 YOLO 或 VLLM 自動檢測和定點陣圖像中的物體
- 預標註:自動檢測所有物體供人工稽核
- 分類:對影像或影像中的區域進行分類
- 提示:在不揭示精確位置的情況下提供指導
- 場景檢測:識別影片中的時間片段
- 關鍵幀檢測:在影片中找到重要時刻
- 目標追蹤:跨影片幀追蹤物體
支援的端點
YOLO 端點
最適合使用本地推理進行快速、準確的目標檢測。
yaml
ai_support:
enabled: true
endpoint_type: "yolo"
ai_config:
model: "yolov8m.pt" # or yolov8n, yolov8l, yolov8x, yolo-world
confidence_threshold: 0.5
iou_threshold: 0.45支援的模型:
- YOLOv8(n/s/m/l/x 變體)
- YOLO-World(開放詞彙檢測)
- 自定義訓練模型
Ollama Vision 端點
用於本地視覺語言模型推理。
yaml
ai_support:
enabled: true
endpoint_type: "ollama_vision"
ai_config:
model: "llava:latest" # or llava-llama3, bakllava, llama3.2-vision, qwen2.5-vl
base_url: "http://localhost:11434"
max_tokens: 500
temperature: 0.1支援的模型:
- LLaVA(7B、13B、34B)
- LLaVA-LLaMA3
- BakLLaVA
- Llama 3.2 Vision(11B、90B)
- Qwen2.5-VL
- Moondream
OpenAI Vision 端點
使用 GPT-4o 進行基於雲的視覺分析。
yaml
ai_support:
enabled: true
endpoint_type: "openai_vision"
ai_config:
api_key: "${OPENAI_API_KEY}"
model: "gpt-4o" # or gpt-4o-mini
max_tokens: 1000
detail: "auto" # low, high, or autoAnthropic Vision 端點
用於具有視覺能力的 Claude。
yaml
ai_support:
enabled: true
endpoint_type: "anthropic_vision"
ai_config:
api_key: "${ANTHROPIC_API_KEY}"
model: "claude-sonnet-4-20250514"
max_tokens: 1024端點能力
每個端點有不同的優勢:
| 端點 | 文本生成 | 視覺 | 邊界框輸出 | 關鍵詞 | 理由 |
|---|---|---|---|---|---|
ollama_vision | 是 | 是 | 否 | 否 | 是 |
openai_vision | 是 | 是 | 否 | 否 | 是 |
anthropic_vision | 是 | 是 | 否 | 否 | 是 |
yolo | 否 | 是 | 是 | 否 | 否 |
最佳實踐:
- 精確目標檢測使用
yolo端點 - 帶解釋的影像分類使用如
ollama_vision配合 Qwen-VL 或 LLaVA 等 VLLM - 組合工作流同時配置文本端點和視覺端點
影像標註與 AI
配置帶檢測、預標註、分類和提示功能的 AI 輔助影像標註:
yaml
annotation_schemes:
- annotation_type: image_annotation
name: object_detection
description: "Detect and label objects in the image"
tools:
- bbox
- polygon
labels:
- name: "person"
color: "#FF6B6B"
- name: "car"
color: "#4ECDC4"
- name: "dog"
color: "#45B7D1"
ai_support:
enabled: true
features:
detection: true # "Detect" button - find objects
pre_annotate: true # "Auto" button - detect all
classification: false # "Classify" button - classify region
hint: true # "Hint" button - get guidance
ai_support:
enabled: true
endpoint_type: "yolo"
ai_config:影片標註與 AI
yaml
annotation_schemes:
- annotation_type: video_annotation
name: scene_segmentation
description: "Segment video into scenes"
mode: segment
labels:
- name: "intro"
color: "#4ECDC4"
- name: "action"
color: "#FF6B6B"
- name: "outro"
color: "#45B7D1"
ai_support:
enabled: true
features:
scene_detection: true # Detect scene boundaries
keyframe_detection: false
tracking: false
pre_annotate: true # Auto-segment entire video
hint: true
ai_support:
enabled: true
endpoint_type: "ollama_vision"
ai_config:分離視覺和文本端點
你可以為視覺任務配置單獨的端點,為每種內容類型使用最佳模型:
yaml
ai_support:
enabled: true
endpoint_type: "openai" # For text annotations
ai_config:
api_key: "${OPENAI_API_KEY}"
model: "gpt-4o-mini"
# Separate visual endpoint
visual_endpoint_type: "yolo"
visual_ai_config:
model: "yolov8m.pt"
confidence_threshold: 0.5或將視覺語言模型與文本模型一起使用:
yaml
ai_support:
enabled: true
endpoint_type: "ollama" # Main endpoint for text
visual_endpoint_type: "ollama_vision" # Visual endpoint for images
ai_config:
model: "llama3.2"
include:
all: true
visual_ai_config:
model: "qwen2.5-vl:7b"AI 功能
檢測
查詢匹配已配置標籤的物體並繪製建議邊界框。建議以虛線疊加層形式出現,可以接受或拒絕。
預標註(自動)
自動檢測影像/影片中的所有物體並建立供人工稽核的建議。適用於加速大數據集的標註。
分類
對選定區域或整張影像進行分類。返回帶置信度分數和推理的建議標籤。
提示
提供指導但不揭示精確答案。適用於培訓標註者或希望以 AI 輔助進行人工判斷的場景。
場景檢測(影片)
分析影片幀以識別場景邊界,並建議帶標籤的時間片段。
關鍵幀檢測(影片)
識別影片中具有重要意義的時刻,作為良好的標註點。
目標追蹤(影片)
建議跨幀的物體位置,用於一致的追蹤標註。
使用 AI 建議
- 點選 AI 輔助按鈕(檢測、自動、提示等)
- 等待建議以虛線疊加層形式出現
- 接受建議:雙擊建議疊加層
- 拒絕建議:右鍵點選建議疊加層
- 全部接受:點選工具欄中的"全部接受"
- 清除全部:點選"清除"刪除所有建議
檢測 API 響應格式
json
{
"detections": [
{
"label": "person",
"bbox": {"x": 0.1, "y": 0.2, "width": 0.3, "height": 0.5},
"confidence": 0.95
}
]
}提示格式:
json
{
"hint": "Look for objects in the lower right corner",
"suggestive_choice": "Focus on overlapping regions"
}影片片段格式:
json
{
"segments": [
{
"start_time": 0.0,
"end_time": 5.5,
"suggested_label": "intro",
"confidence": 0.85
}
]
}依賴要求
YOLO 端點
bash
pip install ultralytics opencv-pythonOllama Vision
- 從 ollama.ai 安裝 Ollama
- 拉取視覺模型:
ollama pull llava - 啟動 Ollama 伺服器(預設執行在
http://localhost:11434)
OpenAI/Anthropic Vision
- 在環境或配置中設定 API 金鑰
- 確保你有權訪問支援視覺的模型
故障排除
"未配置視覺 AI 端點"
確保你已:
- 設定
ai_support.enabled: true - 設定支援視覺的有效
endpoint_type(yolo、ollama_vision、openai_vision、anthropic_vision) - 為所選端點安裝了必需的依賴
YOLO 未檢測到預期物體
- 嘗試降低
confidence_threshold - 確保標籤與 YOLO 的類名匹配(或使用 YOLO-World 處理自定義詞彙)
- 檢查模型檔案是否存在且有效
Ollama Vision 錯誤
- 驗證 Ollama 正在執行:
curl http://localhost:11434/api/tags - 確保已拉取視覺模型:
ollama list - 檢查模型是否支援視覺(llava、bakllava、llama3.2-vision 等)
延伸閱讀
有關實現細節,請參閱原始碼文件。