Face detection sits at the entry gate of most computer vision pipelines. Every video call, photo gallery, and security feed depends on spotting human faces before anything else can happen. Yet the choice of model usually forces an unhappy trade-off. Heavy networks offer accuracy but demand expensive GPUs and rack-mounted cooling. Smaller models run on modest hardware yet often choke on small faces or high-resolution feeds. The YuNet model from the OpenCV Zoo breaks that pattern. I spent time benchmarking it across different scales to see whether it earns a place in real projects or merely looks good on paper.
Why YuNet Deserves a Closer Look
YuNet is not a research curiosity. It lives inside the OpenCV Zoo, a collection of pre-trained models optimized for the OpenCV DNN module. The specific variant I tested uses INT8 quantization, which means its weights and activations compress down to 8-bit integers instead of the usual 32-bit floating-point numbers. That is not a minor technical footnote. INT8 slashes memory bandwidth, reduces cache pressure, and allows modern CPUs to chew through inference without breaking a sweat. For anyone building on a laptop, an edge device, or a server without a dedicated graphics card, this efficiency is the difference between a smooth pipeline and a slideshow.
The architecture itself is lightweight by design. It skips the baggage of enormous backbones and focuses on the single task of locating faces. That discipline pays off when you need to integrate detection into a larger application where CPU and battery budget are shared with tracking, recognition, or video encoding.
The Setup
All tests ran on a Mac Studio with an Apple M4 Max chip. The model file was the YuNet INT8 quantized ONNX build from the OpenCV Zoo repository. I measured inference speed on a 1280x720 image first, then compared detection counts across four different input resolutions to understand how scale affects results.
If you want to verify these numbers on your own machine, the process is fully reproducible. Run the following commands to pull the sparse repository and execute the benchmark:
git clone --depth 1 --filter=blob:none --sparse https://github.com/kiarina/labs.git
cd labs
git sparse-checkout set .gitignore .mise/tasks Makefile mise.toml 2026/07/08/yunet-face-detection
mise -C 2026/07/08/yunet-face-detection run
The sparse checkout keeps the download small, and the mise task runner handles dependencies behind the scenes. You do not need to wrestle with Python environments or manual package installations.
Speed That Stays Consistent
On a 1280x720 image, the INT8 YuNet model averaged 9.21 milliseconds per inference. The quickest pass clocked in at 8.03 ms, while the slowest touched 10.47 ms. That is a remarkably tight band. Less than two and a half milliseconds separate the best and worst times.
In practice, this consistency matters more than bragging rights. Real-time applications do not just need low average latency; they need predictable latency. A model that sometimes takes 50 ms creates visible stutter in a webcam feed. YuNet stays flat. You can rely on it to finish a frame before the next one arrives, which makes scheduling the rest of your pipeline far simpler.
Scale Variance Reveals the Real Story
Raw speed means little if the model misses half the faces in a scene. To test this, I fed the same source imagery through YuNet at four different resolutions. The counts tell a clear story:
- 320 x 180: 6 faces detected
- 640 x 360: 26 faces detected
- 1280 x 720: 38 faces detected
- 2560 x 1440: 52 faces detected
The jump is dramatic. At 320 x 180, only the largest, closest faces register. Bump up to 640 x 360, and the count quadruples. At full 1440p, YuNet finds more than eight times as many faces as it did at the lowest resolution.
This happens because downsampling destroys detail faster than intuition suggests. A face that covers a modest patch in a 1440p frame can shrink to a smudge of five by five pixels at 360p. Once facial features collapse below the model's receptive field, they become invisible noise. Eyes merge into eyebrows. Noses disappear. YuNet has nothing to grab onto.
The practical upshot is worth remembering. If your camera captures a wide-angle view of a classroom, a conference room, or a street corner, distant faces will not appear unless you give the model enough pixels. Resolution is not just about image quality here. It is a direct lever on recall.
The Resize Strategy You Actually Need
YuNet is snel genoeg zodat je je input niet uit gewoonte naar 320 x 240 hoeft te forceren. Op de M4 Max draait zelfs 2560 x 1440 zonder een dedicated GPU. Dat verandert de manier waarop je een pipeline moet ontwerpen.
In plaats van elk frame door een kleine, vaste grootte te dwingen, kies je de inputresolutie op basis van wat je probeert te vinden. Als je alleen geïnteresseerd bent in de persoon direct voor de camera, is 720p of zelfs 640p ruim voldoende. Als je elke aanwezige in een grote zaal wilt catalogiseren, voer het model dan een uitsnede met een hogere resolutie of het volledige originele frame. Omdat YuNet lichtgewicht is, heb je de ruimte om die keuze te maken. Je zit niet vast aan één enkele preset om een vertraging van 200 ms te voorkomen.
Er blijft echter één kanttekening bestaan. Het model is nog steeds afhankelijk van de gezichtsgrootte ten opzichte van de inputtensor. Er is hier geen sprake van magische schaalinvariantie. Kleine gezichten blijven onzichtbaar, tenzij ze genoeg pixels beslaan. De oplossing is mechanisch: vergroot je bronafbeelding voordat je de inferentie uitvoert wanneer je op zoek bent naar verre onderwerpen, en mappen de resulterende bounding boxes vervolgens terug naar de originele coördinaten. YuNet geeft je de snelheid om die stap te kunnen maken.
Waar dit past in je stack
YuNet is geen oplossing voor elke denkbare gezichtstaak. Zware occlusie, extreme profielhoeken of 3D-mesh-extractie vallen buiten de scope. Maar voor het standaardwerk van het lokaliseren van gezichten in foto's en videostreams, bevindt het zich in een sweet spot. Real-time webcam-apps, geautomatiseerde tools voor het selecteren van foto's en bescheiden embedded systemen profiteren allemaal van een detector die snel draait op standaard CPU's.
Het INT8 ONNX-formaat maakt implementatie ook moeiteloos. Je hoeft PyTorch of TensorFlow niet te installeren op het doelapparaat. De DNN-module van OpenCV laadt het model direct, waardoor je binary klein blijft en je dependency tree ondiep.
De kern
YuNet bewijst dat gezichtsdetectie geen industriële hardware of overbodige frameworks vereist. De cijfers spreken voor zich: minder dan tien milliseconden voor een 720p-frame, en een directe, voorspelbare toename in het aantal detecties naarmate de resolutie stijgt. Je kunt zelf kiezen of je maximale snelheid wilt bij een gemiddelde resolutie of een bredere dekking op een hogere schaal, en het model zal je niet straffen voor die keuze.
Als je iets bouwt dat werkt met beelden uit de echte wereld, voer dan de bovenstaande reproductiestappen uit op je eigen hardware. Test het met je eigen beeldmateriaal. Stem vervolgens je resize-logica af op de gezichten die je daadwerkelijk wilt vinden. Snelheid is alleen nuttig als je het kunt sturen. YuNet geeft je zowel de snelheid als de controle.
