使用 Potato 進行影像分類
在 Potato 中設定影像分類:用 instance_display 展示影像,用 radio 和 multiselect 方案收集標籤,並加上品質檢查。
大多數計算機視覺項目遲早都需要一堆標好的影像,而這些標註總得有人來做。無論是給產品照片分門別類、稽核內容,還是給醫學影像歸類,Potato 負責介面,你只管標籤。本教程涵蓋幾種常見配置:單標籤和多標籤分類、兩級類目結構,以及讓影像任務保持可靠的品質檢查。
先把影像顯示出來,再提問
在 Potato 裡,分類和繪製是兩件不同的事,把它們混為一談是最常見的第一個錯誤。instance_display 負責把圖片顯示到螢幕上,annotation_schemes 負責提問。image_annotation 類型是用來在影像上畫框和掩碼的,分類任務完全用不到它。
annotation_task_name: "Product Image Classification"
task_dir: "."
data_files:
- data/products.json
item_properties:
id_key: product_id
text_key: image_url
instance_display:
fields:
- key: image_url
type: image
label: "Product image"
display_options:
max_width: 600
zoomable: true
annotation_schemes:
- annotation_type: radio
name: category
description: "What type of product is shown?"
labels:
- Electronics
- Clothing
- Home & Garden
- Sports & Outdoors
- Books & Media
- Other
sequential_key_binding: true
output_annotation_dir: annotation_output/
export_annotation_format: jsonlsequential_key_binding 把 1 到 6 這幾個鍵分給六個標籤。一個只需掃一眼、點一下的任務,速度基本就取決於鍵盤。
介面會在影像下方顯示類別標籤:
影像標註介面,顯示一張產品圖片以及分類標籤和鍵盤快捷鍵
資料格式
建立 data/products.json:
{"product_id": "P001", "image_url": "/images/products/laptop.jpg"}
{"product_id": "P002", "image_url": "/images/products/tshirt.jpg"}
{"product_id": "P003", "image_url": "/images/products/garden_tools.jpg"}
{"product_id": "P004", "image_url": "https://example.com/images/basketball.jpg"}影像可以是任務目錄下的本地路徑,也可以是絕對 URL。text_key 指向存放路徑的那個欄位,Potato 會把這個欄位交給顯示元件。
多標籤分類
一張影像同時屬於好幾個類別時,用 multiselect:
annotation_schemes:
- annotation_type: multiselect
name: attributes
description: "Select all attributes that apply to this image"
labels:
- Contains people
- Outdoor scene
- Indoor scene
- Contains text
- Product photo
- Lifestyle photo
- Close-up shot
- Wide angle巢狀類目
Potato 沒有給單選按鈕提供巢狀標籤類型,所以兩級類目就是兩個方案。每個方案都要有自己的 labels,而子類目列表必須覆蓋所有父類目:
annotation_schemes:
- annotation_type: radio
name: main_category
description: "Primary category"
labels:
- Apparel
- Electronics
- Home
- annotation_type: radio
name: subcategory
description: "Subcategory within the primary category"
labels:
- Tops
- Bottoms
- Footwear
- Phones & Tablets
- Computers
- Audio
- Furniture
- Kitchen
- Decor如果第二個列表會變得很長,hierarchical_multiselect 能把它收進一個控制元件,省掉拆成兩個方案。
與分類並行的品質檢查
annotation_schemes:
- annotation_type: radio
name: category
description: "Product category"
labels: [Electronics, Clothing, Home, Other]
- annotation_type: radio
name: image_quality
description: "Is this image suitable for the product catalog?"
labels:
- name: Approved
tooltip: "Clear, well-lit, product is visible"
- name: Needs review
tooltip: "Minor issues but potentially usable"
- name: Rejected
tooltip: "Poor quality, wrong product, or inappropriate"
- annotation_type: multiselect
name: quality_issues
description: "If not approved, what issues are present?"
labels:
- Blurry or out of focus
- Poor lighting
- Wrong product shown
- Watermark or text overlay
- Inappropriate content
- Multiple products in frame針對單個標籤的說明寫在 tooltip 裡,這是標籤會讀取的鍵。寫成標籤上的 description:,這段文字不會出現在標註者能看到的任何地方。
完整示例
annotation_task_name: "E-commerce Image Classification"
task_dir: "."
data_files:
- data/images.json
item_properties:
id_key: sku
text_key: image_path
instance_display:
fields:
- key: image_path
type: image
label: "Product image"
display_options:
max_width: 700
zoomable: true
annotation_schemes:
- annotation_type: radio
name: primary_category
description: "Select the main product category"
labels:
- Electronics
- Clothing & Accessories
- Home & Living
- Beauty & Personal Care
- Sports & Fitness
- Toys & Games
- Other
sequential_key_binding: true
- annotation_type: multiselect
name: image_attributes
description: "Select all that apply"
labels:
- White background
- Lifestyle shot
- Multiple angles
- Model wearing or using
- Size reference included
- Brand visible
label_requirement:
required: false
- annotation_type: radio
name: listing_ready
description: "Is this image ready for the product listing?"
labels:
- Ready to publish
- Needs editing
- Reshoot required
label_requirement:
required: true
annotation_instructions: |
## Image Classification Guidelines
### Category selection
Choose the most specific category that fits the product.
### Image quality
- Ready to publish: clear, professional, meets standards
- Needs editing: good photo that needs cropping or color correction
- Reshoot required: fundamentally unsuitable
output_annotation_dir: annotation_output/
export_annotation_format: jsonl影像標註的幾點經驗
不同顯示器的顏色和亮度不一樣,凡是這一點會影響判斷的任務,都要確認標註者用的螢幕校準得還算靠譜。指南里放示例圖片,別用文字去描述類別;一張圖平息的爭論比一整段話還多。把模糊影像該怎麼處理寫下來,因為模糊影像一定會出現。另外每隔一陣子讓團隊標同一批資料再做對比,標準漂移才能早點發現。
實現細節參見影像標註文件。
下一步
完整的影像標註文件參見影像標註。