CenterFace Documentation
repository·master·Indexed 23 days ago
https://github.com/star-clouds/centerfaceAn anchor-free face detection and alignment method optimized for edge devices. CenterFace treats faces as points to balance high accuracy and low inference latency, offering a standard model (7.3MB) and a lightweight CenterFace-small version (2.3MB). The project provides implementations for MNN, NCNN, OpenCV C++, TensorRT, and Python.
What's inside CenterFace
- CenterFace is a practical, anchor-free face detection and alignment method designed specifically for edge devices. It has a small model size of approximately 7.3MB and treats faces as points for joint detection and alignment.
Overview of CenterFace face detection
masterCenterFace is an anchor-free face detection and alignment algorithm designed for practical use on edge devices. It treats faces as points rather than using traditional anchor boxes.
There are two primary model versions:
- CenterFace: A model with a size of 7.3M.
- CenterFace-small: A lightweight version with a size of 2.3M that maintains performance comparable to the standard CenterFace model.
Compare CenterFace accuracy and performance
masterCenterFace and CenterFace-small demonstrate high accuracy on the WIDER FACE dataset and low inference latency on NVIDIA hardware.
Accuracy (WIDER FACE val set):
- CenterFace: Easy (0.935), Medium (0.924), Hard (0.875)
- CenterFace-small: Easy (0.931), Medium (0.924), Hard (0.870)
Inference Latency (NVIDIA RTX 2080TI):
- CenterFace (640×480): 5.5ms
- CenterFace-small (640×480): 4.4ms
- CenterFace (1920×1080): 8.7ms
- CenterFace-small (1920×1080): 7.3ms
Note: For single-scale inference (SIO) on the val set, CenterFace achieves: 92.2% (Easy), 91.1% (Medium), and 78.2% (Hard).
Run the CenterFace TensorRT demo
masterTo run the provided demonstration script, navigate to the
prj-tensorrtdirectory and executedemo.pyusing Python. For more detailed instructions, refer to the external tutorials.cd CenterFace/prj-tensorrt python demo.pyRequirements for CenterFace with TensorRT
masterTo use the Python version of CenterFace with TensorRT acceleration, ensure your environment meets the following requirements:
- TensorRT: version 6.0.1 or higher
- Python: version 3.7
- OpenCV: installed and available in your environment
Requirements for CenterFace NCNN
masterTo build and run the C++ version of CenterFace with NCNN, you need the following dependencies installed on your system:
- ncnn: The core inference framework.
- opencv (optional): Required if you wish to use OpenCV-related features or if the specific build configuration depends on it.
Compile and run the CenterFace MNN project
masterFollow these steps to build the project using CMake and run the demo executable:
- Navigate to the project directory:
cd CenterFace/prj-mnn - Create a build directory and compile:
mkdir build && cd build && cmake .. && make -j3 - Run the demo by providing the path to the MNN models and the target image path:
./demo <model_directory> <image_path>
cd CenterFace/prj-mnn mkdir build && cd build && cmake .. && make -j3 ./demo ../../models/mnn your_image_path- Navigate to the project directory:
Configure MNN directory in CMakeLists.txt
masterBefore compiling, you must specify the path to your MNN installation in the
CMakeLists.txtfile. Locate line 4 and update theDIRvariable to point to your MNN directory.set (DIR /home/mirror/workspace/mnn)Build and run the CenterFace NCNN demo
masterFollow these steps to build the project using CMake and run the provided demo executable. Ensure you are in the
prj-ncnndirectory before starting.cd CenterFace/prj-ncnn mkdir build && cd build && cmake && make ./demo ../../models/ncnn your_image_pathRequirements for CenterFace with MNN
masterTo use the C++ version of CenterFace with MNN, you must have the following dependencies installed on your system:
mnnopencv(version 4.1.1 or compatible)
Build and run the CenterFace C++ demo
masterTo build the project and run the demonstration, follow these steps from the
prj-opencv-cppdirectory:- Create a build directory and compile using CMake and Make.
- Run the
./demoexecutable, providing the path to your ONNX models and the path to the image you wish to process.
cd CenterFace/prj-opencv-cpp mkdir build && cd build && cmake && make ./demo ../../models/onnx your_image_pathRequirements for CenterFace C++ with OpenCV
masterTo use the C++ implementation of CenterFace, you must have OpenCV installed. Specifically, you need version 3.4.2 or higher, and it must be compiled with thecv::dnnmodule enabled.