Instance Segmentation

Run inference on instance classification models hosted on Roboflow.

Linux or MacOS

Retrieving JSON predictions for a local file called YOUR_IMAGE.jpg:

base64 YOUR_IMAGE.jpg | curl -d @- \
"https://outline.roboflow.com/your-model/42?api_key=YOUR_KEY"

Inferring on an image hosted elsewhere on the web via its URL (don't forget to URL encode it):

curl -X POST "https://outline.roboflow.com/your-model/42?\
api_key=YOUR_KEY&\
image=https%3A%2F%2Fi.imgur.com%2FPEEvqPN.png"

Windows

You will need to install curl for Windows and GNU's base64 tool for Windows. The easiest way to do this is to use the git for Windows installer which also includes the curl and base64 command line tools when you select "Use Git and optional Unix tools from the Command Prompt" during installation.

Then you can use the same commands as above.

Response Object Format

The hosted API inference route returns a JSON object containing an array of predictions. Each prediction has the following properties:

  • x = the horizontal center point of the detected object

  • y = the vertical center point of the detected object

  • width = the width of the bounding box

  • height = the height of the bounding box

  • class = the class label of the detected object

  • confidence = the model's confidence that the detected object has the correct label and position coordinates

  • points =list of points that make of the polygon outline of the object - each item in the list is an object with keys x and y for the horizontal and vertical coordinate of the point respectively

// an example JSON object
{
  "predictions": [
    {
      "x": 179.2,
      "y": 247,
      "width": 231,
      "height": 147,
      "class": "A",
      "confidence": 0.98,
      "points": [
        {
          "x": 134,
          "y": 314
        },
        {
          "x": 116,
          "y": 313
        },
        {
          "x": 103,
          "y": 310.1
        },
        {
          "x": 72.7,
          "y": 282
        },
        {
          "x": 66.8,
          "y": 273
        },
      ]
    }
  ]
}

API Reference

Using the Inference API

POST https://outline.roboflow.com/:datasetSlug/:versionNumber

You can POST a base64 encoded image directly to your model endpoint. Or you can pass a URL as the image parameter in the query string if your image is already hosted elsewhere.

Path Parameters

Name
Type
Description

datasetSlug

string

The url-safe version of the dataset name. You can find it in the web UI by looking at the URL on the main project view or by clicking the "Get curl command" button in the train results section of your dataset version after training your model.

version

number

The version number identifying the version of of your dataset

Query Parameters

Name
Type
Description

image

string

URL of the image to add. Use if your image is hosted elsewhere. (Required when you don't POST a base64 encoded image in the request body.) Note: don't forget to URL-encode it.

overlap

number

The maximum percentage (on a scale of 0-100) that bounding box predictions of the same class are allowed to overlap before being combined into a single box. Default: 30

confidence

number

A threshold for the returned predictions on a scale of 0-100. A lower number will return more predictions. A higher number will return fewer high-certainty predictions. Default: 40

api_key

string

Your API key (obtained via your workspace API settings page)

Request Body

Name
Type
Description

string

A base64 encoded image. (Required when you don't pass an image URL in the query parameters).

{
    "predictions": [{
        "x": 234.0,
        "y": 363.5,
        "width": 160,
        "height": 197,
        "class": "hand",
        "confidence": 0.943
    }, {
        "x": 504.5,
        "y": 363.0,
        "width": 215,
        "height": 172,
        "class": "hand",
        "confidence": 0.917
    }, {
        "x": 1112.5,
        "y": 691.0,
        "width": 139,
        "height": 52,
        "class": "hand",
        "confidence": 0.87
    }, {
        "x": 78.5,
        "y": 700.0,
        "width": 139,
        "height": 34,
        "class": "hand",
        "confidence": 0.404
    }]
}

Last updated