API Usage

spoofsense-triton endpoints are optimised for speed and performance.

Walk through

Authentication

You will require x-api-key in order to use the API.

Contact kartikeya@spoofsense.com in case you do not already have it.

1. POST /antispoofing

Performs a Passive Liveness Check.

Detects all types of PAD attacks under ISO 30107 Level-2

https://z3jwq0rjyj.execute-api.ap-south-1.amazonaws.com/prod/antispoofing

2. POST /robust

https://z3jwq0rjyj.execute-api.ap-south-1.amazonaws.com/prod/robust

Features a robust model trained to work under harsh environments - where the captured images might be of low quality. (For Indian Demographic - tuned to work great on Digital Photo Replays, Printed Faces, etc.)

Request body

{
    "data": "image_base64_string",          # base64 string of the image
}

Response

Understanding the Response

Following table shows the API responses and behaviours in different cases

HTTP Code
Type of Image
Raw Output

200

Live Face

{
    "success": true,
    "message": "Process finished successfully",
    "model_output": {
        "pred_idx": "real",
        "prob_real": 0.9997915625572205
}

200

Spoof Face

{
    "success": true,
    "message": "Process finished successfully",
    "model_output": {
        "pred_idx": "spoof",
        "prob_real": 0.00045343424235454
}

200

No Face

{
    "success": false,
    "message": "face not detected"
}

200

Bad Input

{
    "success": false,
    "message": "Invalid base64 string"
}

413

Image Size > 10MB

HTTP content length exceeded 10485760 bytes.

model_output

model_output contains everything needed to check for facial liveness

"pred_idx" refers to the predicted class of the face and has two possible values:

  • "real": A Live Face

  • "spoof": A Spoof Face / Presentation Attack

"prob_real" refers to the probability of the face being "real" (live). A score above THRESHOLD means the face is "real". A score less than THRESHOLDmeans the face is "spoof". "prob_real" metric should be used for writing the liveness check logic in your app.

Default Thresholds

for /antispoofing: Default THRESHOLD is 0.55

for /robust: Default THRESHOLD is 0.50

Perform Liveness Check

if model_output[“prob_real”] > THRESHOLD: 
    return “Liveness Confirmed” 
else: 
    return “Liveness Failed”

THRESHOLD can be changed based on your requirements. A very high THRESHOLD is more strict, can cause more False Negatives (Real faces getting incorrectly classified as Spoofs). You can start with recommended default thresholds for both /antispoofing and /robust.

Last updated