Skip to content
دروس تعليميةمدة القراءة 5 دقيقة

تصنيف الصور باستخدام Potato

أعدّ تصنيف الصور في Potato بعرض الصور عبر instance_display وجمع التسميات بمخططات radio وmultiselect، مع فحوصات الجودة.

Potato Team

عاجلاً أو آجلاً تحتاج معظم مشاريع الرؤية الحاسوبية إلى كمية كبيرة من الصور الموسومة، ولا بد أن يتولى أحد توسيمها. سواء كنت تفرز صور منتجات أو تفحص محتوى أو تصنّف صوراً طبية، يتولى Potato الواجهة لتتفرغ أنت للتسميات. يغطي هذا الدرس الإعدادات الشائعة: التصنيف بتسمية واحدة وبتسميات متعددة، وبنى الفئات المتداخلة، وفحوصات الجودة التي تبقي مهام الصور موثوقة.

اعرض الصورة أولاً ثم اطرح السؤال

التصنيف والرسم عملان مختلفان في Potato، والخلط بينهما هو الخطأ الأول المعتاد. يضع instance_display الصورة على الشاشة، ويطرح annotation_schemes السؤال. أما نوع image_annotation فهو لرسم الصناديق والأقنعة على الصورة، ولذلك لا تستخدمه مهمة التصنيف إطلاقاً.

yaml
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: jsonl

يربط sequential_key_binding التسميات الست بالمفاتيح من 1 إلى 6. في مهمة تتلخص في نظرة ونقرة، تصنع لوحة المفاتيح معظم سرعة الإنجاز.

تعرض الواجهة الصورة وتحتها تسميات الفئات:

واجهة تصنيف الصور مع تسميات الفئات واختصارات لوحة المفاتيحواجهة توسيم الصور تعرض صورة منتج مع تسميات التصنيف واختصارات لوحة المفاتيح

صيغة البيانات

أنشئ data/products.json:

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:

yaml
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 خاصة به، ويجب أن تغطي قائمة الفئات الفرعية جميع الفئات الأم:

yaml
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 في عنصر واجهة واحد بدلاً من مخططين.

فحوصات الجودة إلى جانب التصنيف

yaml
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: على التسمية فتضع النص في مكان لا يراه المُوسِّم.

مثال كامل

yaml
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

نصائح لتوسيم الصور

يختلف اللون والسطوع من شاشة إلى أخرى، لذا تأكد في أي مهمة يهم فيها ذلك من أن المُوسِّمين يعملون على شاشات معايرة بشكل معقول. ضع صوراً نموذجية في إرشاداتك بدلاً من وصف الفئات بالكلمات، فصورة واحدة تحسم خلافات أكثر مما تحسمه فقرة. اكتب ما يجب فعله بالصور الغامضة، لأن الصور الغامضة ستظهر حتماً. واطلب من الفريق بين حين وآخر توسيم الدفعة نفسها ثم قارنوا النتائج، حتى يُكتشف الانحراف مبكراً.

للاطلاع على تفاصيل التنفيذ، راجع وثائق توسيم الصور.

الخطوات التالية


راجع وثائق توسيم الصور الكاملة في توسيم الصور.