Skip to content

Face Detection

BETA PRODUCT

Be aware that this project is currently in BETA. If you would like to try this service, please contact us at tech@ximilar.com

Ximilar Face Detection service provides a face detection API to detect face (bounding box) on the image.

API reference

This is documentation of the Ximilar Face Detection API. The API follows the general rules of Ximilar API as described in Section First steps.

Detect endpoint - /v2/detect/

Detect endpoint executes a face detection and it is the main endpoint of entire detection system. You can pass an image in _url, _file or _base64 fields. API endpoint /face/v2/detect gets JSON-formatted body where you need to specify records to process (up to 10).

Parameters:

  • records: A list of real-life photos to find similar products; each record
    • must contain either of _url, _file or _base64 field
curl -H "Content-Type: application/json" -H "authorization: Token __API_TOKEN__" https://api.ximilar.com/face/v2/detect -d '{"records": [ {"_url": "https://bit.ly/2IymQJv" } ] }'
from ximilar.client.face import FaceClient

data = [ {'_url': __IMAGE_URL__ }, {"_file": __FILE_PATH__ } ]

client = FaceClient(token=__API_TOKEN__)
response = client.detect(data)

# cut first detected face from the image
bbox = response["records"][0]["_objects"][0]["bound_box"]
face_image = image[bbox[1] : bbox[3], bbox[0] : bbox[2]]

The result has similar json structure:

CLICK TO SHOW JSON RESULT

{
  "records": [
    {
      "_url": "__SOME_URL__",
      "_status": {
        "code": 200,
        "text": "OK"
      },
      "_width": 2736,
      "_height": 3648,
      "_objects": [
        {
          "name": "Face",
          "bound_box": [
            2103,
            467,
            2694,
            883
          ],
          "prob": 0.9890862107276917
        },
        {
          "name": "Face",
          "bound_box": [
            100,
            100,
            500,
            883
          ],
          "prob": 0.9890862107276917
        }
      ]
    }
  ]
}