Back to Compreface

Rest API description

docs/Rest-API-description.md

1.2.053.0 KB
Original Source

Rest API description

Table Of Contents

To know more about face services and face plugins visit this page.

Postman documentation

There is a Postman REST API documentation that covers the same REST endpoint. Postman documentation supports snippets on the most popular programming languages.

Face Recognition Service

Managing Subjects

These endpoints allow you to work with subjects.

The most popular case of subject usage is to assign a subject to one person. So, to upload several images of one person, you need to upload them to one subject. As a result, when you perform face recognition, you find a person who is on the image.

Another case of subject usage is assigning a photo of several people as a subject. In this case, you need to detect all faces on the image and then save them to one subject. As a result, when you perform face recognition, you find all photos on which there is the person who is on the image. You don’t need to work with subjects explicitly. You can just upload a new example of the subject and the subject will be created automatically. Or if you delete all the examples of the subject, it will be deleted automatically.

Add a Subject

since 0.6 version

Create a new subject in Face Collection. Creating a subject is an optional step, you can upload an example without an existing subject, and a subject will be created automatically.

shell
curl -X POST "http://localhost:8000/api/v1/recognition/subjects" \
-H "Content-Type: application/json" \
-H "x-api-key: <service_api_key>" \
-d '{"subject": "<subject_name>"}'
ElementDescriptionTypeRequiredNotes
Content-Typeheaderstringrequiredapplication/json
x-api-keyheaderstringrequiredapi key of the Face recognition service, created by the user
subjectbody paramstringrequiredis the name of the subject. It can be a person name, but it can be any string

Response body on success:

json
{
  "subject": "<subject_name>"
}
ElementTypeDescription
subjectstringis the name of the subject

Rename a Subject

since 0.6 version

Rename existing subject. If a new subject name already exists, subjects are merged - all faces from the old subject name are reassigned to the subject with the new name, old subject removed.

shell
curl -X PUT "http://localhost:8000/api/v1/recognition/subjects/<subject>" \
-H "Content-Type: application/json" \
-H "x-api-key: <service_api_key>" \
-d '{"subject: <subject_name>"}'
ElementDescriptionTypeRequiredNotes
Content-Typeheaderstringrequiredapplication/json
x-api-keyheaderstringrequiredapi key of the Face recognition service, created by the user
subjectbody paramstringrequiredis the name of the subject. It can be a person name, but it can be any string

Response body on success:

json
{
  "updated": "true|false"
}
ElementTypeDescription
updatedbooleanfailed or success

Delete a Subject

since 0.6 version

Delete existing subject and all saved faces.

shell
curl -X DELETE "http://localhost:8000/api/v1/recognition/subjects/<subject>" \
-H "Content-Type: application/json" \
-H "x-api-key: <service_api_key>"
ElementDescriptionTypeRequiredNotes
Content-Typeheaderstringrequiredapplication/json
x-api-keyheaderstringrequiredapi key of the Face recognition service, created by the user
subjectbody paramstringrequiredis the name of the subject. It can be a person name, but it can be any string

Response body on success:

json
{
  "subject": "<subject_name>"
}
ElementTypeDescription
subjectstringis the name of the subject

Delete All Subjects

since 0.6 version

Delete all existing subjects and all saved faces.

shell
curl -X DELETE "http://localhost:8000/api/v1/recognition/subjects" \
-H "Content-Type: application/json" \
-H "x-api-key: <service_api_key>"
ElementDescriptionTypeRequiredNotes
Content-Typeheaderstringrequiredapplication/json
x-api-keyheaderstringrequiredapi key of the Face recognition service, created by the user

Response body on success:

json
{
  "deleted": "<count>"
}
ElementTypeDescription
deletedintegernumber of deleted subjects

List Subjects

since 0.6 version

This returns all subject related to Face Collection.

shell
curl -X GET "http://localhost:8000/api/v1/recognition/subjects/" \
-H "Content-Type: application/json" \
-H "x-api-key: <service_api_key>"
ElementDescriptionTypeRequiredNotes
Content-Typeheaderstringrequiredapplication/json
x-api-keyheaderstringrequiredapi key of the Face recognition service, created by the user

Response body on success:

json
{
  "subjects": [
    "<subject_name1>",
    "<subject_name2>"
    ]
}
ElementTypeDescription
subjectsarraythe list of subjects in Face Collection

Managing Subject Examples

The subject example is basically an image of a known face that you want to save to face collection.

When you save a subject example, CompreFace calculates the embedding of the face (faceprint) and saves it into the database. By default, the image itself is also saved, it is needed for managing images, e.g. download of the image. You can change it using save_images_to_db parameter in configuration.

One subject example is enough for face recognition, the accuracy will be high enough. But if you add more examples, the accuracy may be even better.

Add an Example of a Subject

This creates an example of the subject by saving images. You can add as many images as you want to train the system. Image should contain only one face.

shell
curl -X POST "http://localhost:8000/api/v1/recognition/faces?subject=<subject>&det_prob_threshold=<det_prob_threshold>" \
-H "Content-Type: multipart/form-data" \
-H "x-api-key: <service_api_key>" \
-F file=@<local_file> 
ElementDescriptionTypeRequiredNotes
Content-Typeheaderstringrequiredmultipart/form-data
x-api-keyheaderstringrequiredapi key of the Face recognition service, created by the user
subjectparamstringrequiredis the name you assign to the image you save
det_prob_thresholdparamstringoptionalminimum required confidence that a recognized face is actually a face. Value is between 0.0 and 1.0.
filebodyimagerequiredallowed image formats: jpeg, jpg, ico, png, bmp, gif, tif, tiff, webp. Max size is 5Mb

Response body on success:

json
{
  "image_id": "6b135f5b-a365-4522-b1f1-4c9ac2dd0728",
  "subject": "subject1"
}
ElementTypeDescription
image_idUUIDUUID of uploaded image
subjectstringSubject of the saved image

List of All Saved Examples of the Subject

To retrieve a list of subjects saved in a Face Collection:

shell
curl -X GET "http://localhost:8000/api/v1/recognition/faces?page=<page>&size=<size>&subject=<subject>" \
-H "x-api-key: <service_api_key>" \
ElementDescriptionTypeRequiredNotes
x-api-keyheaderstringrequiredapi key of the Face recognition service, created by the user
pageparamintegeroptionalpage number of examples to return. Can be used for pagination. Default value is 0. Since 0.6 version
sizeparamintegeroptionalfaces on page (page size). Can be used for pagination. Default value is 20. Since 0.6 version
subjectparamstringoptionalwhat subject examples endpoint should return. If empty, return examples for all subjects. Since 1.0 version

Response body on success:

{
  "faces": [
    {
      "image_id": <image_id>,
      "subject": <subject>
    },
    ...
  ],
  "page_number": 0,
  "page_size": 10,
  "total_pages": 2,
  "total_elements": 12
}
ElementTypeDescription
face.image_idUUIDUUID of the face
faсe.subjectstring<subject> of the person, whose picture was saved for this api key
page_numberintegerpage number
page_sizeintegerrequested page size
total_pagesintegertotal pages
total_elementsintegertotal faces

Delete All Examples of the Subject by Name

To delete all image examples of the <subject>:

shell
curl -X DELETE "http://localhost:8000/api/v1/recognition/faces?subject=<subject>" \
-H "x-api-key: <service_api_key>"
ElementDescriptionTypeRequiredNotes
x-api-keyheaderstringrequiredapi key of the Face recognition service, created by the user
subjectparamstringoptionalis the name subject. If this parameter is absent, all faces in Face Collection will be removed

Response body on success:

{
    "deleted": <count>
}
ElementTypeDescription
deletedintegerNumber of deleted faces

Delete an Example of the Subject by ID

Endpoint to delete an image by ID. If no image found by id - 404.

shell
curl -X DELETE "http://localhost:8000/api/v1/recognition/faces/<image_id>" \
-H "x-api-key: <service_api_key>"
ElementDescriptionTypeRequiredNotes
x-api-keyheaderstringrequiredapi key of the Face recognition service, created by the user
image_idvariableUUIDrequiredUUID of the removing face

Response body on success:

{
  "image_id": <image_id>,
  "subject": <subject>
}
ElementTypeDescription
image_idUUIDUUID of the removed face
subjectstring<subject> of the person, whose picture was saved for this api key

Delete Multiple Examples

since 1.0 version

To delete several subject examples:

shell
curl -X POST "http://localhost:8000/api/v1/recognition/faces/delete" \
-H "Content-Type: application/json" \
-H "x-api-key: <service_api_key>" \
-d '["<image_id1>","<image_id2>", ..., "<image_idN>"]'
ElementDescriptionTypeRequiredNotes
service_api_keyheaderstringrequiredapi key of the Face recognition service, created by the user
image_idvariableUUIDrequiredUUID of the removing face

Response body on success:

{
  "image_id": <image_id>,
  "subject": <subject>
}
ElementDescriptionType
image_idUUID of the removed faceUUID
subjectof the person, whose picture was saved for this api keystring

If some image ids are not exists, they will be ignored

Direct Download an Image example of the Subject by ID

since 0.6 version

You can paste this URL into the html tag to show the image.

shell
curl -X GET "http://localhost:8000/api/v1/static/<service_api_key>/images/<image_id>"
ElementDescriptionTypeRequiredNotes
service_api_keyvariablestringrequiredapi key of the Face recognition service, created by the user
image_idvariableUUIDrequiredUUID of the image to download

Response body is binary image. Empty bytes if image not found.

Download an Image example of the Subject by ID

since 0.6 version

To download an image example of the Subject by ID:

shell
curl -X GET "http://localhost:8000/api/v1/recognition/faces/<image_id>/img"
-H "x-api-key: <service_api_key>"
ElementDescriptionTypeRequiredNotes
x-api-keyheaderstringrequiredapi key of the Face recognition service, created by the user
image_idvariableUUIDrequiredUUID of the image to download

Response body is binary image. Empty bytes if image not found.

Recognize Faces from a Given Image

To recognize faces from the uploaded image:

shell
curl  -X POST "http://localhost:8000/api/v1/recognition/recognize?limit=<limit>&prediction_count=<prediction_count>&det_prob_threshold=<det_prob_threshold>&face_plugins=<face_plugins>&status=<status>&detect_faces=<detect_faces>" \
-H "Content-Type: multipart/form-data" \
-H "x-api-key: <service_api_key>" \
-F file=<local_file>
ElementDescriptionTypeRequiredNotes
Content-Typeheaderstringrequiredmultipart/form-data
x-api-keyheaderstringrequiredapi key of the Face recognition service, created by the user
filebodyimagerequiredallowed image formats: jpeg, jpg, ico, png, bmp, gif, tif, tiff, webp. Max size is 5Mb
limitparamintegeroptionalmaximum number of faces on the image to be recognized. It recognizes the biggest faces first. Value of 0 represents no limit. Default value: 0
det_prob_thresholdparamstringoptionalminimum required confidence that a recognized face is actually a face. Value is between 0.0 and 1.0.
prediction_countparamintegeroptionalmaximum number of subject predictions per face. It returns the most similar subjects. Default value: 1
face_pluginsparamstringoptionalcomma-separated slugs of face plugins. If empty, no additional information is returned. Learn more
statusparambooleanoptionalif true includes system information like execution_time and plugin_version fields. Default value is false
detect_facesparambooleanoptionalif false, CompreFace won't run a face detector. Instead, it will treat the image as a cropped face. Default value is true. Since 1.2 version

Response body on success:

json
{
  "result" : [ {
    "age" : {
      "probability": 0.9308982491493225,
      "high": 32,
      "low": 25
    },
    "gender" : {
      "probability": 0.9898611307144165,
      "value": "female"
    },
    "mask" : {
      "probability": 0.9999470710754395,
      "value": "without_mask"
    },
    "embedding" : [ 9.424854069948196E-4, "...", -0.011415496468544006 ],
    "box" : {
      "probability" : 1.0,
      "x_max" : 1420,
      "y_max" : 1368,
      "x_min" : 548,
      "y_min" : 295
    },
    "landmarks" : [ [ 814, 713 ], [ 1104, 829 ], [ 832, 937 ], [ 704, 1030 ], [ 1017, 1133 ] ],
    "subjects" : [ {
      "similarity" : 0.97858,
      "subject" : "subject1"
    } ],
    "execution_time" : {
      "age" : 28.0,
      "gender" : 26.0,
      "detector" : 117.0,
      "calculator" : 45.0,
      "mask": 36.0
    }
  } ],
  "plugins_versions" : {
    "age" : "agegender.AgeDetector",
    "gender" : "agegender.GenderDetector",
    "detector" : "facenet.FaceDetector",
    "calculator" : "facenet.Calculator",
    "mask": "facemask.MaskDetector"
  }
}
ElementTypeDescription
ageobjectdetected age range. Return only if age plugin is enabled
genderobjectdetected gender. Return only if gender plugin is enabled
poseobjectdetected head pose. Return only if pose plugin is enabled
maskobjectdetected mask. Return only if face mask plugin is enabled.
embeddingarrayface embeddings. Return only if calculator plugin is enabled
boxobjectlist of parameters of the bounding box for this face
probabilityfloatprobability that a found face is actually a face
x_max, y_max, x_min, y_minintegercoordinates of the frame containing the face
landmarksarraylist of the coordinates of the frame containing the face-landmarks. Return only if landmarks plugin is enabled
subjectslistlist of similar subjects with size of <prediction_count> order by similarity
similarityfloatsimilarity that on that image predicted person
subjectstringname of the subject in Face Collection
execution_timeobjectexecution time of all plugins
plugins_versionsobjectcontains information about plugin versions

Verify Faces from a Given Image

To compare faces from the uploaded images with the face in saved image ID:

shell
curl -X POST "http://localhost:8000/api/v1/recognition/faces/<image_id>/verify?limit=<limit>&det_prob_threshold=<det_prob_threshold>&face_plugins=<face_plugins>&status=<status>" \
-H "Content-Type: multipart/form-data" \
-H "x-api-key: <service_api_key>" \
-F file=<local_file>
ElementDescriptionTypeRequiredNotes
Content-Typeheaderstringrequiredmultipart/form-data
x-api-keyheaderstringrequiredapi key of the Face recognition service, created by the user
image_idvariableUUIDrequiredUUID of the verifying face
filebodyimagerequiredallowed image formats: jpeg, jpg, ico, png, bmp, gif, tif, tiff, webp. Max size is 5Mb
limitparamintegeroptionalmaximum number of faces on the target image to be recognized. It recognizes the biggest faces first. Value of 0 represents no limit. Default value: 0
det_prob_thresholdparamstringoptionalminimum required confidence that a recognized face is actually a face. Value is between 0.0 and 1.0.
face_pluginsparamstringoptionalcomma-separated slugs of face plugins. If empty, no additional information is returned. Learn more
statusparambooleanoptionalif true includes system information like execution_time and plugin_version fields. Default value is false

Response body on success:

json
{
  "result": [
    {
      "age" : {
        "probability": 0.9308982491493225,
        "high": 32,
        "low": 25
      },
      "gender" : {
        "probability": 0.9898611307144165,
        "value": "female"
      },
      "mask" : {
        "probability": 0.9999470710754395,
        "value": "without_mask"
      },
      "embedding" : [ -0.049007344990968704, "...", -0.01753818802535534 ],
      "box" : {
        "probability" : 0.9997453093528748,
        "x_max" : 205,
        "y_max" : 167,
        "x_min" : 48,
        "y_min" : 0
      },
      "landmarks" : [ [ 260, 129 ], [ 273, 127 ], [ 258, 136 ], [ 257, 150 ], [ 269, 148 ] ],
      "similarity" : 0.97858,
      "execution_time" : {
        "age" : 59.0,
        "gender" : 30.0,
        "detector" : 177.0,
        "calculator" : 70.0,
        "mask": 36.0
      }
    }
  ],
  "plugins_versions" : {
    "age" : "agegender.AgeDetector",
    "gender" : "agegender.GenderDetector",
    "detector" : "facenet.FaceDetector",
    "calculator" : "facenet.Calculator",
    "mask": "facemask.MaskDetector"
  }
}
ElementTypeDescription
ageobjectdetected age range. Return only if age plugin is enabled
genderobjectdetected gender. Return only if gender plugin is enabled
poseobjectdetected head pose. Return only if pose plugin is enabled
maskobjectdetected mask. Return only if face mask plugin is enabled
embeddingarrayface embeddings. Return only if calculator plugin is enabled
boxobjectlist of parameters of the bounding box for this face
probabilityfloatprobability that a found face is actually a face
x_max, y_max, x_min, y_minintegercoordinates of the frame containing the face
landmarksarraylist of the coordinates of the frame containing the face-landmarks. Return only if landmarks plugin is enabled
similarityfloatsimilarity that on that image predicted person
execution_timeobjectexecution time of all plugins
plugins_versionsobjectcontains information about plugin versions

Face Detection Service

To detect faces from the uploaded image:

shell
curl  -X POST "http://localhost:8000/api/v1/detection/detect?limit=<limit>&det_prob_threshold=<det_prob_threshold>&face_plugins=<face_plugins>&status=<status>" \
-H "Content-Type: multipart/form-data" \
-H "x-api-key: <service_api_key>" \
-F file=<local_file>
ElementDescriptionTypeRequiredNotes
Content-Typeheaderstringrequiredmultipart/form-data
x-api-keyheaderstringrequiredapi key of the Face Detection service, created by the user
filebodyimagerequiredimage where to detect faces. Allowed image formats: jpeg, jpg, ico, png, bmp, gif, tif, tiff, webp. Max size is 5Mb
limitparamintegeroptionalmaximum number of faces on the image to be recognized. It recognizes the biggest faces first. Value of 0 represents no limit. Default value: 0
det_prob_thresholdparamstringoptionalminimum required confidence that a recognized face is actually a face. Value is between 0.0 and 1.0
face_pluginsparamstringoptionalcomma-separated slugs of face plugins. If empty, no additional information is returned. Learn more
statusparambooleanoptionalif true includes system information like execution_time and plugin_version fields. Default value is false

Response body on success:

json
{
  "result" : [ {
    "age" : {
      "probability": 0.9308982491493225,
      "high": 32,
      "low": 25
    },
    "gender" : {
      "probability": 0.9898611307144165,
      "value": "female"
    },
    "mask" : {
      "probability": 0.9999470710754395,
      "value": "without_mask"
    },
    "embedding" : [ -0.03027934394776821, "...", -0.05117142200469971 ],
    "box" : {
      "probability" : 0.9987509250640869,
      "x_max" : 376,
      "y_max" : 479,
      "x_min" : 68,
      "y_min" : 77
    },
    "landmarks" : [ [ 156, 245 ], [ 277, 253 ], [ 202, 311 ], [ 148, 358 ], [ 274, 365 ] ],
    "execution_time" : {
      "age" : 30.0,
      "gender" : 26.0,
      "detector" : 130.0,
      "calculator" : 49.0,
      "mask": 36.0
    }
  } ],
  "plugins_versions" : {
    "age" : "agegender.AgeDetector",
    "gender" : "agegender.GenderDetector",
    "detector" : "facenet.FaceDetector",
    "calculator" : "facenet.Calculator",
    "mask": "facemask.MaskDetector"
  }
}
ElementTypeDescription
ageobjectdetected age range. Return only if age plugin is enabled
genderobjectdetected gender. Return only if gender plugin is enabled
poseobjectdetected head pose. Return only if pose plugin is enabled
maskobjectdetected mask. Return only if face mask plugin is enabled
embeddingarrayface embeddings. Return only if calculator plugin is enabled
boxobjectlist of parameters of the bounding box for this face (on processedImage)
probabilityfloatprobability that a found face is actually a face (on processedImage)
x_max, y_max, x_min, y_minintegercoordinates of the frame containing the face (on processedImage)
landmarksarraylist of the coordinates of the frame containing the face-landmarks. Return only if landmarks plugin is enabled
execution_timeobjectexecution time of all plugins
plugins_versionsobjectcontains information about plugin versions

Face Verification Service

To compare faces from given two images:

shell
curl  -X POST "http://localhost:8000/api/v1/verification/verify?limit=<limit>&prediction_count=<prediction_count>&det_prob_threshold=<det_prob_threshold>&face_plugins=<face_plugins>&status=<status>" \
-H "Content-Type: multipart/form-data" \
-H "x-api-key: <service_api_key>" \
-F source_image=<local_check_file>
-F target_image=<local_process_file>
ElementDescriptionTypeRequiredNotes
Content-Typeheaderstringrequiredmultipart/form-data
x-api-keyheaderstringrequiredapi key of the Face verification service, created by the user
source_imagebodyimagerequiredfile to be verified. Allowed image formats: jpeg, jpg, ico, png, bmp, gif, tif, tiff, webp. Max size is 5Mb
target_imagebodyimagerequiredreference file to check the source file. Allowed image formats: jpeg, jpg, ico, png, bmp, gif, tif, tiff, webp. Max size is 5Mb
limitparamintegeroptionalmaximum number of faces on the target image to be recognized. It recognizes the biggest faces first. Value of 0 represents no limit. Default value: 0
det_prob_thresholdparamstringoptionalminimum required confidence that a recognized face is actually a face. Value is between 0.0 and 1.0.
face_pluginsparamstringoptionalcomma-separated slugs of face plugins. If empty, no additional information is returned. Learn more
statusparambooleanoptionalif true includes system information like execution_time and plugin_version fields. Default value is false

Response body on success:

json
{
  "result" : [{
    "source_image_face" : {
      "age" : {
        "probability": 0.9308982491493225,
        "high": 32,
        "low": 25
      },
      "gender" : {
        "probability": 0.9898611307144165,
        "value": "female"
      },
      "mask" : {
        "probability": 0.9999470710754395,
        "value": "without_mask"
      },
      "embedding" : [ -0.0010271212086081505, "...", -0.008746841922402382 ],
      "box" : {
        "probability" : 0.9997453093528748,
        "x_max" : 205,
        "y_max" : 167,
        "x_min" : 48,
        "y_min" : 0
      },
      "landmarks" : [ [ 92, 44 ], [ 130, 68 ], [ 71, 76 ], [ 60, 104 ], [ 95, 125 ] ],
      "execution_time" : {
        "age" : 85.0,
        "gender" : 51.0,
        "detector" : 67.0,
        "calculator" : 116.0,
        "mask": 36.0
      }
    },
    "face_matches": [
      {
        "age" : {
          "probability": 0.9308982491493225,
          "high": 32,
          "low": 25
        },
        "gender" : {
          "probability": 0.9898611307144165,
          "value": "female"
        },
        "mask" : {
          "probability": 0.9999470710754395,
          "value": "without_mask"
        },
        "embedding" : [ -0.049007344990968704, "...", -0.01753818802535534 ],
        "box" : {
          "probability" : 0.99975,
          "x_max" : 308,
          "y_max" : 180,
          "x_min" : 235,
          "y_min" : 98
        },
        "landmarks" : [ [ 260, 129 ], [ 273, 127 ], [ 258, 136 ], [ 257, 150 ], [ 269, 148 ] ],
        "similarity" : 0.97858,
        "execution_time" : {
          "age" : 59.0,
          "gender" : 30.0,
          "detector" : 177.0,
          "calculator" : 70.0,
          "mask": 36.0
        }
      }],
    "plugins_versions" : {
      "age" : "agegender.AgeDetector",
      "gender" : "agegender.GenderDetector",
      "detector" : "facenet.FaceDetector",
      "calculator" : "facenet.Calculator",
      "mask": "facemask.MaskDetector"
    }
  }]
}
ElementTypeDescription
source_image_faceobjectadditional info about source image face
face_matchesarrayresult of face verification
ageobjectdetected age range. Return only if age plugin is enabled
genderobjectdetected gender. Return only if gender plugin is enabled
poseobjectdetected head pose. Return only if pose plugin is enabled
maskobjectdetected mask. Return only if face mask plugin is enabled
embeddingarrayface embeddings. Return only if calculator plugin is enabled
boxobjectlist of parameters of the bounding box for this face
probabilityfloatprobability that a found face is actually a face
x_max, y_max, x_min, y_minintegercoordinates of the frame containing the face
landmarksarraylist of the coordinates of the frame containing the face-landmarks. Return only if landmarks plugin is enabled
similarityfloatsimilarity between this face and the face on the source image
execution_timeobjectexecution time of all plugins
plugins_versionsobjectcontains information about plugin versions

Base64 Support

since 0.5.1 version

Except multipart/form-data, all CompreFace endpoints, that require images as input, accept images in Base64 format. The base rule is to use Content-Type: application/json header and send JSON in the body. The name of the JSON parameter coincides with the name of the multipart/form-data parameter.

Add an Example of a Subject, Base64

Full description here.

shell
curl -X POST "http://localhost:8000/api/v1/recognition/faces?subject=<subject>&det_prob_threshold=<det_prob_threshold>" \
-H "Content-Type: application/json" \
-H "x-api-key: <service_api_key>" \
-d {"file": "<base64_value>"}

Recognize Faces from a Given Image, Base64

Full description here.

shell
curl  -X POST "http://localhost:8000/api/v1/recognition/recognize?limit=<limit>&prediction_count=<prediction_count>&det_prob_threshold=<det_prob_threshold>&face_plugins=<face_plugins>&status=<status>" \
-H "Content-Type: application/json" \
-H "x-api-key: <service_api_key>" \
-d {"file": "<base64_value>"}

Verify Faces from a Given Image, Base64

Full description here.

shell
curl -X POST "http://localhost:8000/api/v1/recognition/faces/<image_id>/verify?
limit=<limit>&det_prob_threshold=<det_prob_threshold>&face_plugins=<face_plugins>&status=<status>" \
-H "Content-Type: application/json" \
-H "x-api-key: <service_api_key>" \
-d {"file": "<base64_value>"}

Face Detection Service, Base64

Full description here.

shell
curl  -X POST "http://localhost:8000/api/v1/detection/detect?limit=<limit>&det_prob_threshold=<det_prob_threshold>&face_plugins=<face_plugins>&status=<status>" \
-H "Content-Type: application/json" \
-H "x-api-key: <service_api_key>" \
-d {"file": "<base64_value>"}

Face Verification Service, Base64

Full description here.

shell
curl -X POST "http://localhost:8000/api/v1/verification/verify?limit=<limit>&prediction_count=<prediction_count>&det_prob_threshold=<det_prob_threshold>&face_plugins=<face_plugins>&status=<status>" \
-H "Content-Type: application/json" \
-H "x-api-key: <service_api_key>" \
-d {"source_image": "<source_image_base64_value>", "target_image": "<target_image_base64_value>"}

Recognition and verification using embedding

since 1.2.0 version

You can use computed embedding to perform recognition and verification. To obtain embedding, you can use calculator plugin in each Face service. The base rule is to use Content-Type: application/json header and send JSON in the body.

Recognize Faces from a Given Image, Embedding

The service is used to determine similarities between input embeddings and embeddings within the Face Collection. An example:

shell
curl -X POST "http://localhost:8000/api/v1/recognition/embeddings/recognize?prediction_count=<prediction_count>" \
-H "Content-Type: application/json" \
-H "x-api-key: <service_api_key>" \
-d {"embeddings": [[<array_of_embedding>], ...]}
ElementDescriptionTypeRequiredNotes
Content-Typeheaderstringrequiredapplication/json
x-api-keyheaderstringrequiredan api key of the Face recognition service, created by the user
embeddingsbodyarrayrequiredan input embeddings. The length depends on the model (e.g. 512 or 128)
prediction_countparamintegeroptionalthe maximum number of subject predictions per embedding. It returns the most similar subjects. Default value: 1

Response body on success:

json
{
  "result": [
    {
      "embedding": [0.0627421774604647, "...", -0.0236684433507126],
      "similarities": [
        {
          "subject": "John",
          "similarity": 0.55988
        },
        "..."
      ]
    },
    "..."
  ]
}
ElementTypeDescription
resultarrayan array that contains all the results
embeddingarrayan input embedding
similaritiesarrayan array that contains results of similarity between the embedding and the input embedding
subjectstringa subject in which the similar embedding was found
similarityfloata similarity between the embedding and the input embedding

Verify Faces from a Given Image, Embedding

The endpoint is used to compare input embeddings to the embedding stored in Face Collection. An example:

shell
curl -X POST "http://localhost:8000/api/v1/recognition/embeddings/faces/{image_id}/verify" \
-H "Content-Type: application/json" \
-H "x-api-key: <service_api_key>" \
-d {"embeddings": [[<array_of_embeddings>], ...]}
ElementDescriptionTypeRequiredNotes
Content-Typeheaderstringrequiredapplication/json
x-api-keyheaderstringrequiredapi key of the Face recognition service, created by the user
embeddingsbodyarrayrequiredan input embeddings. The length depends on the model (e.g. 512 or 128)
image_idvariableUUIDrequiredan id of the source embedding within the Face Collection

Response body on success:

json
{
  "result": [
    {
      "embedding": [0.0627421774604647, "...", -0.0236684433507126],
      "similarity": 0.55988
    },
    "..."
  ]
}
ElementTypeDescription
resultarrayan array that contains all the results
embeddingarraya source embedding which we are comparing to embedding from Face Collection
similarityfloata similarity between the source embedding and embedding from Face Collection

Face Verification Service, Embedding

The service is used to determine similarities between an input source embedding and input target embeddings. An example:

shell
curl -X POST "http://localhost:8000/api/v1/verification/embeddings/verify" \
-H "Content-Type: application/json" \
-H "x-api-key: <service_api_key>" \
-d {"source": [<source_embedding>], "targets": [[<target_embedding>], ...]}
ElementDescriptionTypeRequiredNotes
Content-Typeheaderstringrequiredapplication/json
x-api-keyheaderstringrequiredapi key of the Face verification service, created by the user
sourcebodyarrayrequiredan input embeddings. The length depends on the model (e.g. 512 or 128)
targetsbodyarrayrequiredan array of the target embeddings. The length depends on the model (e.g. 512 or 128)

Response body on success:

json
{
  "result": [
    {
      "embedding": [0.0627421774604647, "...", -0.0236684433507126],
      "similarity": 0.55988
    },
    "..."
  ]
}
ElementTypeDescription
resultarrayan array that contains all the results
embeddingarraya target embedding which we are comparing to source embedding
similarityfloata similarity between the source embedding and the target embedding