Accurately - Run Inference API Guide

Overview

This guide details how to call Accurately Inference API from your web application or service to Accurately. After Model Training has been completed successfully, developers should be able to turn on Start API and obtain an Inference API Key.

Prerequisites

Please obtain an API key from the Model Training portal after enabled Start API in Model Training details page under "Run Inferences".

Integration Guide

1. Running Inference with API Requests

The first step is to choose the model you are going to run. Go to the Model Train and select the model you want to use and copy the API Key. We will use API Key as a model determination and authorization.



Next is API request preparation. To make an API request to Accurately server, the following parameters below need to be added as a request payload.



To perform a request, you are also required to specify Authorization header with API Key.



POST https://accurately-api.datawow.io/inferences

Here is​​ an example to perform a request by using cURL.

curl --location --request POST 'https://accurately-api.datawow.io/inferences' \
     --header 'Authorization: 9xQ7oq925UhLulHgTqnQMw==' \
     --form 'data=@"/Users/user/Images/image.jpg"' \
     --form 'webhook_url="https://postback.url/inference"' \
     --form 'webhook_method="POST"'


2. Receive Inference results from Accurately’s Server via Webhook
Webhook is a subscription that notifies your service via a webhook URL when an Inference has been completed. Rather than requiring you to pull information via API, Accurately sends webhooks to get information on Inference. Notifications are delivered via HTTPS POST (or other method you can configure) in JSON format to the webhook_url configured when you send image to inference. This information can be used to update your service or trigger AI training process.

You should be able to receive the webhook request containing results to your webhook URL after the Inferencing process completed. Here is an example of Response Data.

{
   "id":"62301e2a3b96920001187da4",
   "inferences":[
      {
         "color":"#dbe9b7",
         "confidence":"1",
         "id":"a6af75da-32c4-48f0-bcae-3c53ef6c2b71",
         "name":"foo",
         "shape":{
            "height":"0.30630630254745483",
            "width":"-0.20600003004074097",
            "x":"0.7300000190734863",
            "y":"0.30630630254745483"
         },
         "type":"boundingBox"
      },
      {
         "color":"#dbe9b7",
         "confidence":"1",
         "id":"a6af75da-32c4-48f0-bcae-3c53ef6c2b71",
         "name":"foo",
         "shape":{
            "height":"-0.13513511419296265",
            "width":"-0.7720000296831131",
            "x":"0.9240000247955322",
            "y":"0.7117117047309875"
         },
         "type":"boundingBox"
      },
      {
         "color":"#dbe9b7",
         "confidence":"2",
         "id":"a6af75da-32c4-48f0-bcae-3c53ef6c2b71",
         "name":"foo",
         "shape":{
            "height":"0.3168168067932129",
            "width":"-0.15399998426437378",
            "x":"0.5699999928474426",
            "y":"0.3168168067932129"
         },
         "type":"boundingBox"
      }
   ]
}


3. Retrieve Inference results from Accurately’s Server
Another way to retrieve Inference results or tracking the progress is to make a GET request to Accurately’s Server by adding the ID as query parameter to the endpoint.

GET https://accurately-api.datawow.io/inferences/:id

Here is​​ an example of request by using cURL and response

curl --location --request GET 'https://accurately-api.datawow.io/inferences/621727a28dce0700012d81cf' \
       --header 'Authorization: dEpdxIXmGNuS18VIWK5wjA=='


response.data.attributes



response.data.attributes.inferences


{
    "data": {
        "id": "621727a28dce0700012d81cf",
        "type": "inference_model_train",
        "attributes": {
            "status": "complete",
            "file_name": "image.jpg",
            "data": "https://image.url",
            "inferences": [
                {
                    "color": "#dbe9b7",
                    "name": "foo",
                    "id": "a6af75da-32c4-48f0-bcae-3c53ef6c2b71",
                    "shape": {
                        "x": 0.7300000190734863,
                        "y": 0.30630630254745483,
                        "width": -0.20600003004074097,
                        "height": 0.30630630254745483
                    },
                    "type": "boundingBox",
                    "confidence": 1
                },
                ....
            ],
            "metadata": {
                "width": 500,
                "height": 333,
                "file_size": 18862
            }
        }
    }
}
บทความนี้เป็นประโยชน์หรือไม่?
ยกเลิก
ขอบคุณ!