Skip to content

Replace dlib with MediaPipe for face detection and add ONNX export#7

Open
AmirhosseinSoltan wants to merge 3 commits into
rehg-lab:masterfrom
AmirhosseinSoltan:master
Open

Replace dlib with MediaPipe for face detection and add ONNX export#7
AmirhosseinSoltan wants to merge 3 commits into
rehg-lab:masterfrom
AmirhosseinSoltan:master

Conversation

@AmirhosseinSoltan

Copy link
Copy Markdown

What changed?

Great inference speed by:

  • Replaced dlib CNN face detector with MediaPipe FaceDetection
  • Added one-time ONNX export pipeline: PyTorch weights
  • Switched inference from PyTorch forward pass to ONNX Runtime CPUExecutionProvider
  • Added --onnx CLI argument to override the ONNX model path

Why?

The original pipeline was far too slow for real-time CPU inference. The dlib CNN face detector alone took 100–300 ms/frame — 3–10× the entire frame budget for 30 FPS — making the bottleneck the detector, not the ResNet. Replacing it with MediaPipe brings detection down to ~5–10 ms/frame. Exporting to ONNX reduces ResNet-50 inference time by ~2× and model size from 91 MB to ~23 MB, with negligible accuracy impact on a binary eye-contact score.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant