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 cukup pantas sehingga anda tidak perlu mengecilkan input anda kepada 320 x 240 secara membuta tuli. Pada M4 Max, malah resolusi 2560 x 1440 boleh dijalankan tanpa GPU khusus. Ini mengubah cara anda harus merangka saluran paip (pipeline).

Daripada memaksa setiap bingkai melalui saiz tetap yang kecil, pilih resolusi input anda berdasarkan apa yang anda cuba cari. Jika anda hanya mementingkan orang yang berada tepat di hadapan kamera, 720p atau malah 640p sudah mencukupi. Jika anda perlu menyenaraikan setiap peserta dalam dewan yang besar, berikan model tersebut keratan (crop) resolusi lebih tinggi atau bingkai asal sepenuhnya. Oleh kerana YuNet adalah ringan, anda mempunyai ruang untuk membuat pilihan tersebut. Anda tidak terikat pada satu tetapan pratetap tunggal semata-mata untuk mengelakkan lengah (lag) 200 ms.

Satu peringatan tetap ada. Model ini masih bergantung pada saiz wajah berbanding tensor input. Tiada ketidakterubahan skala (scale invariance) ajaib di sini. Wajah yang kecil akan kekal tidak kelihatan melainkan ia memenuhi jumlah piksel yang mencukupi. Penyelesaiannya adalah secara mekanikal: besarkan saiz imej sumber anda sebelum inferens apabila mencari subjek yang jauh, kemudian petakan kotak sempadan (bounding boxes) yang terhasil kembali ke koordinat asal. YuNet memberikan anda bajet kelajuan untuk melakukan langkah tersebut.

Di Mana Kedudukannya dalam Stack Anda

YuNet bukanlah penyelesaian untuk setiap tugasan wajah yang boleh dibayangkan. Halangan (occlusion) yang berat, sudut profil yang ekstrem, atau pengekstrakan mesh 3D adalah di luar skopnya. Namun untuk kerja asas seperti mengesan wajah dalam foto dan aliran video, ia berada pada tahap yang sangat ideal. Aplikasi webcam masa nyata, alat penapisan foto automatik, dan sistem terbenam (embedded systems) yang sederhana semuanya mendapat manfaat daripada pengesan yang berjalan pantas pada CPU standard.

Format INT8 ONNX juga memudahkan proses penggunaan (deployment). Anda tidak perlu memasang PyTorch atau TensorFlow pada peranti sasaran. Modul DNN OpenCV memuatkan model secara terus, yang mengekalkan saiz binari anda kecil dan pokok kebergantungan (dependency tree) anda ringkas.

Kesimpulannya

YuNet membuktikan bahawa pengesanan wajah tidak memerlukan perkakasan industri atau rangka kerja (framework) yang berat. Angkanya jelas: kurang daripada sepuluh milisaat untuk bingkai 720p, dan peningkatan jumlah pengesanan yang langsung serta boleh diramal apabila resolusi meningkat. Anda boleh memilih sama ada mahukan kelajuan maksimum pada resolusi sederhana atau liputan yang lebih luas pada skala yang lebih tinggi, dan model ini tidak akan menjejaskan prestasi anda disebabkan pilihan tersebut.

Jika anda sedang membina apa-apa yang melibatkan imej dunia nyata, jalankan langkah reproduksi di atas pada perkakasan anda sendiri. Uji ia dengan rakaman anda. Kemudian, selaraskan logik penukaran saiz anda agar sepadan dengan wajah yang perlu anda cari. Kelajuan hanya berguna apabila anda boleh mengarahkannya. YuNet memberikan anda kedua-duanya: kepantasan dan kawalan.