| --- |
| license: bsl-1.0 |
| pipeline_tag: image-feature-extraction |
| tags: |
| - code |
| --- |
| # Insightface |
| 基于Insightface的人脸识别Pipeline,使用其buffalo_l系列模型中的人脸检测+定点模型,人脸属性模型,人脸特征提取模型实现人脸识别,支持650N系列平台的1v1人脸比对和1vN人脸识别。 |
| |
| 支持芯片: |
| - AX650N |
| |
| 支持硬件 |
| |
| - [M4N-Dock(爱芯派Pro)](https://wiki.sipeed.com/hardware/zh/maixIV/m4ndock/m4ndock.html) |
| - [M.2 Accelerator card](https://axcl-docs.readthedocs.io/zh-cn/latest/doc_guide_hardware.html) |
| |
| 原始模型请参考 |
| - [Insightface Github](https://github.com/deepinsight/insightface) |
| |
| ## 性能对比 |
| |
| | Models |input size | Latency (ms) | CMM Usage (MB) | |
| | --------------|------- | ---------------------- | -------------- | |
| | det_10g |640x640 |6.947 | 14.0 | |
| | genderage |96x96 |0.295 | 0.62 | |
| | w600k_r50 |112x112|3.993 | 44.0 | |
| |
| ## 模型转换 |
| - 模型转换工具链[Pulsar2](https://huggingface.co/AXERA-TECH/Pulsar2) |
| - 转换文档[TODO] |
| |
| ## 环境准备 |
| - NPU Python API: [pyaxengine](https://github.com/AXERA-TECH/pyaxengine) |
| |
| 安装需要的python库 |
| ```pip install -r requirements.txt``` |
| |
| ## 运行(算力卡版本) |
| |
| ```bash |
| (insightface) axera@dell:~/insightface/ax$ python insightface_pipeline.py -h |
| [INFO] Available providers: ['AXCLRTExecutionProvider'] |
| usage: insightface_pipeline.py [-h] [--model_path MODEL_PATH] [--type TYPE] [--gallery_path GALLERY_PATH] [--query_path QUERY_PATH] [--draw] |
| |
| Face Recognition Pipeline Example |
| |
| options: |
| -h, --help show this help message and exit |
| --model_path, -m MODEL_PATH |
| Path to the model directory |
| --type, -t TYPE Type of operation: 1: 1v1 compare, 2: 1vN recognize |
| --gallery_path, -g GALLERY_PATH |
| Path to the gallery image for image file |
| --query_path, -q QUERY_PATH |
| Path to the query image |
| --draw, -d Whether to draw results on the image |
| |
| |
| (insightface) axera@dell:~/insightface/ax$ python insightface_pipeline.py -g ./gallery_imgs/ -d -t 1 |
| [INFO] Available providers: ['AXCLRTExecutionProvider'] |
| ModelRouter ./models/buffalo_l/1k3d68.axmodel |
| [INFO] Using provider: AXCLRTExecutionProvider |
| [INFO] SOC Name: AX650N |
| [INFO] VNPU type: VNPUType.DISABLED |
| [INFO] Compiler version: 5.0-patch1-dirty 5cf5ab99-dirty |
| Applied providers: AXCLRTExecutionProvider, with options: None |
| model not recognized: ./models/buffalo_l/1k3d68.axmodel |
| ModelRouter ./models/buffalo_l/2d106det.axmodel |
| [INFO] Using provider: AXCLRTExecutionProvider |
| [INFO] SOC Name: AX650N |
| [INFO] VNPU type: VNPUType.DISABLED |
| [INFO] Compiler version: 5.0-patch1-dirty 5cf5ab99-dirty |
| Applied providers: AXCLRTExecutionProvider, with options: None |
| model not recognized: ./models/buffalo_l/2d106det.axmodel |
| ModelRouter ./models/buffalo_l/det_10g.axmodel |
| [INFO] Using provider: AXCLRTExecutionProvider |
| [INFO] SOC Name: AX650N |
| [INFO] VNPU type: VNPUType.DISABLED |
| [INFO] Compiler version: 5.0-patch1-dirty 5cf5ab99-dirty |
| Applied providers: AXCLRTExecutionProvider, with options: None |
| find model: ./models/buffalo_l/det_10g.axmodel detection [1, 640, 640, 3] 0.0 1.0 |
| ModelRouter ./models/buffalo_l/genderage.axmodel |
| [INFO] Using provider: AXCLRTExecutionProvider |
| [INFO] SOC Name: AX650N |
| [INFO] VNPU type: VNPUType.DISABLED |
| [INFO] Compiler version: 5.0-patch1-dirty 5cf5ab99-dirty |
| Applied providers: AXCLRTExecutionProvider, with options: None |
| find model: ./models/buffalo_l/genderage.axmodel genderage [1, 96, 96, 3] 0.0 1.0 |
| ModelRouter ./models/buffalo_l/w600k_r50.axmodel |
| [INFO] Using provider: AXCLRTExecutionProvider |
| [INFO] SOC Name: AX650N |
| [INFO] VNPU type: VNPUType.DISABLED |
| [INFO] Compiler version: 5.0-patch1-dirty 5cf5ab99-dirty |
| Applied providers: AXCLRTExecutionProvider, with options: None |
| find model: ./models/buffalo_l/w600k_r50.axmodel recognition [1, 112, 112, 3] 0.0 1.0 |
| set det-size: (640, 640) |
| warning: det_size is already set in detection model, ignore |
| 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<00:00, 12.49it/s] |
| 特征库构建完成,包含以下人员: ['wade', 'kobe'] |
| 请输入查询图像路径 (输入 'exit' 退出): |
| ./query/wade2.jpg |
| 识别结果: wade, 相似度(0-1): 0.5860 |
| 结果已保存到 ./output/wade2.jpg |
| 请输入查询图像路径 (输入 'exit' 退出): |
| ./query/ssd_horse.jpg |
| 识别结果: Unknown, 相似度(0-1): 0.0135 |
| 结果已保存到 ./output/ssd_horse.jpg |
| 请输入查询图像路径 (输入 'exit' 退出): |
| exit |
|
|
| ``` |
| |
| 保存结果在 `./output` 目录下: |
|  |
|  |