General Classification

FREEMIUM
Verified
โœ“
By API 4 AI | Updated 15ๆ—ฅๅ‰ | Visual Recognition
Popularity

8.6 / 10

Latency

694ms

Service Level

100%

Health Check

100%

Followers: 2
Resources:
Product Website
API Creator:
Rapid account: API 4 AI
API 4 AI
api4ai
Log In to Rate API
Rating: 5 - Votes: 1

README

Overview

The service classifies input image and responds with classes and their probabilities.

There are 1000 different classes that are categories from ImageNet.

Endpoints

METHOD URL DESCRIPTION
GET https://general-classification1.p.rapidapi.com/v1/version Get service version.
GET https://general-classification1.p.rapidapi.com/v1/algos Get list of available algorithms.
POST https://general-classification1.p.rapidapi.com/v1/results Perform image analysis and get results.

Get version

Returns an actual version of the service in format vX.Y.Z where X is the version of API.

PROPERTY DESCRIPTION
Endpoint https://general-classification1.p.rapidapi.com/v1/version
Method GET

Examples

Request:

$ curl -X 'GET' 'https://general-classification1.p.rapidapi.com/v1/version'

Response:

"v1.5.0"

Get list of algorithms

Service provides alternative algorithms that may be used for image classification.
The idea behind multiple algorithms is to let client try different algorithms to get the best one that matches clientโ€™s use case.

This section describes endpoint that returns all available algorithms that may be used for image classification as list.

PROPERTY DESCRIPTION
Endpoint https://general-classification1.p.rapidapi.com/v1/algos
Method GET

Examples

Request:

$ curl -X 'GET' 'https://general-classification1.p.rapidapi.com/v1/algos'

Response:

[
  "algo1",
  "algo2",
  "algo3"
]

Analyse image and return results

Performs actual image analysis and responds with results.

PROPERTY DESCRIPTION
Endpoint https://general-classification1.p.rapidapi.com/v1/results
Method POST
Query parameters algo
POST parameters image, url

Query parameter algo is optional and may be used to select one of the algorithms to perform classification.
By default the service uses algo1.

Response schema

For responses with 200 HTTP code the type of response is JSON object with the following schema:

{
  "results": [
    {
      "status": {
        "code": ...,
        "message": ...
      },
      "name": ...,
      "md5": ...,
      "page": ...,
      "width": ...,
      "height": ...,
      "entities": [
        {
          "kind": "classes",
          "name": "general-image-classes",
          "classes": {
            ...
          }
        }
      ]
    }
  ]
}

Primary fields:

Name Type Description
results[].status.code string Status code of image processing: ok or failure.
results[].status.message string Human readable explanation for status of image processing.
results[].name string Original image name passed in request (e.g. my_image.jpg).
results[].md5 string MD5 sum of original image passed in request.
results[].page int Optinal page number (presented for multipage inputs only).
results[].width int Optinal image width (presented for valid inputs only).
results[].height int Optinal image height (presented for valid inputs only).
results[].entities[].classes object Predicted classes and probabilities.

Other fields that are not described above always have the same values.

Probabilities are float values in range from 0.0 to 1.0.

Passing image

Image can be passed by posting regular โ€œmultipart form dataโ€ in two alternative ways:

  • as binary file in image field
  • as URL to some public resource in url field

Image must be a regular JPEG or PNG image (with or without transparency) or PDF file.
Usually such images have extensions: .jpg, .jpeg, .png, .pdf. In case of PDF
each page will be converted to PNG image and processed separately.
The service checks input file by MIME type and accepts the following types:

  • image/jpeg
  • image/png
  • application/pdf

The size of image file must be less than 16Mb.

Examples

Request:

curl -X 'POST' 'https://general-classification1.p.rapidapi.com/v1/results?api_key=...' -F 'image=@image.jpg'

Response:

{
  "results": [
    {
      "status": {
        "code": "ok",
        "message": "Success"
      },
      "name": "image.jpg",
      "md5": "6ea449c4645b8811eef1342040725687",
      "width": 1024,
      "height": 768,
      "entities": [
        {
          "kind": "classes",
          "name": "general-image-classes",
          "classes": {
           "tench": 5.591508625002461e-7,
           "goldfish": 0.000004238243946019793,
           "great white shark": 0.000009770637916517444,
           ...
          }
        }
      ]
    }
  ]
}

Possible errors

The service can not process an image

When client sends an image that can not be processed for some reason(s), the service responds with 200 code and returns JSON object in the same format as the format for successful analysis. In this case, the results[].status.code will have failure value and results[].status.message will contain relevant explanation.

Example of possible reasons for the issue:

  • Unsupported file MIME type
  • Corrupted image
  • File passed as URL is too big or non downloadable

Example response for corrupted image:

{
  "results": [
    {
      "status": {
        "code": "failure",
        "message": "Can not load image."
      },
      "name": "file.jpg",
      "md5": "d41d8cd98f00b204e9800998ecf8427e",
      "entities": []
    }
  ]
}

Request size is too big

Request size is limited by approximately 32Mb.
When client sends request that exceeds this limit, the service responds with 413 code.

The typical reason for exceeding this limit is overly large image.
Taking into account additional HTTP overhead, we strongly recommend to not pass image files of size more than 16Mb.

Example response for too big request:

Error: Request Entity Too Large

Your client issued a request that was too large.

Missing image or url

When client sends a request without an image and url, the service responds with 422 code and returns JSON object.

Example response for request without image or url:

{"detail": "Missing image or url field."}