人脸检测模型
In this article, we will see how to detect faces using Tensorflow models without using libraries like Firebase in Flutter, the process is based on the BlazeFace model, a lightweight and well-performing face detector tailored for mobile GPU inference.
在本文中,我们将了解如何在不使用Flutter之类的库的情况下使用Tensorflow模型检测人脸,该过程基于BlazeFace模型(一种针对移动GPU推理量身定制的轻巧且性能良好的面部检测器)。
介绍 (Intro)
BlazeFace, a lightweight and well-performing face detector tailored for mobile GPU inference. It runs at a speed of 200–1000+ FPS on flagship devices. This super-realtime performance enables it to be applied to any augmented reality pipeline that requires an accurate facial region of interest as an input for task-specific models, such as 2D/3D facial keypoint or geometry estimation, facial features or expression classification, and face region segmentation.
BlazeFace是专为移动GPU推理量身定制的轻巧性能良好的面部检测器。 在旗舰设备上,它以200–1000 + FPS的速度运行。 这种超实时性能使其可以应用于需要准确的感兴趣面部区域作为特定于任务的模型(例如2D / 3D面部关键点或几何估计,面部特征或表情分类,以及脸部区域分割。
工作流程 (Workflow)
Get frames by camera plugin and parse planes
通过相机插件获取帧并解析平面
Create and initialize face detection model using tflite_flutter.
使用tflite_flutter创建和初始化人脸检测模型。
- Create functions for parse inference results and get the coordinates of the faces. 创建用于解析推理结果的函数并获取人脸的坐标。
实作 (Implementation)
In this story we will only focus on the handling of tensors and initialization of the model, the installation of dependencies can be done with the help of the corresponding readme of the libraries.
在这个故事中,我们仅关注张量的处理和模型的初始化,依赖项的安装可以在相应的库自述文件的帮助下完成。
Step 1 — Model declaration
第1步-模型声明
Get BlazeFace model and put in assets folder.
获取BlazeFace模型并将其放入资产文件夹。
We will start by defining each of the models necessary for the processing of the results produced by the model:
我们将首先定义处理模型产生的结果所需的每个模型:
This class contains the necessary characteristics to be able to limit the results of the model, as well as properties or conditionals when we handle the image</