Image classification

Image classification is currently in the Preview stage.

This section describes how the image classification feature works in the service.

Use this feature to find out how well an image matches a certain property (for instance, whether the image contains adult-only content). This can reduce the cost of manual moderation because you will be able to ban such images automatically.

The list of properties that the result is returned for depends on the selected model. For example, the quality model, which is used to assess the quality of an image, returns the probabilities for properties such as low, medium, and high. More information about supported models.

Request format

To use this feature, specify CLASSIFICATION in the feature type and pass the name of the model:

{
    "folderId": "b1gvmob95yysaplct532",
    "analyze_specs": [{
        "content": "iVBORw0KGgo...",
        "features": [{
            "type": "CLASSIFICATION",
            "classificationConfig": {
                "model": "quality"
            }
        }]
    }]
}

Only one model can be used within a single analysis feature. If you need to apply more models to your image, pass another object in features:

{
    "folderId": "b1gvmob95yysaplct532",
    "analyze_specs": [{
        "content": "iVBORw0KGgo...",
        "features": [{
            "type": "CLASSIFICATION",
            "classificationConfig": {
                "model": "quality"
            }
        },
        {
            "type": "CLASSIFICATION",
            "classificationConfig": {
                "model": "moderation"
            }
        }]
    }]
}

Service response

The service returns a list of properties in the following format:

{
    "name": "low", // property name
    "probability": 0.71257284 // probability of matching the property
}

The service returns all properties for the selected model, even if the probability for a property is zero.

Sample response:

{
  "results": [{
    "results": [{
      "faceDetection": {
        "properties": [{
            "name": "low",
            "probability": 0.001466292142868043
          },
          {
            "name": "medium",
            "probability": 0.003421348333358767
          },
          {
            "name": "high",
            "probability": 0.99511235952377319
          }
        ]
      }
    }]
  }]
}

What's next