People and faces

Person detectionPreview · Face detectionPreview

Person detection and face detection are preview features that locate people and faces in images and can estimate an age range for each face. They're off unless a request turns them on, and their results are informational: they never change an asset's moderation decision, status or policy action.

Turning them on

Set processingOptions.features.personDetection.enabled or faceDetection.enabled to true on an upload, and faceDetection.ageEstimation to true for age ranges. See Processing features for how features are chosen and saved.

import { readFile } from "node:fs/promises";

const asset = await client.assets.classify({
  name: "photo.jpg",
  content: { buffer: await readFile("./photo.jpg"), type: "image/jpeg" },
  processingOptions: {
    features: {
      personDetection: { enabled: true },
      faceDetection: { enabled: true, ageEstimation: true },
    },
  },
});

const faces = asset.classification.faceDetection;
if (faces?.status === "evaluated") {
  for (const face of faces.faces) console.log(face.box, face.ageRange);
}

Availability and billing

Both features analyse images, including images extracted from documents and websites, which keep the features of the upload they came from. Text, audio and video aren't analysed. Detection runs alongside moderation, so it doesn't delay the decision.

Each feature is billed per image it produces a result for, after a free monthly allowance: person detection costs £2.50 per 1,000 images and records one person_detection unit, and face detection costs £2.50 per 1,000 images and records one face_detection unit. Age estimation is included in face detection. An identical image uploaded again reuses the stored result and is still billed. A result that is not-evaluated isn't billed. See Pricing.

Reading the results

Results appear in the asset's classification.personDetection and classification.faceDetection. Each is null when the feature didn't run, and otherwise has a status:

  • evaluated: the feature ran. Person detection lists people and face detection lists faces. An empty list means none were found.
  • not-evaluated: detection was attempted but produced no usable result, with reason unavailable. The moderation decision is unaffected, and the feature isn't billed. The asset still completes, so it can't be retried; upload the image again to run detection again.
{
  "classification": {
    "personDetection": {
      "status": "evaluated",
      "people": [
        { "box": { "left": 0.12, "top": 0.08, "width": 0.31, "height": 0.86 }, "confidence": 0.98 }
      ]
    },
    "faceDetection": {
      "status": "evaluated",
      "faces": [
        {
          "box": { "left": 0.19, "top": 0.11, "width": 0.14, "height": 0.2 },
          "confidence": 0.99,
          "ageRange": { "low": 24, "high": 32 }
        }
      ]
    }
  }
}
  • box gives the position and size as fractions of the image's width and height, from 0 to 1. left and top can be slightly negative when a person or face extends past the edge.
  • confidence is the detection confidence from 0 to 1.
  • ageRange is present only when the request set ageEstimation: true. Use this estimated range in years as an informational signal. Allow for uncertainty of several years; age verification requires separate evidence.
  • Person detection also finds people whose faces aren't visible. Face detection finds faces whether or not the rest of the person is in the image.

Blurring faces

Serve a copy with every detected face blurred using the redact.faces transform option, such as /rendered/redact.faces,width=800. It blurs the boxes face detection found when the image was uploaded, on the full image before the other options apply, so it lines up even when the transform resizes or crops. An image uploaded without face detection has no face boxes and is served unchanged. See Lenses.

Testing

To test your handling of people, faces and age ranges without photos of real people, upload a test image that declares them. See Test person and face detection. Its results are free and marked with classification.testInput: true; never use them for real age checks.

Privacy

Faces are located, not recognised: CalmLens doesn't identify people, compare faces or store face templates. Images with either feature on are sent to a detection subprocessor listed on the Trust page. The boxes, confidences and age ranges are stored in the asset's report and are deleted with the asset. Depending on where you and your users are, age estimation from faces may be regulated; check your obligations before turning it on.

Result compatibility

While person and face detection are in preview, allow for changes to the result structure when integrating and updating your client.

Last updated

Signing in

Signing out

Cookies on CalmLens

We use essential cookies for sign-in and security. With your permission, functional cookies remember your preferences and Google Analytics measures website use and signups. Optional ad measurement cookies link Google ad clicks to signups. Personalised advertising stays off. Manage cookies