AddFaceTo3588/使用指南.md
2026-03-02 18:16:02 +08:00

62 lines
1.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 人脸库生成工具 - 使用指南
## 1. 准备照片
创建目录结构:
```
数据集目录/
张三/
001.jpg
002.jpg
李四/
a.png
b.png
```
- 每人一个文件夹,文件夹名就是人名
- 每人建议放 3-10 张照片
- 支持 jpg/png/bmp 格式
## 2. 生成人脸库
在项目目录打开 PowerShell运行
```powershell
build_gallery.bat `
--dataset "D:\你的数据集目录" `
--db_out "D:\输出目录\face_gallery.db" `
--det_model "./models/RetinaFace_mobile320.onnx" `
--recog_model "./models/mobilefacenet_arcface_prenorm.onnx" `
--det_outputs_config "./models/retinaface_mobile320_config.json"
```
只需修改 `D:\你的数据集目录``D:\输出目录` 两个路径即可。
## 3. 查看结果
生成成功后,会输出统计信息:
- 总人数、成功入库人数
- 每人使用的照片数
- 失败原因统计
生成的 `face_gallery.db` 就是最终的人脸库文件。
---
## 可选参数
| 参数 | 默认值 | 说明 |
|------|--------|------|
| `--max_imgs_per_person` | 10 | 每人最多用几张照片 |
| `--min_face_size` | 80 | 人脸最小尺寸(像素) |
| `--pick_face` | largest | 多脸时选哪个largest(最大)/first(第一个)/highest_score(置信度最高) |
## 测试单张图片
修改 `testpic.py` 第 9 行的 `INPUT_IMAGE = "003.jpg"` 为你的图片路径,然后运行:
```powershell
testpic.bat
```
会生成对齐后的图片和特征向量到 `debug_output/` 目录。