增加快速运行命令

This commit is contained in:
tian 2026-03-02 18:16:02 +08:00
parent cf170b4284
commit 3ea3f9069f
3 changed files with 67 additions and 0 deletions

3
build_gallery.bat Normal file
View File

@ -0,0 +1,3 @@
@echo off
REM 使用项目虚拟环境运行 build_gallery.py
.venv\Scripts\python.exe build_gallery.py %*

3
testpic.bat Normal file
View File

@ -0,0 +1,3 @@
@echo off
REM 使用项目虚拟环境运行 testpic.py
.venv\Scripts\python.exe testpic.py

61
使用指南.md Normal file
View File

@ -0,0 +1,61 @@
# 人脸库生成工具 - 使用指南
## 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/` 目录。