{"id":15645087,"url":"https://github.com/yeyupiaoling/pytorch-mobilefacenet","last_synced_at":"2025-06-25T15:09:26.169Z","repository":{"id":50648875,"uuid":"369476866","full_name":"yeyupiaoling/Pytorch-MobileFaceNet","owner":"yeyupiaoling","description":"Pytorch实现的人脸识别明细MobileFaceNet模型，在预测使用MTCNN检测人脸，然后使用MobileFaceNet模型识别。","archived":false,"fork":false,"pushed_at":"2021-11-03T07:34:18.000Z","size":12371,"stargazers_count":145,"open_issues_count":0,"forks_count":33,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T05:55:19.351Z","etag":null,"topics":["face-recognition","mobilefacenet","mtcnn","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yeyupiaoling.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-21T09:03:47.000Z","updated_at":"2025-04-08T03:48:32.000Z","dependencies_parsed_at":"2022-08-24T18:31:29.172Z","dependency_job_id":null,"html_url":"https://github.com/yeyupiaoling/Pytorch-MobileFaceNet","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yeyupiaoling/Pytorch-MobileFaceNet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeyupiaoling%2FPytorch-MobileFaceNet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeyupiaoling%2FPytorch-MobileFaceNet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeyupiaoling%2FPytorch-MobileFaceNet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeyupiaoling%2FPytorch-MobileFaceNet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yeyupiaoling","download_url":"https://codeload.github.com/yeyupiaoling/Pytorch-MobileFaceNet/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yeyupiaoling%2FPytorch-MobileFaceNet/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261897033,"owners_count":23226650,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["face-recognition","mobilefacenet","mtcnn","pytorch"],"created_at":"2024-10-03T12:04:28.504Z","updated_at":"2025-06-25T15:09:25.812Z","avatar_url":"https://github.com/yeyupiaoling.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MobileFaceNet\n\n本项目参考了[ArcFace](https://arxiv.org/abs/1801.07698)的损失函数结合MobileNet，意在开发一个模型较小，但识别准确率较高且推理速度快的一种人脸识别项目，该项目训练数据使用emore数据集，一共有85742个人，共5822653张图片，使用lfw-align-128数据集作为测试数据。\n\n# 数据集准备\n本项目提供了标注文件，存放在`dataset`目录下，解压即可。另外需要下载下面这两个数据集，下载完解压到`dataset`目录下。\n - emore数据集[百度网盘](https://pan.baidu.com/s/1eXohwNBHbbKXh5KHyItVhQ)\n - lfw-align-128下载地址：[百度网盘](https://pan.baidu.com/s/1tFEX0yjUq3srop378Z1WMA) 提取码：b2ec\n\n然后执行下面命令，将提取人脸图片到`dataset/images`，并把整个数据集打包为二进制文件，这样可以大幅度的提高训练时数据的读取速度。\n```shell\npython create_dataset.py\n```\n\n# 训练\n\n执行`train.py`即可，更多训练参数请查看代码。\n```shell\npython train.py\n```\n\n训练输出如下：\n```\n[2021-11-03 15:18:28.813591] Train epoch 9, batch: 6100/90979, loss: 1.215695, accuracy: 0.859375, lr: 0.000107, eta: 5 days, 5:28:26\n[2021-11-03 15:18:37.044353] Train epoch 9, batch: 6200/90979, loss: 0.908210, accuracy: 0.859375, lr: 0.000107, eta: 5 days, 6:35:02\n[2021-11-03 15:18:45.229030] Train epoch 9, batch: 6300/90979, loss: 0.964092, accuracy: 0.875000, lr: 0.000107, eta: 5 days, 9:17:21\n[2021-11-03 15:18:53.449567] Train epoch 9, batch: 6400/90979, loss: 1.208947, accuracy: 0.828125, lr: 0.000107, eta: 5 days, 12:41:06\n[2021-11-03 15:19:01.682437] Train epoch 9, batch: 6500/90979, loss: 1.081449, accuracy: 0.875000, lr: 0.000107, eta: 5 days, 10:29:44\n[2021-11-03 15:19:09.895995] Train epoch 9, batch: 6600/90979, loss: 1.277803, accuracy: 0.828125, lr: 0.000107, eta: 5 days, 12:29:05\n[2021-11-03 15:19:18.086872] Train epoch 9, batch: 6700/90979, loss: 1.308692, accuracy: 0.828125, lr: 0.000107, eta: 5 days, 7:23:03\n[2021-11-03 15:19:26.306897] Train epoch 9, batch: 6800/90979, loss: 1.474561, accuracy: 0.781250, lr: 0.000107, eta: 5 days, 8:20:23\n[2021-11-03 15:19:34.528685] Train epoch 9, batch: 6900/90979, loss: 1.295028, accuracy: 0.812500, lr: 0.000107, eta: 5 days, 5:54:56\n[2021-11-03 15:19:42.736712] Train epoch 9, batch: 7000/90979, loss: 1.474828, accuracy: 0.812500, lr: 0.000107, eta: 5 days, 8:32:33\n```\n\n# 评估\n\n执行`eval.py`即可，更多训练参数请查看代码。\n```shell\npython eval.py\n```\n\n# 预测\n\n本项目已经不教提供了模预测，模型文件可以直接用于预测。在执行预测之前，先要在face_db目录下存放人脸图片，每张图片只包含一个人脸，并以该人脸的名称命名，这建立一个人脸库。之后的识别都会跟这些图片对比，找出匹配成功的人脸。这里使用的人脸检测是MTCNN模型，这个模型具有速度快，模型小的特点，源码地址：[Pytorch-MTCNN](https://github.com/yeyupiaoling/Pytorch-MTCNN)\n\n如果是通过图片路径预测的，请执行下面命令。\n```shell\npython infer.py --image_path=temp/test.jpg\n```\n日志输出如下：\n```\n人脸检测时间：38ms\n人脸识别时间：11ms\n人脸对比结果： [('迪丽热巴', 0.7030987), ('杨幂', 0.36442137)]\n人脸对比结果： [('杨幂', 0.63616204), ('迪丽热巴', 0.3101096)]\n预测的人脸位置： [[272, 67, 328, 118, 1], [156, 80, 215, 134, 1]]\n识别的人脸名称： ['迪丽热巴', '杨幂']\n总识别时间：82ms\n```\n![识别结果](./dataset/result.jpg)\n\n如果是通过相机预测的，请执行下面命令。\n```shell\npython infer_camera.py --camera_id=0\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyeyupiaoling%2Fpytorch-mobilefacenet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyeyupiaoling%2Fpytorch-mobilefacenet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyeyupiaoling%2Fpytorch-mobilefacenet/lists"}