> ## Documentation Index
> Fetch the complete documentation index at: https://docs.img-processing.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Image Classification

> Classifies the image giving a list of labels and their probabilities

### Description

The `classify` endpoint allows you to classify an image using a pre-trained model. At the moment,
the only supported model is the [ResNet50](https://keras.io/api/applications/resnet/#resnet50-function) model,
a deep learning model that excels at image classification tasks.

The endpoint will return a list of labels and their probabilities for the image.

<Warning>
  Test images may return accurate results due the `test` watermarks applied to them. If you want to get
  better results, please use live images. If you just want to test this feature, contact support to temporarily
  upgrade your account.
</Warning>

***


## OpenAPI

````yaml openapi.json post /v1/images/{image_id}/classify
openapi: 3.1.0
info:
  title: IMG Processing API
  description: >
    This powerful and flexible API provides a wide range of

    image manipulation and analysis capabilities, allowing developers to
    integrate advanced image processing

    features into their applications with ease.
  version: 1.0.0
servers:
  - url: https://api.img-processing.com
    description: IMG Processing API Server
security:
  - ApiKeyAuth: []
paths:
  /v1/images/{image_id}/classify:
    post:
      tags:
        - Analysis Endpoints
      summary: Image Classification
      description: >-
        The classify endpoint allows you to classify an image using a
        pre-trained model. At the moment, the only supported model is the
        ResNet50 model, a deep learning model that excels at image
        classification tasks.


        The endpoint will return a list of labels and their probabilities for
        the image.
      operationId: classify
      parameters:
        - in: path
          name: image_id
          schema:
            type: string
            description: >-
              The unique identifier of the image. This identifier is used to
              reference the image in subsequent requests.
          required: true
      responses:
        '201':
          description: The API will return the Image object in the response body.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IdentifyResponse'
        '401':
          description: >-
            Error object for unauthorized access. Probably due to missing or
            invalid API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
        '403':
          description: >-
            Error object for forbidden access. Probably due to insufficient
            permissions.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ForbiddenError'
        '422':
          description: Error object for validation errors.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
        '429':
          description: Error object for rate limit exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitError'
        5XX:
          description: Error object for internal server errors.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServerError'
components:
  schemas:
    IdentifyResponse:
      type: object
      properties:
        main_label:
          type: string
          description: >-
            The main label of the image. This is the label with the highest
            probability.
        main_score:
          type: number
          description: >-
            The probability score of the main label. This is a number between 0
            and 1.
        secondary_labels:
          type: array
          items:
            type: object
            properties:
              label:
                type: string
                description: >-
                  The label of the secondary label. This is the label with a
                  lower probability than the main label.
              score:
                type: number
                description: >-
                  The probability score of the secondary label. This is a number
                  between 0 and 1.
            required:
              - label
              - score
          description: >-
            An array of secondary labels with their respective scores. These are
            the labels with lower probabilities than the main label.
      required:
        - main_label
        - main_score
        - secondary_labels
      title: Identify Response
      description: >-
        Response object for image identification. Contains the main label and
        secondary labels with their scores.
      examples:
        - main_label: Tabby
          main_score: 0.4316079616546631
          secondary_labels:
            - label: Tiger Cat
              score: 0.37503865361213684
            - label: Egyptian Cat
              score: 0.124073326587677
            - label: Plastic Bag
              score: 0.007065261714160442
            - label: Lynx
              score: 0.003809159155935049
    UnauthorizedError:
      type: object
      properties:
        type:
          type: string
          description: The type of error
        error:
          type: string
          description: The title of the error
        status:
          type: number
          const: 401
          description: The status of the error
        message:
          type: string
          description: The error message
      required:
        - type
        - error
        - status
        - message
      title: Unauthorized Error
      description: >-
        Error object for unauthorized access. Probably due to missing or invalid
        API key
      examples:
        - type: https://docs.img-processing.com/errors/unauthorized
          error: Unauthorized
          status: 401
          message: API key is required.
    ForbiddenError:
      type: object
      properties:
        type:
          type: string
          description: The type of error
        error:
          type: string
          description: The title of the error
        status:
          type: number
          const: 403
          description: The status of the error
        message:
          type: string
          description: The error message
      required:
        - type
        - error
        - status
        - message
      title: Forbidden Error
      description: >-
        Error object for forbidden access. Probably due to insufficient
        permissions.
      examples:
        - type: https://docs.img-processing.com/errors/forbidden
          error: Forbidden
          status: 403
          message: You are not allowed to access this image.
    ValidationError:
      type: object
      properties:
        type:
          type: string
          description: The type of error
        error:
          type: string
          description: The title of the error
        status:
          type: number
          const: 422
          description: The status of the error
        errors:
          type: array
          items:
            type: string
          description: The validation errors
      required:
        - type
        - error
        - status
        - errors
      title: Validation Error
      description: Error object for validation errors
      examples:
        - type: https://docs.img-processing.com/errors/validation-error
          error: Validation Error
          status: 422
          errors:
            - '{field or param} {error message}'
    RateLimitError:
      type: object
      properties:
        type:
          type: string
          description: The type of error
        error:
          type: string
          description: The title of the error
        status:
          type: number
          const: 429
          description: The status of the error
        message:
          type: string
          description: The error message
      required:
        - type
        - error
        - status
        - message
      title: Rate Limit Error
      description: Error object for rate limit exceeded.
      examples:
        - type: https://docs.img-processing.com/errors/too-many-requests
          error: Too Many Requests
          status: 429
          message: Rate limit exceeded. Try again later.
    ServerError:
      type: object
      properties:
        type:
          type: string
          description: The type of error
        error:
          type: string
          description: The title of the error
        status:
          type: number
          description: The status of the error
        message:
          type: string
          description: The error message
      required:
        - type
        - error
        - status
        - message
      title: Server Error
      description: Error object for internal server errors.
      examples:
        - type: https://docs.img-processing.com/errors/internal-error
          error: Internal Error
          status: 500
          message: >-
            An unexpected error occurred. Please try again later. If the problem
            persists, contact support.
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: API Key for authentication

````