API DOCUMENTATION

General API

The Chooch API is organized around REST. The API recognizes objects and concepts in videos and images from our pre-trained models.
The API is compatible with livestreams and live tagging.

Image Recognition API

The image recognition API is a straightforward REST API conducting classification and object recognition predictions on images. The image URL is passed as a field to the API and the API returns a JSON based response with relevant predictions.

IMAGE POST

# Image Recognition with Local Image

import requests

import json

url = 'http://api.chooch.ai/predict/image?apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19'

files = {'image': open('local_image.jpg', 'rb')}

response = requests.post(url, files=files)

print(response.content)

var form = new FormData();

form.append("image", "");

var settings = {

"url": "https://api.chooch.ai/predict/image?apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19",

"method": "POST",

"timeout": 0,

"processData": false,

"mimeType": "multipart/form-data",

"contentType": false,

"data": form

};

$.ajax(settings).done(function (response) {

console.log(response);

});


$curl = curl_init();

curl_setopt_array($curl, array(

CURLOPT_URL => "https://api.chooch.ai/predict/image?apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19",

CURLOPT_RETURNTRANSFER => true,

CURLOPT_ENCODING => "",

CURLOPT_MAXREDIRS => 10,

CURLOPT_TIMEOUT => 0,

CURLOPT_FOLLOWLOCATION => false,

CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,

CURLOPT_CUSTOMREQUEST => "POST",

CURLOPT_POSTFIELDS => array('image'=> new CURLFILE('')),

));

$response = curl_exec($curl);

$err = curl_error($curl);

curl_close($curl);

if ($err) {

echo "cURL Error #:" . $err;

} else {

echo $response;

} ?>

curl --location --request POST "https://api.chooch.ai/predict/image?apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19" --form "image=@"

URL POST

# Image Recognition with Image Url

import requests

import json

url = 'http://api.chooch.ai/predict/image?url=https://s3.amazonaws.com/choochdashboard/base_site/ronaldo_suit.jpg&apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19'

response = requests.post(url)

print(response.content)

var form = new FormData();

var settings = {

"url": "https://api.chooch.ai/predict/image?url=https://s3.amazonaws.com/choochdashboard/base_site/ronaldo_suit.jpg&apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19",

"method": "GET",

"timeout": 0,

"headers": {

"Content-Type": "application/json"

},

"processData": false,

"mimeType": "multipart/form-data",

"contentType": false,

"data": form

};

$.ajax(settings).done(function (response) {

console.log(response);

});


$curl = curl_init();

curl_setopt_array($curl, array(

CURLOPT_URL => "https://api.chooch.ai/predict/image?url=https://s3.amazonaws.com/choochdashboard/base_site/ronaldo_suit.jpg&apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19",

CURLOPT_RETURNTRANSFER => true,

CURLOPT_ENCODING => "",

CURLOPT_MAXREDIRS => 10,

CURLOPT_TIMEOUT => 0,

CURLOPT_FOLLOWLOCATION => false,

CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,

CURLOPT_CUSTOMREQUEST => "GET",

CURLOPT_HTTPHEADER => array(

"Content-Type: application/json"

),

));

$response = curl_exec($curl);

$err = curl_error($curl);

curl_close($curl);

if ($err) {

echo "cURL Error #:" . $err;

} else {

echo $response;

} ?>

curl --location --request GET "https://api.chooch.ai/predict/image?url=https://s3.amazonaws.com/choochdashboard/base_site/ronaldo_suit.jpg&apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19" --header "Content-Type: application/json"

API input fields are:

  • url: URL of the image file. In this example it is https://s3.amazonaws.com/choochdashboard/base_site/ronaldo_suit.jpg
  • apikey: API key provided by Chooch. In this example it is 346g5717-1sd3-35h6-9104-b8h5c819dn19

SAMPLE OUTPUT (IMAGE)

The sample JSON response is:


{
  "status": "ok",
  "url": "https://s3.amazonaws.com/choochdashboard/base_site/ronaldo_suit.jpg",
  "predictions": [
    {
      "class_title": "Cristiano Ronaldo",
      "order": "1"
    },
    {
      "class_title": "tom ford style",
      "order": "2"
    },
    {
      "class_title": "double-breasted suit, fashion",
      "order": "3"
    },
    {
      "class_title": "man",
      "order": "6"
    },
    {
      "class_title": "suit",
      "order": "7"
    },
    {
      "class_title": "cartoon, sterling archer",
      "order": "8"
    },
    {
      "class_title": "icon",
      "order": "9"
    },
    {
      "class_title": "man's clothing",
      "order": "10"
    },
    {
      "class_title": "face",
      "order": "11"
    },
    {
      "class_title": "male",
      "order": "12"
    },
    {
      "class_title": "young man",
      "order": "13"
    },
    {
      "class_title": "actor, doer",
      "order": "14"
    },
    {
      "class_title": "tie",
      "order": "15"
    },
    {
      "class_title": "striped tie",
      "order": "16"
    },
    {
      "class_title": "windsor tie",
      "order": "17"
    },
    {
      "class_title": "four-in-hand tie",
      "order": "18"
    },
    {
      "class_title": "cravat",
      "order": "19"
    }
  ],
  "texts": {
    "status": "limited to 15 results",
    "predictions": [
      
    ],
    "summary": [
      
    ]
  },
  "objects": {
    "predictions": [
      {
        "sub_predictions": [
          {
            "class_title": "tom ford style",
            "order": 1
          },
          {
            "class_title": "double breasted suit",
            "order": 2
          },
          {
            "class_title": "brown tie",
            "order": 3
          },
          {
            "class_title": "double-breasted suit, fashion",
            "order": 4
          }
        ],
        "object_title": "man",
        "coordinates": "0,749,64,982"
      },
      {
        "sub_predictions": [
          {
            "class_title": "cartoon, sterling archer",
            "order": 1
          },
          {
            "class_title": "tom ford style",
            "order": 2
          },
          {
            "class_title": "sterling archer",
            "order": 3
          },
          {
            "class_title": "double breasted suit",
            "order": 4
          },
          {
            "class_title": "brown tie",
            "order": 5
          },
          {
            "class_title": "double-breasted suit, fashion",
            "order": 6
          },
          {
            "class_title": "icon",
            "order": 7
          },
          {
            "class_title": "man's clothing",
            "order": 8
          }
        ],
        "object_title": "suit",
        "coordinates": "25,712,305,995"
      },
      {
        "sub_predictions": [
          {
            "class_title": "male",
            "order": 1
          },
          {
            "class_title": "young man",
            "order": 2
          },
          {
            "class_title": "actor, doer",
            "order": 3
          }
        ],
        "object_title": "face",
        "coordinates": "225,504,75,464"
      },
      {
        "sub_predictions": [
          {
            "class_title": "striped tie",
            "order": 1
          },
          {
            "class_title": "windsor tie",
            "order": 2
          },
          {
            "class_title": "four-in-hand tie",
            "order": 3
          },
          {
            "class_title": "cravat",
            "order": 4
          }
        ],
        "object_title": "tie",
        "coordinates": "320,436,523,875"
      }
    ],
    "summary": [
      {
        "count": "1",
        "object_title": "tie"
      },
      {
        "count": "1",
        "object_title": "face"
      },
      {
        "count": "1",
        "object_title": "suit"
      },
      {
        "count": "1",
        "object_title": "man"
      }
    ]
  },
  "faces": {
    "face_count": 1,
    "predictions": [
      {
        "face_name": "Cristiano Ronaldo",
        "coordinates": "248,506,192,450"
      }
    ]
  },
  "predicttype": "dense",
  "fileid": "c2f02758f0dd4b8ab703e26f4d70d7c7"
}                                    

The response fields are:

  • url: URL of the image file posted
  • status: Status of the API request. When successful the status is “ok”. For error messages see last section.
  • predictions: Predictions made on the image. Predictions are provided as a list and have class_title and order fields.class_title is the name of the class predicted, and order is the order of relevancy of the particular class.
  • sub_predictions: Predictions made under dense classification. The image or frame is segmented into parts and classified based on the segments.
  • text_value: Text predictions.
  • face_name: Facial recognition name predictions.
  • face_count: Sum of faces.
  • coordinates: Coordinates of the object based on pixels. The format for the coordinates is X1, X2, Y1, Y2.
  • count: The number of times an object or concept appears in an image or a frame.
  • fileid: Unique File ID created for the image. The File ID is to identify the image for future references.
    In this example it is ec7995bb557d4416ab97b819917fc18c

Video Recognition API

The video recognition API is a REST API indexing videos every second. The API consists of 2 parts: 1) send video and 2) search. The indexing begins by sending the video. After sending the video, the indexed data can be viewed through the search API.

SAMPLE INPUT (VIDEO)

API input fields are:

  • url: URL of the video file. In this example it is https://s3.amazonaws.com/choochvideo/51.mp4
  • apikey: API key provided by Chooch. In this example it is 346g5717-1sd3-35h6-9104-b8h5c819dn19

SAMPLE OUTPUT (VIDEO)

The sample JSON response is:

{
    url: "https://s3.amazonaws.com/choochvideo/51.mp4",
    status: "Success (Video is being indexed)",
    predicttype: "video",
    fileid: "55de9d9ce1e2469da3a420a7b4de9397"
}

The response fields are:

  • url: URL of the video file.
  • status: Status of the API request. When successful the status is “Success (Video is being indexed)”. For errors see last section.
  • predicttype: Predict type is video for videos.
  • fileid: Unique File ID created for the video. The File ID is to identify the indexed video for future reference and searches within the video. In this example it is 55de9d9ce1e2469da3a420a7b4de9397

VIEWING INDEXED VIDEO

After the video is indexed, the indexed data can be viewed through the search API by using the File ID of the video. The following is a sample API request URL for viewing indexed data.

API input fields are:

  • apikey: : API key provided by Chooch. In this example it is 346g5717-1sd3-35h6-9104-b8h5c819dn19
  • fileid: Unique File ID created for the video. The File ID is to identify the indexed video for future reference and searches within the video. In this example it is 55de9d9ce1e2469da3a420a7b4de9397

The sample JSON response is:

{
    status: "ok",
    url: "https://s3.amazonaws.com/choochvideo/51.mp4",
    indexstatus: "Success (Video Has Been Indexed)",
    seconds: [{
        texts: {
            status: "limited to 15 results",
            predictions: [
                {
                    text_value: "sports",
                    coordinates: "556,773,379,422"
                },
                {
                    text_value: "scenter",
                    coordinates: "751,1041,376,432"
                },
                {
                    text_value: "allaccess",
                    coordinates: "631,973,458,507"
                },
                {
                    text_value: "ronald",
                    coordinates: "592,994,519,616"
                },
                {
                    text_value: "in",
                    coordinates: "682,735,614,650"
                },
                {
                    text_value: "china",
                    coordinates: "748,922,616,660"
                }
            ],
            summary: [
                {
                    count: "1",
                    text_value: "allaccess"
                },
                {
                    count: "1",
                    text_value: "sports"
                },
                {
                    count: "1",
                    text_value: "ronald"
                },
                {
                    count: "1",
                    text_value: "china"
                },
                {
                    count: "1",
                    text_value: "in"
                },
                {
                    count: "1",
                    text_value: "scenter"
                }
            ]
        },
        second: 1,
        objects: {
            predictions: [
                {
                    sub_predictions: [ ],
                    object_title: "illustration",
                    coordinates: "211,1138,142,712"
                },
                {
                    sub_predictions: [
                    {
                        class_title: "victory",
                        order: 1
                    },
                    {
                        class_title: "joy",
                        order: 2
                    }
                    ],
                    object_title: "man",
                    coordinates: "190,580,319,712"
                },
                {
                    sub_predictions: [ ],
                    object_title: "face",
                    coordinates: "279,511,325,658"
                },
                {
                    sub_predictions: [ ],
                    object_title: "person",
                    coordinates: "978,1089,571,716"
                },
                {
                    sub_predictions: [ ],
                    object_title: "clothing",
                    coordinates: "971,1097,602,712"
                },
                {
                    sub_predictions: [ ],
                    object_title: "illustration",
                    coordinates: "211,1138,142,712"
                },
                {
                    sub_predictions: [
                        {
                            class_title: "victory",
                            order: 1
                        },
                        {
                            class_title: "joy",
                            order: 2
                        }
                    ],
                    object_title: "man",
                    coordinates: "190,580,319,712"
                },
                {
                    sub_predictions: [ ],
                    object_title: "face",
                    coordinates: "279,511,325,658"
                },
                {
                    sub_predictions: [ ],
                    object_title: "person",
                    coordinates: "978,1089,571,716"
                },
                {
                    sub_predictions: [ ],
                    object_title: "clothing",
                    coordinates: "971,1097,602,712"
                }
            ],
            summary: [
                {
                    count: "2",
                    object_title: "person"
                },
                {
                    count: "2",
                    object_title: "face"
                },
                {
                    count: "2",
                    object_title: "clothing"
                },
                {
                    count: "2",
                    object_title: "illustration"
                },
                {
                    count: "2",
                    object_title: "man"
                }
            ]
        },
        predictions: [
            {
                class_title: "cristiano ronaldo",
                order: "1"
            },
            {
                class_title: "illustration",
                order: "2"
            },
            {
                class_title: "man",
                order: "3"
            },
            {
                class_title: "victory",
                order: "4"
            },
            {
                class_title: "joy",
                order: "5"
            },
            {
                class_title: "face",
                order: "6"
            },
            {
                class_title: "sports",
                order: "7"
            },
            {
                class_title: "scenter",
                order: "8"
            },
            {
                class_title: "allaccess",
                order: "9"
            },
            {
                class_title: "ronald",
                order: "10"
            },
            {
                class_title: "in",
                order: "11"
            },
            {
                class_title: "china",
                order: "12"
            }
        ],
        faces: {
            face_count: 1,
            predictions: [
                {
                    face_name: "Cristiano Ronaldo",
                    coordinates: "212,390,292,472"
                }
            ]
        }
    },
    {
        texts: {
            status: "limited to 15 results",
            predictions: [
            {
                text_value: "scenter",
                coordinates: "712,1023,279,339"
            },
            {
                text_value: "sorts",
                coordinates: "512,745,302,345"
            },
            {
                text_value: "allfaccess",
                coordinates: "583,937,366,417"
            },
            {
                text_value: "onald",
                coordinates: "545,970,428,530"
            },
            {
                text_value: "i",
                coordinates: "626,683,534,572"
            },
            {
                text_value: "china",
                coordinates: "690,906,529,582"
            },
            {
                text_value: "mra",
                coordinates: "1042,1084,568,584"
            },
            {
                text_value: "s",
                coordinates: "957,993,652,671"
            }
            ],
            summary: [
                {
                    count: "1",
                    text_value: "allfaccess"
                },
                {
                    count: "1",
                    text_value: "i"
                },
                {
                    count: "1",
                    text_value: "mra"
                },
                {
                    count: "1",
                    text_value: "s"
                },
                {
                    count: "1",
                    text_value: "china"
                },
                {
                    count: "1",
                    text_value: "sorts"
                },
                {
                    count: "1",
                    text_value: "onald"
                },
                {
                    count: "1",
                    text_value: "scenter"
                }
            ]
        },
        second: 2,
        objects: {
            predictions: [
                {
                    sub_predictions: [
                        {
                            class_title: "maybe olympics",
                            order: 1
                        }
                    ],
                    object_title: "man",
                    coordinates: "78,547,267,712"
                },
                {
                    sub_predictions: [
                        {
                            class_title: "psycho joker",
                            order: 1
                        }
                    ],
                    object_title: "face",
                    coordinates: "241,455,271,582"
                },
                {
                    sub_predictions: [
                        {
                            class_title: "forward",
                            order: 1
                        },
                        {
                            class_title: "back",
                            order: 2
                        }
                    ],
                    object_title: "man",
                    coordinates: "965,1150,467,712"
                },
                {
                    sub_predictions: [ ],
                    object_title: "person",
                    coordinates: "981,1145,459,707"
                },
                {
                    sub_predictions: [ ],
                    object_title: "clothing",
                    coordinates: "987,1150,503,697"
                },
                {
                    sub_predictions: [
                        {
                            class_title: "maybe olympics",
                            order: 1
                        }
                    ],
                    object_title: "man",
                    coordinates: "78,547,267,712"
                },
                {
                    sub_predictions: [
                        {
                            class_title: "psycho joker",
                            order: 1
                        }
                    ],
                    object_title: "face",
                    coordinates: "241,455,271,582"
                },
                {
                    sub_predictions: [
                        {
                            class_title: "forward",
                            order: 1
                        },
                        {
                            class_title: "back",
                            order: 2
                        }
                        ],
                    object_title: "man",
                    coordinates: "965,1150,467,712"
                },
                {
                    sub_predictions: [ ],
                    object_title: "person",
                    coordinates: "981,1145,459,707"
                },
                {
                    sub_predictions: [ ],
                    object_title: "clothing",
                    coordinates: "987,1150,503,697"
                }
            ],
            summary: [
                {
                    count: "4",
                    object_title: "man"
                },
                {
                    count: "2",
                    object_title: "person"
                },
                {
                    count: "2",
                    object_title: "face"
                },
                {
                    count: "2",
                    object_title: "clothing"
                }
            ]
        },
        predictions: [
            {
                class_title: "cristiano ronaldo",
                order: "1"
            },
            {
                class_title: "man - 1",
                order: "2"
            },
            {
                class_title: "maybe olympics",
                order: "3"
            },
            {
                class_title: "face",
                order: "4"
            },
            {
                class_title: "psycho joker",
                order: "5"
            },
            {
                class_title: "man - 2",
                order: "6"
            },
            {
                class_title: "forward",
                order: "7"
            },
            {
                class_title: "back",
                order: "8"
            },
            {
                class_title: "scenter",
                order: "9"
            },
            {
                class_title: "sorts",
                order: "10"
            },
            {
                class_title: "allfaccess",
                order: "11"
            },
            {
                class_title: "onald",
                order: "12"
            },
            {
                class_title: "i",
                order: "13"
            },
            {
                class_title: "china",
                order: "14"
            },
            {
                class_title: "mra",
                order: "15"
            },
            {
                class_title: "s",
                order: "16"
            }
        ],
        faces: {
            face_count: 1,
            predictions: [
                {
                    face_name: "Cristiano Ronaldo",
                    coordinates: "192,342,260,408"
                }
            ]
        }
    },
    ],
    index_status: "Success (Video Has Been Indexed)",
    fileid: "55de9d9ce1e2469da3a420a7b4de9397"
}

The response fields are:

  • url: URL of the video file.
  • status: Status of the API request. When successful the status is “Success (Video is being indexed)”. For errors see last section.
  • predicttype: Predict type is video for videos.
  • sub_predictions: Predictions made under dense classification. The image or frame is segmented into parts and classified based on the segments.
  • face_count: Sum of faces
  • coordinates: Coordinates of the object based on pixels. The format for the coordinates are X1, X2, Y1, Y2.
  • count: The number of times an object or concept appears in an image or a frame.
  • fileid: Unique File ID created for the video. The File ID is to identify the indexed video for future reference and searches within the video. In this example it is 55de9d9ce1e2469da3a420a7b4de9397
  • indexstatus: Status of video index. When complete the status is "Success (Video Has Been Indexed)". For errors see next section.
  • seconds: Each second in the video is indexed. Each item is a second in the video and there are predictions for every second, similar to the image prediction API. Each item has a second and predictions field. Predictions for every second are listed in the predictions field with the class_title and order fields.

    GENERAL STATUS MESSAGES

  • ok
  • Error (Wrong Parameters)
  • Error (Invalid API Key)
  • Error (You Have Reached Your Trial API Call Limit)
  • Error (No File)

    VIDEO INDEX STATUS MESSAGES

  • Waiting to Be Processed
  • In Process Error Occurred (Not Valid Video File)
  • Error Occurred (Reached Your API Call Limit)
  • Success (Video Has Been Indexed)

FTP DROP FUNCTION

The FTP drop function was developed on top of the Chooch API for image and video professionals who want to tag their images and videos autonomously. For every client a personal FTP host is issued together with the API.

  • FTP Host: ftp://52.207.237.100
  • API Key: 6werc42-1675-6553-8105

The FTP drop sends the image to the API. The API predicts the image and places the results in the keywords field of the IPTC metadata file. Once the metadata has been successfully placed into the keywords fields of the IPTC file, it is sent to the destination directed by the user.

Facial Recognition Training on the Chooch Dashboard

Chooch provides a Facial Recognition Perception training platform to train your own face images. Below is a summary on how to train and test a Facial Recognition Perception.

Login to the Chooch Dashboard

https://app.chooch.ai

If you don’t have an account simply sign up.

After logging into the Chooch Dashboard click on the Training tab. The Training options will appear as seen below:

There are 3 options of training on the screen: Facial, Image and Object.

Select “Facial”. The Facial Recognition Perceptions screen will appear as seen below:
The other options will be available soon.

You can create and manage your Facial Recognition Perceptions from this screen.

Let’s create a new perception named “Famous People”. We click on “Create Perception” and type in “Famous People” as seen below:

After the Perception is created the Perception Detail Screen will appear as seen below:

Let’s add a Person to the perception.

As seen below we add “George Clooney” to the perception.

After we add a person the “Person Detail” page will appear. We recommend at least 5 face photos for each person in order to get high quality results. But you can use less photos, minimum one photo is needed.

Let’s add some images to the Person (George Clooney). We can select and upload multiple images as seen below.

Now that we added our images we can test our Perception. Let’s click on back and go to the Perception detail screen.

After we enabled our Perception and added a person we can start testing.

Just click on “Predict via Upload” and select and image. Below we uploaded an image of “George Clooney” that was not in the dataset we uploaded. We got a similarity score of 0.80 which means this person is most likely George Clooney. Anything above 0.70 is considered a hit.
There is also a search function to search people in the Perceptions.

On the Settings tab of the Dashboard you will see your API key. Please refer to the Facial Recognition API documentation on how to predict faces using the Chooch API.

Facial Recognition API

Chooch Face Recognition consists of Perception > People > Images

You can search and tag a face in the Chooch API by feeding the Chooch API a Face Image. Below is a sample post of an image url.

SAMPLE OUTPUT (IMAGE)

https://api.chooch.ai/predict/face?url=https://choochdashboard.s3.amazonaws.com/base_site/1461123713-esq050116cover001s.jpg&person_id_filter=-1&model_id=14&apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19

The fields are:

  • url: This is the image url of the face to be searched.
  • person_id_filter: This field is a filter that is optional to pass. The default -1 which means don’t filter by person. If a valid person_id is passed, Chooch will search only in that given person’s data.
  • model_id: This is the id of the perception that the search will be made on. This field is required.

You can also post an image through the image field. Below are 2 separate sample posts in python.

URL POST

import requests

import json

import time

url = 'https://api.chooch.ai/predict/face?url=https://choochdashboard.s3.amazonaws.com/base_site/1461123713-esq050116cover001s.jpg&person_id_filter=-1&model_id=14&apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19'

response = requests.post(url)

json_data = json.loads(response.content)

print(json_data)

var form = new FormData();

var settings = {

"url": "https://api.chooch.ai/predict/face?url=https://choochdashboard.s3.amazonaws.com/base_site/1461123713-esq050116cover001s.jpg&person_id_filter=-1&model_id=14&apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19",

"method": "POST",

"mimeType": "multipart/form-data",

"contentType": false,

"data": form

};

$.ajax(settings).done(function (response) {

console.log(response);

});


$curl = curl_init();

curl_setopt_array($curl, array(

CURLOPT_URL => "https://api.chooch.ai/predict/face?url=https://choochdashboard.s3.amazonaws.com/base_site/1461123713-esq050116cover001s.jpg&person_id_filter=-1&model_id=14&apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19",

CURLOPT_RETURNTRANSFER => true,

CURLOPT_ENCODING => "",

CURLOPT_MAXREDIRS => 10,

CURLOPT_TIMEOUT => 0,

CURLOPT_FOLLOWLOCATION => false,

CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,

CURLOPT_CUSTOMREQUEST => "POST",

));

$response = curl_exec($curl);

$err = curl_error($curl);

curl_close($curl);

if ($err) {

echo "cURL Error #:" . $err;

} else {

echo $response;

} ?>

curl --location --request POST "https://api.chooch.ai/predict/face?url=https://choochdashboard.s3.amazonaws.com/base_site/1461123713-esq050116cover001s.jpg&person_id_filter=-1&model_id=14&apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19"

IMAGE POST

import requests

import json

import time

url = 'https://api.chooch.ai/predict/face?person_id_filter=7&model_id=5&apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19'

files = {'image': open('local_image.jpg', 'rb')} response = requests.post(url, files=files)

response = requests.post(url)

json_data = json.loads(response.content)

print(json_data)

var form = new FormData();

form.append("image", "");

var settings = {

"url": "https://api.chooch.ai/predict/face?person_id_filter=-1&model_id=14&apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19",

"method": "POST",

"timeout": 0,

"processData": false,

"mimeType": "multipart/form-data",

"contentType": false,

"data": form

};

$.ajax(settings).done(function (response) {

console.log(response);

});


$curl = curl_init();

curl_setopt_array($curl, array(

CURLOPT_URL => "https://api.chooch.ai/predict/face?person_id_filter=-1&model_id=14&apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19",

CURLOPT_RETURNTRANSFER => true,

CURLOPT_ENCODING => "",

CURLOPT_MAXREDIRS => 10,

CURLOPT_TIMEOUT => 0,

CURLOPT_FOLLOWLOCATION => false,

CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,

CURLOPT_CUSTOMREQUEST => "POST",

CURLOPT_POSTFIELDS => array('image'=> new CURLFILE('')),

));

$response = curl_exec($curl);

$err = curl_error($curl);

curl_close($curl);

if ($err) {

echo "cURL Error #:" . $err;

} else {

echo $response;

} ?>

curl --location --request POST "https://api.chooch.ai/predict/face?person_id_filter=-1&model_id=14&apikey=346g5717-1sd3-35h6-9104-b8h5c819dn19" --form "image=@"

JSON RESPONSE

The example JSON response is as below. In this example, we got a hit with a similarity of 0.80 percent. The face_recog_hit is True when we get a hit and False when we don’t.

{
    status:"ok",
    person_id_filter:-1,
    post_type:"face_search",
    face_recog_hit:true,
    faces:[
            {
            person_id:22,
            person_name:"George Clooney",
            coordinates:"1402,158,1657,506",
            similarity:0.80
            }
        ]
}
                                        

CREATE PERSON API COMMAND

You can create a person through the Chooch API. Below is a sample Python based usage of the create_person command.

# Create Person Python Code
import requests

import json

url = 'https://api.chooch.ai/predict/face?person_name=Tom Bill&model_id=5&apikey=cx065e5d-51wc87-9df6-163e-8b65a78k51e3&command=create_person'

response = requests.post(url)

json_data = json.loads(response.content)

print(json_data)

var form = new FormData();

var settings = {

"url": "https://api.chooch.ai/predict/face?person_name=Tom Bill&model_id=5&apikey=cx065e5d-51wc87-9df6-163e-8b65a78k51e3&command=create_person",

"method": "POST",

"processData": false,

"mimeType": "multipart/form-data",

"contentType": false,

"data": form

};

$.ajax(settings).done(function (response) {

console.log(response);

});


$curl = curl_init();

curl_setopt_array($curl, array(

CURLOPT_URL => "https://api.chooch.ai/predict/face?person_name=Tom%20Bill&model_id=5&apikey=cx065e5d-51wc87-9df6-163e-8b65a78k51e3&command=create_person",

CURLOPT_RETURNTRANSFER => true,

CURLOPT_ENCODING => "",

CURLOPT_MAXREDIRS => 10,

CURLOPT_TIMEOUT => 0,

CURLOPT_FOLLOWLOCATION => false,

CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,

CURLOPT_CUSTOMREQUEST => "POST",

));

$response = curl_exec($curl);

$err = curl_error($curl);

curl_close($curl);

if ($err) {

echo "cURL Error #:" . $err;

} else {

echo $response;

} ?>

curl --location --request POST "https://api.chooch.ai/predict/face?person_name=Tom%20Bill&model_id=5&apikey=cx065e5d-51wc87-9df6-163e-8b65a78k51e3&command=create_person"

JSON RESPONE

{
    person_id: 37,
    status: 37,
    status_description: success,
    post_type: create_person
}                                                    

RETURN STATUS VALUES:

  • status > 0 : success, and the return value is the person_id.
  • status = 0 : error has occurred.
  • status = -1 : invalid model id.
  • status = -2 : invalid person name.

INSERT PERSON IMAGE API COMMAND

A face image can be added to an existing person using the person_id. Below is a sample Python based usage of the insert_person_image command.

# Add face image to person with person_id_filter (person_id) Python Code

import requests

import json

url = 'https://api.chooch.ai/predict/face?person_id_filter=37&apikey=cx065e5d-51wc87-9df6-163e-8b65a78k51e3&command=insert_person_image'

files = {'image': open('your_image.jpg', 'rb')}

response = requests.post(url, files=files)

json_data = json.loads(response.content)

print(json_data)

var form = new FormData();

form.append("image", "");

var settings = {

"url": "https://api.chooch.ai/predict/face?person_id_filter=37&apikey=cx065e5d-51wc87-9df6-163e-8b65a78k51e3&command=insert_person_image",

"method": "POST",

"processData": false,

"mimeType": "multipart/form-data",

"contentType": false,

"data": form

};

$.ajax(settings).done(function (response) {

console.log(response);

});


$curl = curl_init();

curl_setopt_array($curl, array(

CURLOPT_URL => "https://api.chooch.ai/predict/face?person_id_filter=37&apikey=cx065e5d-51wc87-9df6-163e-8b65a78k51e3&command=insert_person_image",

CURLOPT_RETURNTRANSFER => true,

CURLOPT_ENCODING => "",

CURLOPT_MAXREDIRS => 10,

CURLOPT_TIMEOUT => 0,

CURLOPT_FOLLOWLOCATION => false,

CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,

CURLOPT_CUSTOMREQUEST => "POST",

CURLOPT_POSTFIELDS => array('image'=> new CURLFILE('')),

));

$response = curl_exec($curl);

$err = curl_error($curl);

curl_close($curl);

if ($err) {

echo "cURL Error #:" . $err;

} else {

echo $response;

} ?>

curl --location --request POST "https://api.chooch.ai/predict/face?person_id_filter=37&apikey=cx065e5d-51wc87-9df6-163e-8b65a78k51e3&command=insert_person_image" --form "image=@"

JSON RESPONSE

{
    status: 210,  
    status_description: success, 
    post_type: insert_person_image
}
                                                    
                                        

RETURN STATUS VALUES:

  • status > 0 : success, and the return value is the image id
  • status = 0 : error has occurred.
  • status = -1 : no face detected.
  • status = -2 : invalid person id.