Prediction with Image URL

Returns a prediction from an image or multi-label model for the image file specified by its URL.

Request Parameters

Name

Type

Description

Available Version

modelId

string

ID of the model that makes the prediction.

1.0

numResults

int

Number of probabilities to return. Optional. If passed, must be a number greater than zero.

The response is sorted by probability in descending order. For example, if you pass in 3, only the top three label and probability values are returned.

2.0

sampleId

string

String that you can pass in to tag the prediction. Optional. Can be any value, and is returned in the response.

1.0

sampleLocation

string

URL of the image file.

1.0

Keep the following points in mind when sending an image in for prediction:

  • The maximum image file size you can pass to this resource is 5 MB.
  • The supported image file types are PNG, JPG, and JPEG.
  • If you omit the numResults parameter and the modelId specifies a standard classification model, the response returns the top five labels and probabilities.
  • The numResults parameter has no effect on the response from a multi-label model or a detection model. The prediction response from a multi-label model always returns probabilities for all the labels in a model. The prediction response from a detection model always returns probabilities for all objects detected in the image.

Response Body

Name

Type

Description

Available Version

message

string

Error message. Returned only if the status is something other than successful (200).

1.0

object

string

Object returned; in this case, predictresponse.

1.0

probabilities

array

Array of probabilities for the prediction.

1.0

sampleId

string

Value passed in when the prediction call was made. Returned only if the sampleId request parameter is provided.

1.0

status

string

Status of the prediction. Status of 200 means the prediction was successful.

1.0

Probabilities Response Body

Name

Type

Description

Available Version

label

string

Probability label for the input.

1.0

probability

float

Probability value for the input. Values are between 0–1.

1.0

Probabilities from a Multi-Label Model

A multi-label model (modelType is image-multi-label) is designed to return predictions for multiple objects in an image. The response format is the same as a prediction from a model with a modelType of image, however, the probabilities don't add up to one.

For example, if you send an image of a baseball bat and a baseball glove into a sports-related multi-label model, the response might look something like the following JSON. This response shows high probabilities for both the .baseball-bat and the baseball-glove labels.

{
  "probabilities": [
    {
      "label": "baseball-bat",
      "probability": 0.7356758
    },
    {
      "label": "baseball-glove",
      "probability": 0.74909562
    },
    {
      "label": "basketball-hoop",
      "probability": 0.112600096
    },
    {
      "label": "tennis-ball",
      "probability": 0.088070825
    },
    {
      "label": "tennis-racket",
      "probability": 0.0854089
    },
    {
      "label": "tennis-court",
      "probability": 0.0007318517
    }
  ],
  "object": "predictresponse"
}

When a response comes back from a multi-label model, it returns probabilities for all the labels in the model. Multi-label models are available in Einstein Vision API version 2.0 and later.

Rate Limit Headers

Any time you make an API call to the /predict resource, your rate limit information is returned in the header. The rate limit headers specify your prediction usage for the current calendar month only.

X-RateLimit-Limit 2000
X-RateLimit-Remaining 1997
X-RateLimit-Reset 2017-04-01 19:31:42.0

Header

Description

Example

X-RateLimit-Limit

Maximum number of prediction calls available for the current plan month.

2000

X-RateLimit-Remaining

Total number of prediction calls you have left for the current plan month.

1997

X-RateLimit-Reset

Date on which your predictions are next provisioned. Always the first of the month.

2017-04-01 22:07:40.0

Language