# Image Classification with Potato

Source: https://www.potatoannotator.com/blog/image-classification-tutorial

Sooner or later most computer vision projects need a pile of labeled images, and someone has to do the labeling. Whether you're sorting product photos, screening content, or classifying medical scans, Potato handles the interface so you can focus on the labels. This tutorial covers the setups you'll actually use: single-label and multi-label classification, nested category structures, and the quality checks that keep image tasks honest.

## Basic image classification

We'll start with a single-label task.

### Configuration

```yaml
annotation_task_name: "Product Image Classification"

# Image data
data_files:
  - data/products.json

item_properties:
  id_key: product_id
  text_key: image_url

# Classification labels
annotation_schemes:
  - annotation_type: image_annotation
    name: category
    description: "What type of product is shown?"
    labels:
      - Electronics
      - Clothing
      - Home & Garden
      - Sports & Outdoors
      - Books & Media
      - Other
    keyboard_shortcuts:
      Electronics: "1"
      Clothing: "2"
      "Home & Garden": "3"
      "Sports & Outdoors": "4"
      "Books & Media": "5"
      Other: "6"
```

The image classification interface displays the image alongside category labels:

![Image classification interface with category labels and keyboard shortcuts](/images/blog/image-classification.png "The image annotation interface showing a product image with classification labels and keyboard shortcuts")

### Data Format

Create `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"}
```

Images can be local paths or URLs.

## Multi-Label Classification

For images that belong to multiple categories:

```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
    min_selections: 1
    max_selections: 5
```

## Hierarchical Categories

For complex taxonomies, use nested labels:

```yaml
annotation_schemes:
  - annotation_type: radio
    name: main_category
    description: "Primary category"
    labels:
      - Apparel
      - Electronics
      - Home

  - annotation_type: radio
    name: subcategory
    description: "Subcategory"
    conditional:
      depends_on: main_category
      options:
        Apparel:
          - Tops
          - Bottoms
          - Footwear
          - Accessories
        Electronics:
          - Phones
          - Computers
          - Audio
          - Cameras
        Home:
          - Furniture
          - Decor
          - Kitchen
          - Bedding
```

## Image Quality Assessment

Add quality checks alongside classification:

```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
        description: "Clear, well-lit, product is visible"
      - name: Needs review
        description: "Minor issues but potentially usable"
      - name: Rejected
        description: "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
    conditional:
      depends_on: image_quality
      show_when: ["Needs review", "Rejected"]
```

## Advanced Image Settings

For advanced image display customization, configure the `image_annotation` type in your annotation schemes and use CSS or custom styling as needed.

## Complete Example

Here's a production-ready configuration:

```yaml
annotation_task_name: "E-commerce Image Classification"

data_files:
  - data/images.json

item_properties:
  id_key: sku
  text_key: image_path

annotation_schemes:
  - annotation_type: image_annotation
    name: primary_category
    description: "Select the main product category"
    labels:
      - Electronics
      - Clothing & Accessories
      - Home & Living
      - Beauty & Personal Care
      - Sports & Fitness
      - Toys & Games
      - Other
    required: true
    keyboard_shortcuts:
      Electronics: "1"
      "Clothing & Accessories": "2"
      "Home & Living": "3"
      "Beauty & Personal Care": "4"
      "Sports & Fitness": "5"
      "Toys & Games": "6"
      Other: "7"

  - annotation_type: multiselect
    name: image_attributes
    description: "Select all that apply"
    labels:
      - White background
      - Lifestyle shot
      - Multiple angles
      - Model wearing/using
      - Size reference included
      - Brand visible
    required: false

  - annotation_type: radio
    name: listing_ready
    description: "Is this image ready for product listing?"
    labels:
      - Yes - Ready to publish
      - No - Needs editing
      - No - Reshoot required
    required: true

annotation_guidelines:
  title: "Image Classification Guidelines"
  content: |
    ## Category Selection
    Choose the most specific category that fits the product.

    ## Image Quality
    - "Ready to publish": Clear, professional, meets standards
    - "Needs editing": Good photo but needs cropping/color correction
    - "Reshoot required": Fundamentally unsuitable
```

## Tips for image annotation

Color and brightness vary between monitors, so for anything where that matters, make sure annotators are on reasonably calibrated displays. Put example images in your guidelines rather than describing categories in words; one picture settles more arguments than a paragraph. Write down what to do with the ambiguous images, because there will be ambiguous images. And every so often, have the team label the same batch and compare, so drift gets caught early.

For implementation details, see the [image annotation documentation](https://github.com/davidjurgens/potato/blob/master/docs/annotation-types/multimedia/image_annotation.md).

## Next steps

- Learn [bounding box annotation](/blog/bounding-box-annotation) for object detection
- Set up [polygon annotation](/blog/polygon-annotation-guide) for segmentation
- Explore [video annotation](/blog/video-frame-annotation) for temporal tasks

---

*See complete image annotation documentation at [/docs/features/image-annotation](/docs/features/image-annotation).*
