help ukraine

We stand with Ukraine! If you're as appalled by Russia's abhorrent attack as we are, please support Ukraine and its people.

Face detection crop

On this page

Automatically detect faces in your image and crop them. Sirv uses deep learning neural networks, trained on millions of images to accurately detect faces in images. Faces can be detected in as little as 200ms.

How to use face detection

Use the crop.type parameter to initiate face detection on an image. Specify face as the type of crop you want to apply, like so:

Original image, not cropped Face detection cropped image

To scale down the size of the face, use ch and/or cw:

Face detected image, scaled to 150px

To see which faces Sirv detected, add to the URL. A red box will be drawn around the face:

AI image face detection with confidence value

Face confidence

Sirv's AI algorithm provides a level of confidence for each face detected. Values range from 0.00 to 1.00, where 1.00 is complete confidence. By default, face crop will initiate if confidence is at least 0.50. This can be adjusted by setting crop.confidence.

The following example has confidence of 0.36 so face crop won't initiate by default:

AI face detection image with 30% confidence value

By lowering the crop.confidence to 0.3, the face will be cropped:

Face detected on image with confidence value at least 30%

Multiple faces

If an image contains more than one face, Sirv shows the face with the highest confidence level i.e. the face which the AI algorithm deems most likely a human face.

AI face detection on image with multiple people

To specify a particular face to crop, use crop.face. Face numbering starts from 0. When multiple faces have the same confidence level, the first face identified will be 0.

The following URLs will show the first 2 faces:

First face detected
Second face detected

Face coordinates

You can check how many faces Sirv detected and what their coordinates are by appending ?info to the image URL, for example:

In the JSON response, you will see a section for faces:

  "faces": {
        "_fileversion": 0,
        "_version": 1,
        "faces": [

The example above shows that 3 faces were detected. Each face has 5 numbers - the first 4 are coordinates for the corners of the box around the face and the 5th is the confidence score.

Was this article helpful?

Get help from a Sirv expert