基于 PyTorch 的人脸识别系统,使用CNN和VIT。
facerecognize/
├── model.py # ConvNet 模型
├── modelv2.py # Facenet 模型
├── mobilefacenet.py # MobileFaceNet 模型
├── vit.py # Vision Transformer 模型
├── train.py # 模型训练脚本
├── finetune.py # MobileFaceNet微调脚本
├── compare.py # 两张人脸图片比对
├── realtime_face_detection.py # 实时人脸检测
├── lfw_eval*.py # LFW 数据集评估脚本
├── export_model.py # 模型导出脚本
├── facecrop.py # 人脸裁剪工具
├── C++/ # C++ 演示代码
│ ├── showcase.cpp
│ └── test_vit.cpp
└── face_detector/ # 人脸检测模型(opencv)
├── deploy.prototxt
└── res10_300x300_ssd_iter_140000.caffemodel
| 模型 | 特点 |
|---|---|
| ConvNet | 第一代卷积神经网络 |
| MobileFaceNet | 对照组模型 |
| ViT | Vision Transformer微调模型 |
| Facenet | 第二代卷积神经网络 |
- Python 3.10
- PyTorch
- OpenCV
- torchvision
- Numpy
- PIL
pip install torch torchvision opencv-python numpy pillowpython realtime_face_detection.pypython train.pypython lfw_eval.pybest_model.pth- FaceNet 最佳模型best_model_origin.pth- 原始ConvNet模型best_vit_model.pth- ViT 最佳模型mobilefacenet.ckpt- MobileFaceNet 模型mobilefacenet_finetuned.ckpt- MobileFaceNet 微调模型
- 安装cmake和一个C++编译器,我使用的是VS
- 从pytorch.org下载libtorch,解压到C++/libtorch下
- 下载opencv,解压到C++/opencv下
- 使用cmake编译
项目使用 CASIA FaceV5 数据集进行训练,评估采用 LFW 数据集。