Table of contents
0 Preface
This time I will reproduce facenet-pytorch in face recognition for
reference:
Pytorch builds its own Facenet face recognition network (Bubbliiiiing deep learning tutorial)
https://gitee.com/xiaozhao123666/facenet-pytorch
https://gitee.com/xiaozhao123666/facenet-pytorch github.com/bubbliiiiing/facenet-pytorch
B station operation video:
https://www.bilibili.com/video/BV1MG411u7Dv/
https://www.bilibili.com/video/BV1RG411M7rX/
This time, the CPU of windows is used for reproduction
1 Build environment and project
Environment: python=3.7 torch1.2 torchvision0.4.0 cu92
Create a virtual environment face
# 创建虚拟环境face
conda create --name face python=3.7 -y
#激活环境
conda activate face
Download the face recognition project
git clone https://gitee.com/xiaozhao123666/facenet-pytorch.git
install torch
#搭建项目所需pytorch环境
#pip install torch==1.2.0+cu92 torchvision==0.4.0+cu92 -f https://download.pytorch.org/whl/torch_stable.html -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install torch==1.2.0+cu92 torchvision==0.4.0+cu92 -f https://download.pytorch.org/whl/torch_stable.html
install dependencies
# 进入项目,安装依赖
cd facenet-pytorch
pip install -r requirements.txt
2 Face prediction and result display
Store the following pictures under facenet-pytorch\img
In the picture above, 1_1, 1_2, and 1_3 are one person, and 2_1 is another person
. You can make this data by yourself, or download it from the link below (free, I set 0 download coupons):
https://download.csdn. net/download/WhiffeYF/87209609
Before starting the prediction, you need to change the cuda value of the facenet.py clock to False (so that the cpu is used for calculation instead of the GPU), as shown in the figure below.
start forecasting
python predict.py
Then you will see:
Input image_1 filename:
field, which is for you to enter the path of the first picture, and you need to enter two pictures in total.
The following is the test result