Skip to content

Latest commit

 

History

History
69 lines (48 loc) · 3.12 KB

File metadata and controls

69 lines (48 loc) · 3.12 KB
title Object classification
description Learn about how to classify objects in your images with imgproxy

Object classification ((pro))

imgproxy Pro can classify objects detected in images, providing detailed information about what the objects are. This feature extends object detection by not only detecting objects but also identifying their specific classes or categories.

:::info Object classification requires object detection to be configured and enabled. Classification is performed on the objects detected by the object detection model. :::

You can use object classification for content moderation, image organization, and automatic tagging. You can fetch the classified objects info via the info handler.

Configuration

:::tip If you're using an imgproxy Pro Docker image with a tag suffixed with -ml, a basic classification model is included. For advanced classification, you may want to configure your own model. :::

You need to define the following config variables to enable object classification:

  • [IMGPROXY_OBJECT_CLASSIFY_NET]: a path to the classification neural network model in ONNX format

  • [IMGPROXY_OBJECT_CLASSIFY_CLASSES]: a path to the class names file

  • [IMGPROXY_OBJECT_CLASSIFY_NET_SIZE]: the size of the neural network input. The width and the heights of the inputs should be the same, so this config value should be a single number. Default: 224

  • [IMGPROXY_OBJECT_CLASSIFY_THRESHOLD]: classifications with confidence below this value will be discarded. Default: 0.5

  • [IMGPROXY_OBJECT_CLASSIFY_NORMALIZATION]: the normalization type to apply to the input image. Possible values:

    • none: no normalization
    • half: normalize to [-0.5, 0.5] range
    • full: normalize to [-1, 1] range
    • imagenet: normalize using ImageNet mean and standard deviation

    Default: none

  • [IMGPROXY_OBJECT_CLASSIFY_LAYOUT]: the data layout of the neural network input. Possible values:

    • nchw: channels first (default)
    • nhwc: channels last

    Default: nchw

Class names file

The class names file is used to map the class indexes from the neural network output to human-readable class names. The path to the class names file should be defined in the IMGPROXY_OBJECT_CLASSIFY_CLASSES config variable.

The class names file should contain one class name per line. The class names should be in the same order as the classes in the neural network output. Example:

person
bicycle
car

Getting classification info

Object classification is available via the info handler using the co (classify objects) endpoint. Fetch classification results by specifying the number of top classes to return:

.../info/co:5/...

Where 5 is the number of top classes to return.

The response is an array of objects, each containing:

  • class_id: The numeric ID of the class
  • name: The class name from the class names file
  • confidence: The confidence score for this classification

See getting info documentation for more details.