YuNet Face Detection

YUNET_FACE_DETECTION

Fast face detection that returns a box around every face in a photo and five landmarks, the eyes, the nose tip and the mouth corners.

Utilitiesface-detectionfacial-landmarksyunetlightweightmitFine-tunable
YuNet Face Detection: Utilities model on Kainguru

About YuNet Face Detection

Capabilities

  • Fast and small — a 0.2 MB network that finds faces in milliseconds
  • Five landmarks — eyes, nose tip and mouth corners for every face
  • Pixel coordinates — boxes and points in the photo's own pixels, as JSON
  • Fine-tunable — train it on your own pictures with their face boxes

Good to know

  • Photos up to 30 MB and 40 megapixels, as PNG, JPEG or WebP. The network sees the photo scaled so its longer side is at most 2048 pixels; the boxes are returned in the photo's own pixels.
  • Works best for faces between about 10 and 300 pixels across in the scaled photo; for very large faces, a smaller photo works better.
  • The default score threshold is 0.9; lower it to find more, less certain faces.
  • Detection only: it finds faces, it does not tell who they are.
  • Fine-tuning takes one ZIP (at most 4 GB, 5000 entries, no password) with 4 to 1000 pictures (each up to 30 MB and 40 megapixels) and a manifest.jsonl with one line per picture: {"file": "photos/a.jpg", "faces": [{"box": [x0, y0, x1, y1], "landmarks": [[x, y], [x, y], [x, y], [x, y], [x, y]]}]}. Paths are relative to the manifest, and manifest.jsonl is at most 16 MB.
  • Boxes and landmarks are in pixels of the picture as displayed (after its EXIF rotation). Landmarks are optional (null): a face without them trains the box only. A picture may have up to 1000 faces, or none.
  • Training letterboxes every picture to 640 x 640 pixels and mirrors half of them; it stops after 10,000 steps or 9 hours, whichever comes first, and keeps what it learned.

Attribution

YuNet by Shiqi Yu and the libfacedetection contributors, released under the MIT License, Copyright (c) 2020 Shiqi Yu; its training code is BSD-3-Clause.

YuNet Face Detection inputs and output

NameTypeRequiredDefaultDetails
imagefileYes—The picture: PNG, JPEG or WebP, at most 30 MB and 40 megapixels.
1–2048 characters · image/png, jpeg, webp
score_thresholdnumberNo0.9Lowest score of a returned face, 0 to 1; higher returns fewer, surer faces.
0–1
max_facesintegerNo50The most faces to return, best first.
1–200

Output. JSON array, best first: [{"score": 0.99, "box": [x0, y0, x1, y1], "landmarks": [[x, y], ...]}], in pixels of the picture; landmarks: eyes, nose tip, mouth corners, left to right as seen. At most 200 faces.

Run YuNet Face Detection with the API

Send your API key in the X-API-Key header. The run is asynchronous: submit it, then poll it until it finishes. Create an API key.

cURL
curl -X POST "https://api.kainguru.com/api/v1/executions?mlFlowId=YUNET_FACE_DETECTION" \
  -H "X-API-Key: kg_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
  "input": {
    "image": "https://example.com/input.png",
    "max_faces": 50,
    "score_threshold": 0.9
  },
  "outputFormat": "json"
}'

# Poll until the execution reaches a terminal state
curl "https://api.kainguru.com/api/v1/executions/{executionId}" \
  -H "X-API-Key: kg_your_api_key"
Python
from kainguru import KainguruClient

with KainguruClient(api_key="kg_your_api_key", base_url="https://api.kainguru.com/api") as client:
    submitted = client.executions.execute(
        "YUNET_FACE_DETECTION",
        {
          "image": "https://example.com/input.png",
          "max_faces": 50,
          "score_threshold": 0.9
        },
        output_format="json",
    )
    result = client.executions.await_completion(submitted.id)
    print(result.execution.output)

Fine-tune YuNet Face Detection

You can fine-tune YuNet Face Detection on your own data and run the tuned model through the same API. Dataset: One ZIP (at most 4 GB, no password) with 4 to 1000 pictures and a manifest.jsonl: one line per picture, {"file", "faces": [{"box", "landmarks"}]} in pixels. More rules: Good to know, in the README.

The steps are in the docs.

YuNet Face Detection pricing

Price per request: 0.0437 credits ($0.000437). The price is shown again before every run; all prices are on the pricing page.

Licence and source

RetinaFace ResNet-50: Utilities model on Kainguru
Utilities

RetinaFace ResNet-50

Finds every face in a photo and returns a box around each one with five landmarks, the eyes, the nose tip and the…

Fine-tunable
BiRefNet General: Utilities model on Kainguru
Utilities

BiRefNet General

Removes the background from a photo and returns the subject on a transparent background, or as a black-and-white mask.

Fine-tunable
Cloth Segmentation U2-Net: Utilities model on Kainguru
Utilities

Cloth Segmentation U2-Net

Finds the clothes a person wears in a photo and returns a mask for the upper body, the lower body and full-body…

Fine-tunable
EoMT Large COCO Panoptic: Utilities model on Kainguru
Utilities

EoMT Large COCO Panoptic

Splits a picture into its objects and regions, such as people, cars, sky and road, with a label and a mask for each one.

Fine-tunable
InSPyReNet: Utilities model on Kainguru
Utilities

InSPyReNet

Removes the background from a photo with fine detail at hair and edges, and returns the subject on a transparent…

Fine-tunable
MoGe-2 ViT-L Normal: Utilities model on Kainguru
Utilities

MoGe-2 ViT-L Normal

Estimates metric depth, surface normals and the camera's field of view from a single photo of any scene, indoors or out.

Fine-tunable