这是一个facenet-pytorch的库,可以用于训练自己的人脸识别模型。

Overview

Facenet:人脸识别模型在Pytorch当中的实现


目录

  1. 性能情况 Performance
  2. 所需环境 Environment
  3. 注意事项 Attention
  4. 文件下载 Download
  5. 预测步骤 How2predict
  6. 训练步骤 How2train
  7. 参考资料 Reference

性能情况

训练数据集 权值文件名称 测试数据集 输入图片大小 accuracy
CASIA-WebFace facenet_mobilenet.pth LFW 160x160 98.23%
CASIA-WebFace facenet_inception_resnetv1.pth LFW 160x160 98.78%

所需环境

pytorch==1.2.0

文件下载

已经训练好的facenet_mobilenet.pth和facenet_inception_resnetv1.pth可以在百度网盘下载。
链接: https://pan.baidu.com/s/1slUYdpskFpUX62WpJeLByA 提取码: fe1w

训练用的CASIA-WebFaces数据集以及评估用的LFW数据集可以在百度网盘下载。
链接: https://pan.baidu.com/s/1fhiHlylAFVoR43yfDbi4Ag 提取码: gkch

预测步骤

a、使用预训练权重

  1. 下载完库后解压,在model_data文件夹里已经有了facenet_mobilenet.pth,可直接运行predict.py输入:
img\1_001.jpg
img\1_002.jpg
  1. 也可以在百度网盘下载facenet_inception_resnetv1.pth,放入model_data,修改facenet.py文件的model_path后,输入:
img\1_001.jpg
img\1_002.jpg

b、使用自己训练的权重

  1. 按照训练步骤训练。
  2. 在facenet.py文件里面,在如下部分修改model_path和backbone使其对应训练好的文件;model_path对应logs文件夹下面的权值文件,backbone对应主干特征提取网络
_defaults = {
    "model_path"    : "model_data/facenet_mobilenet.pth",
    "input_shape"   : (160, 160, 3),
    "backbone"      : "mobilenet",
    "cuda"          : True,
}
  1. 运行predict.py,输入
img\1_001.jpg
img\1_002.jpg

训练步骤

  1. 本文使用如下格式进行训练。
|-datasets
    |-people0
        |-123.jpg
        |-234.jpg
    |-people1
        |-345.jpg
        |-456.jpg
    |-...
  1. 下载好数据集,将训练用的CASIA-WebFaces数据集以及评估用的LFW数据集,解压后放在根目录。
  2. 在训练前利用txt_annotation.py文件生成对应的cls_train.txt。
  3. 利用train.py训练facenet模型,训练前,根据自己的需要选择backbone,model_path和backbone一定要对应。
  4. 运行train.py即可开始训练。

评估步骤

  1. 下载好评估数据集,将评估用的LFW数据集,解压后放在根目录
  2. 在eval_LFW.py设置使用的主干特征提取网络和网络权值。
  3. 运行eval_LFW.py来进行模型准确率评估。

Reference

https://github.com/davidsandberg/facenet
https://github.com/timesler/facenet-pytorch

You might also like...
Comments
  • 训练过程经常遇到BrokenPipeError: [Errno 32] Broken pipe

    训练过程经常遇到BrokenPipeError: [Errno 32] Broken pipe

    Epoch 1/100: 100%|██████████| 583/583 [07:36<00:00, 1.07it/s, accuracy=0.89, lr=0.01, total_CE_loss=9.02, total_triple_loss=0.101]Traceback (most recent call last): File "/opt/vitis_ai/conda/envs/vitis-ai-optimizer_pytorch/lib/python3.7/multiprocessing/queues.py", line 242, in _feed send_bytes(obj) File "/opt/vitis_ai/conda/envs/vitis-ai-optimizer_pytorch/lib/python3.7/multiprocessing/connection.py", line 200, in send_bytes self._send_bytes(m[offset:offset + size]) File "/opt/vitis_ai/conda/envs/vitis-ai-optimizer_pytorch/lib/python3.7/multiprocessing/connection.py", line 404, in _send_bytes self._send(header + buf) File "/opt/vitis_ai/conda/envs/vitis-ai-optimizer_pytorch/lib/python3.7/multiprocessing/connection.py", line 368, in _send n = write(self._handle, buf) BrokenPipeError: [Errno 32] Broken pipe

    opened by jia0511 1
  • lfw数据集处理有什么区别? 精度目前97%

    lfw数据集处理有什么区别? 精度目前97%

    使用facenet_mobilenet.pth 在 LFW 数据集上,调整图片大小为 160x160 ,得到了0.97的精度,没有到| 98.23%,而在百度网盘提供的slfw数据上,精度可以到98%, 但是我看网页上提供的数据图片大小是96*112,请问下,LFW处理上应用什么其他方法吗?

    Test Epoch: [5888/6000 (96%)]: : 24it [00:32, 1.34s/it] Accuracy: 0.97383+-0.00675 Best_thresholds: 1.16000 Validation rate: 0.82100+-0.03127 @ FAR=0.00100

    opened by xiaomujiang 1
Releases(v2.0)
Owner
Bubbliiiing
Bubbliiiing
Google Landmark Recogntion and Retrieval 2021 Solutions

Google Landmark Recogntion and Retrieval 2021 Solutions In this repository you can find solution and code for Google Landmark Recognition 2021 and Goo

Vadim Timakin 5 Nov 25, 2022
This is a re-implementation of TransGAN: Two Pure Transformers Can Make One Strong GAN (CVPR 2021) in PyTorch.

TransGAN: Two Transformers Can Make One Strong GAN [YouTube Video] Paper Authors: Yifan Jiang, Shiyu Chang, Zhangyang Wang CVPR 2021 This is re-implem

Ahmet Sarigun 79 Jan 05, 2023
NuPIC Studio is an all­-in-­one tool that allows users create a HTM neural network from scratch

NuPIC Studio is an all­-in-­one tool that allows users create a HTM neural network from scratch, train it, collect statistics, and share it among the members of the community. It is not just a visual

HTM Community 93 Sep 30, 2022
PoseViz – Multi-person, multi-camera 3D human pose visualization tool built using Mayavi.

PoseViz – 3D Human Pose Visualizer Multi-person, multi-camera 3D human pose visualization tool built using Mayavi. As used in MeTRAbs visualizations.

István Sárándi 79 Dec 30, 2022
Code for paper "Context-self contrastive pretraining for crop type semantic segmentation"

Code for paper "Context-self contrastive pretraining for crop type semantic segmentation" Setting up a python environment Follow the instruction in ht

Michael Tarasiou 11 Oct 09, 2022
Delta Conformity Sociopatterns Analysis - Delta Conformity Sociopatterns Analysis

Delta_Conformity_Sociopatterns_Analysis ∆-Conformity is a local homophily measur

2 Jan 09, 2022
The source code of CVPR 2019 paper "Deep Exemplar-based Video Colorization".

Deep Exemplar-based Video Colorization (Pytorch Implementation) Paper | Pretrained Model | Youtube video 🔥 | Colab demo Deep Exemplar-based Video Col

Bo Zhang 253 Dec 27, 2022
Compares various time-series feature sets on computational performance, within-set structure, and between-set relationships.

feature-set-comp Compares various time-series feature sets on computational performance, within-set structure, and between-set relationships. Reposito

Trent Henderson 7 May 25, 2022
HSC4D: Human-centered 4D Scene Capture in Large-scale Indoor-outdoor Space Using Wearable IMUs and LiDAR. CVPR 2022

HSC4D: Human-centered 4D Scene Capture in Large-scale Indoor-outdoor Space Using Wearable IMUs and LiDAR. CVPR 2022 [Project page | Video] Getting sta

51 Nov 29, 2022
Official implementation of "One-Shot Voice Conversion with Weight Adaptive Instance Normalization".

One-Shot Voice Conversion with Weight Adaptive Instance Normalization By Shengjie Huang, Yanyan Xu*, Dengfeng Ke*, Mingjie Chen, Thomas Hain. This rep

31 Dec 07, 2022
GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond

GCNet for Object Detection By Yue Cao, Jiarui Xu, Stephen Lin, Fangyun Wei, Han Hu. This repo is a official implementation of "GCNet: Non-local Networ

Jerry Jiarui XU 1.1k Dec 29, 2022
Learning to Self-Train for Semi-Supervised Few-Shot

Learning to Self-Train for Semi-Supervised Few-Shot Classification This repository contains the TensorFlow implementation for NeurIPS 2019 Paper "Lear

86 Dec 29, 2022
This repo is the official implementation of "L2ight: Enabling On-Chip Learning for Optical Neural Networks via Efficient in-situ Subspace Optimization".

L2ight is a closed-loop ONN on-chip learning framework to enable scalable ONN mapping and efficient in-situ learning. L2ight adopts a three-stage learning flow that first calibrates the complicated p

Jiaqi Gu 9 Jul 14, 2022
(3DV 2021 Oral) Filtering by Cluster Consistency for Large-Scale Multi-Image Matching

Scalable Cluster-Consistency Statistics for Robust Multi-Object Matching (3DV 2021 Oral Presentation) Filtering by Cluster Consistency (FCC) is a very

Yunpeng Shi 11 Sep 28, 2022
Tensorflow implementation of Human-Level Control through Deep Reinforcement Learning

Human-Level Control through Deep Reinforcement Learning Tensorflow implementation of Human-Level Control through Deep Reinforcement Learning. This imp

Devsisters Corp. 2.4k Dec 26, 2022
Multi-scale discriminator feature-wise loss function

Multi-Scale Discriminative Feature Loss This repository provides code for Multi-Scale Discriminative Feature (MDF) loss for image reconstruction algor

Graphics and Displays group - University of Cambridge 76 Dec 12, 2022
A Java implementation of the experiments for the paper "k-Center Clustering with Outliers in Sliding Windows"

OutliersSlidingWindows A Java implementation of the experiments for the paper "k-Center Clustering with Outliers in Sliding Windows" Dataset generatio

PaoloPellizzoni 0 Jan 05, 2022
Python project to take sound as input and output as RGB + Brightness values suitable for DMX

sound-to-light Python project to take sound as input and output as RGB + Brightness values suitable for DMX Current goals: Get one pixel working: Vary

Bobby Cox 1 Nov 17, 2021
这是一个mobilenet-yolov4-lite的库,把yolov4主干网络修改成了mobilenet,修改了Panet的卷积组成,使参数量大幅度缩小。

YOLOV4:You Only Look Once目标检测模型-修改mobilenet系列主干网络-在Keras当中的实现 2021年2月8日更新: 加入letterbox_image的选项,关闭letterbox_image后网络的map一般可以得到提升。

Bubbliiiing 65 Dec 01, 2022
[ICCV2021] 3DVG-Transformer: Relation Modeling for Visual Grounding on Point Clouds

3DVG-Transformer This repository is for the ICCV 2021 paper "3DVG-Transformer: Relation Modeling for Visual Grounding on Point Clouds" Our method "3DV

22 Dec 11, 2022