axinc-ai
Published in

axinc-ai

BlazeFace : A Machine Learning Model for Fast Detection of Face Positions and Key Points

This is an introduction to「BlazeFace」, a machine learning model that can be used with ailia SDK. You can easily use this model to create AI applications using ailia SDK as well as many other ready-to-use ailia MODELS.

Overview

BlazeFace is a machine learning model developed by Google to rapidly detect the location and keypoints of faces.

The position of the face and the keypoints of the face can be obtained simultaneously. There are six key points: eyes, nose, ears, and mouth. It is also possible to detect multiple people at the same time.

BlazeFace inference result

Originally the model was for MediaPipe provided by Google, but a version converted to Pytorch that ailia SDK can use is also provided in the repository below.

Architecture

BlazeFace is designed to perform very fast inference on mobile GPUs. Specifically, it runs nearly 2.3 times faster than MobileNetV2-SSD.

(Source:https://arxiv.org/abs/1907.05047

BlazeFace uses an improved network based on MobileNet. Given the fact that a 3x3 depthwise convolution of a 56x56x128 tensor takes 0.07ms on iPhoneX, while the subsequent 1x1 convolution from 128 to 128 channels is 4.3× slower at 0.3ms, it shows that increasing the kernel size of the depthwise part is relatively cheap. Therefore the authors propose to replace 3x3 depthwise convolution with 5x5 depthwise convolution, making the model shallower to speed up the process.

(Source:https://arxiv.org/abs/1907.05047

In addition, there is a fixed cost for dispatching a particular layer computation for shaders on GPUs. For example with MobileNetV1, out of 4.9 ms of inference time, only 3.9 ms are spent in actual GPU shader computation. In order to reduce this cost of dispatch for anchor computation, the authors adopted an alternative anchor scheme to reduce the number of layers.

(Source:https://arxiv.org/abs/1907.05047

Usage

To use BlazeFace with ailia SDK, use the following sample.

You can use the following command to run BlazeFace on the web camera video stream.

$ python3 blazeface.py -v 0

The command below can be used to run BlazeFace on an image.

$ python3 blazeface.py -i person.jpg

Related topic

ax Inc. has developed ailia SDK, which enables cross-platform, GPU-based rapid inference.

ax Inc. provides a wide range of services from consulting and model creation, to the development of AI-based applications and SDKs. Feel free to contact us for any inquiry.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store