
Security News
OWASP 2025 Top 10 Adds Software Supply Chain Failures, Ranked Top Community Concern
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.
insightface-paddle
Advanced tools
简体中文 | English
InsightFacePaddle is an open source deep face detection and recognition toolkit, powered by PaddlePaddle. InsightFacePaddle provide three related pretrained models now, include BlazeFace for face detection, ArcFace and MobileFace for face recognition.
PaddleInfernence.For face detection task, on WiderFace dataset, the following table shows mAP, speed and time cost for BlazeFace.
| Model structure | Model size | WiderFace mAP | CPU time cost | GPU time cost |
|---|---|---|---|---|
| BlazeFace-FPN-SSH-Paddle | 0.65MB | 0.9187/0.8979/0.8168 | 31.7ms | 5.6ms |
| RetinaFace | 1.68MB | -/-/0.825 | 182.0ms | 17.4ms |
For face recognition task, on MSAM dataset, the following table shows precision, speed and time cost for MobileFaceNet.
| Model structure | lfw | cfp_fp | agedb30 | CPU time cost | GPU time cost |
|---|---|---|---|---|---|
| MobileFaceNet-Paddle | 0.9945 | 0.9343 | 0.9613 | 4.3ms | 2.3ms |
| MobileFaceNet-mxnet | 0.9950 | 0.8894 | 0.9591 | 7.3ms | 4.7ms |
Benchmark environment:
Note: Performance of RetinaFace is tested using script test.py. The image shape is modified to 640x480 here. Performance of MobileFaceNet-mxnet is tested using script verification.py.
One example result predicted by InsightFacePaddle is as follow. Please refer to the Demo for more.
Scan the QR code below with your QQ (QQ group number: 705899115) to discuss more about deep learning together.
PaddlePaddle 2.1 or later is required for InsightFacePaddle. You can use the following steps to install PaddlePaddle.
# for GPU
pip3 install paddlepaddle-gpu
# for CPU
pip3 install paddlepaddle
For more details about installation. please refer to PaddlePaddle.
InsightFacePaddle dependencies are listed in requirements.txt, you can use the following command to install the dependencies.
pip3 install --upgrade -r requirements.txt -i https://mirror.baidu.com/pypi/simple
InsightFacePaddlepip to install the lastest version InsightFacePaddle from pypi.pip3 install --upgrade insightface-paddle
cd ./InsightFacePaddle
python3 setup.py bdist_wheel
pip3 install dist/*
InsightFacePaddle support two ways of use, including Commad Line and Python API.
You can use InsightFacePaddle in Command Line.
You can get the help about InsightFacePaddle by following command.
insightfacepaddle -h
The args are as follows:
| args | type | default | help |
|---|---|---|---|
| det_model | str | BlazeFace | The detection model. |
| rec_model | str | MobileFace | The recognition model. |
| use_gpu | bool | True | Whether use GPU to predict. Default by True. |
| enable_mkldnn | bool | False | Whether use MKLDNN to predict, valid only when --use_gpu is False. Default by False. |
| cpu_threads | int | 1 | The num of threads with CPU, valid only when --use_gpu is False and --enable_mkldnn is True. Default by 1. |
| input | str | - | The path of video to be predicted. Or the path or directory of image file(s) to be predicted. |
| output | str | - | The directory to save prediction result. |
| det | bool | False | Whether to detect. |
| det_thresh | float | 0.8 | The threshold of detection postprocess. Default by 0.8. |
| rec | bool | False | Whether to recognize. |
| index | str | - | The path of index file. |
| cdd_num | int | 5 | The number of candidates in the recognition retrieval. Default by 5. |
| rec_thresh | float | 0.45 | The threshold of match in recognition, use to remove candidates with low similarity. Default by 0.45. |
| max_batch_size | int | 1 | The maxium of batch_size to recognize. Default by 1. |
| build_index | str | - | The path of index to be build. |
| img_dir | str | - | The img(s) dir used to build index. |
| label | str | - | The label file path used to build index. |
If use recognition, before start predicting, you have to build the index.
insightfacepaddle --build_index ./demo/friends/index.bin --img_dir ./demo/friends/gallery --label ./demo/friends/gallery/label.txt
An example used to build index is as follows:
Use the image below to predict:
The prediction command:
insightfacepaddle --det --input ./demo/friends/query/friends1.jpg --output ./output
The result is under the directory ./output:
insightfacepaddle --det --input ./demo/friends/query/friends.mp4 --output ./output
Use the image below to predict:
The prediction command:
insightfacepaddle --rec --index ./demo/friends/index.bin --input ./demo/friends/query/Rachel.png
The result is output in the terminal:
INFO:root:File: Rachel., predict label(s): ['Rachel']
Use the image below to predict:
The prediction command:
insightfacepaddle --det --rec --index ./demo/friends/index.bin --input ./demo/friends/query/friends2.jpg --output ./output
The result is under the directory ./output:
insightfacepaddle --det --rec --index ./demo/friends/index.bin --input ./demo/friends/query/friends.mp4 --output ./output
You can use InsightFacePaddle in Python. First, import InsightFacePaddle and logging because InsightFacePaddle using that to control log.
import insightface_paddle as face
import logging
logging.basicConfig(level=logging.INFO)
parser = face.parser()
help_info = parser.print_help()
print(help_info)
parser = face.parser()
args = parser.parse_args()
args.build_index = "./demo/friends/index.bin"
args.img_dir = "./demo/friends/gallery"
args.label = "./demo/friends/gallery/label.txt"
predictor = face.InsightFace(args)
predictor.build_index()
parser = face.parser()
args = parser.parse_args()
args.det = True
args.output = "./output"
input_path = "./demo/friends/query/friends1.jpg"
predictor = face.InsightFace(args)
res = predictor.predict(input_path)
print(next(res))
import cv2
parser = face.parser()
args = parser.parse_args()
args.det = True
args.output = "./output"
path = "./demo/friends/query/friends1.jpg"
img = cv2.imread(path)[:, :, ::-1]
predictor = face.InsightFace(args)
res = predictor.predict(img)
print(next(res))
The prediction result saved as "./output/tmp.png".
parser = face.parser()
args = parser.parse_args()
args.det = True
args.output = "./output"
input_path = "./demo/friends/query/friends.mp4"
predictor = face.InsightFace(args)
res = predictor.predict(input_path)
for _ in res:
print(_)
parser = face.parser()
args = parser.parse_args()
args.rec = True
args.index = "./demo/friends/index.bin"
input_path = "./demo/friends/query/Rachel.png"
predictor = face.InsightFace(args)
res = predictor.predict(input_path, print_info=True)
next(res)
import cv2
parser = face.parser()
args = parser.parse_args()
args.rec = True
args.index = "./demo/friends/index.bin"
path = "./demo/friends/query/Rachel.png"
img = cv2.imread(path)[:, :, ::-1]
predictor = face.InsightFace(args)
res = predictor.predict(img, print_info=True)
next(res)
parser = face.parser()
args = parser.parse_args()
args.det = True
args.rec = True
args.index = "./demo/friends/index.bin"
args.output = "./output"
input_path = "./demo/friends/query/friends2.jpg"
predictor = face.InsightFace(args)
res = predictor.predict(input_path, print_info=True)
next(res)
import cv2
parser = face.parser()
args = parser.parse_args()
args.det = True
args.rec = True
args.index = "./demo/friends/index.bin"
args.output = "./output"
path = "./demo/friends/query/friends2.jpg"
img = cv2.imread(path)[:, :, ::-1]
predictor = face.InsightFace(args)
res = predictor.predict(img, print_info=True)
next(res)
The prediction result saved as "./output/tmp.png".
parser = face.parser()
args = parser.parse_args()
args.det = True
args.rec = True
args.index = "./demo/friends/index.bin"
args.output = "./output"
input_path = "./demo/friends/query/friends.mp4"
predictor = face.InsightFace(args)
res = predictor.predict(input_path, print_info=True)
for _ in res:
pass
FAQs
A toolkit for face detection and recognition powered by PaddlePaddle.
We found that insightface-paddle demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.