这是一个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
Official DGL implementation of "Rethinking High-order Graph Convolutional Networks"

SE Aggregation This is the implementation for Rethinking High-order Graph Convolutional Networks. Here we show the codes for citation networks as an e

Tianqi Zhang (张天启) 32 Jul 19, 2022
NeRD: Neural Reflectance Decomposition from Image Collections

NeRD: Neural Reflectance Decomposition from Image Collections Project Page | Video | Paper | Dataset Implementation for NeRD. A novel method which dec

Computergraphics (University of Tübingen) 195 Dec 29, 2022
Unofficial PyTorch Implementation of "DOLG: Single-Stage Image Retrieval with Deep Orthogonal Fusion of Local and Global Features"

Pytorch Implementation of Deep Orthogonal Fusion of Local and Global Features (DOLG) This is the unofficial PyTorch Implementation of "DOLG: Single-St

DK 96 Jan 06, 2023
Organseg dags - The repository contains the codebase for multi-organ segmentation with directed acyclic graphs (DAGs) in CT.

Organseg dags - The repository contains the codebase for multi-organ segmentation with directed acyclic graphs (DAGs) in CT.

yzf 1 Jun 12, 2022
A Python library for working with arbitrary-dimension hypercomplex numbers following the Cayley-Dickson construction of algebras.

Hypercomplex A Python library for working with quaternions, octonions, sedenions, and beyond following the Cayley-Dickson construction of hypercomplex

7 Nov 04, 2022
Using Tensorflow Object Detection API to detect Waymo open dataset

Waymo-2D-Object-Detection Using Tensorflow Object Detection API to detect Waymo open dataset Result CenterNet Training Loss SSD ResNet Training Loss C

76 Dec 12, 2022
Yolov3 pytorch implementation

YOLOV3 Pytorch实现 在bubbliiing大佬代码的基础上进行了修改,添加了部分注释。 预训练模型 预训练模型来源于bubbliiing。 链接:https://pan.baidu.com/s/1ncREw6Na9ycZptdxiVMApw 提取码:appk 训练自己的数据集 按照VO

4 Aug 27, 2022
Distilled coarse part of LoFTR adapted for compatibility with TensorRT and embedded divices

Coarse LoFTR TRT Google Colab demo notebook This project provides a deep learning model for the Local Feature Matching for two images that can be used

Kirill 46 Dec 24, 2022
A Simple Framwork for CV Pre-training Model (SOCO, VirTex, BEiT)

A Simple Framwork for CV Pre-training Model (SOCO, VirTex, BEiT)

Sense-GVT 14 Jul 07, 2022
[CVPR 2021] A Peek Into the Reasoning of Neural Networks: Interpreting with Structural Visual Concepts

Visual-Reasoning-eXplanation [CVPR 2021 A Peek Into the Reasoning of Neural Networks: Interpreting with Structural Visual Concepts] Project Page | Vid

Andy_Ge 54 Dec 21, 2022
Code for the paper "On the Power of Edge Independent Graph Models"

Edge Independent Graph Models Code for the paper: "On the Power of Edge Independent Graph Models" Sudhanshu Chanpuriya, Cameron Musco, Konstantinos So

Konstantinos Sotiropoulos 0 Oct 26, 2021
Pytorch implementation of 'Fingerprint Presentation Attack Detector Using Global-Local Model'

RTK-PAD This is an official pytorch implementation of 'Fingerprint Presentation Attack Detector Using Global-Local Model', which is accepted by IEEE T

6 Aug 01, 2022
Cosine Annealing With Warmup

CosineAnnealingWithWarmup Formulation The learning rate is annealed using a cosine schedule over the course of learning of n_total total steps with an

zhuyun 4 Apr 18, 2022
TextureGAN in Pytorch

TextureGAN This code is our PyTorch implementation of TextureGAN [Project] [Arxiv] TextureGAN is a generative adversarial network conditioned on sketc

Patsorn 147 Dec 14, 2022
This repository contain code on Novelty-Driven Binary Particle Swarm Optimisation for Truss Optimisation Problems.

This repository contain code on Novelty-Driven Binary Particle Swarm Optimisation for Truss Optimisation Problems. The main directory include the code

0 Dec 23, 2021
PyTorch implementation of the Transformer in Post-LN (Post-LayerNorm) and Pre-LN (Pre-LayerNorm).

Transformer-PyTorch A PyTorch implementation of the Transformer from the paper Attention is All You Need in both Post-LN (Post-LayerNorm) and Pre-LN (

Jared Wang 22 Feb 27, 2022
Hierarchical Aggregation for 3D Instance Segmentation (ICCV 2021)

HAIS Hierarchical Aggregation for 3D Instance Segmentation (ICCV 2021) by Shaoyu Chen, Jiemin Fang, Qian Zhang, Wenyu Liu, Xinggang Wang*. (*) Corresp

Hust Visual Learning Team 145 Jan 05, 2023
BOOKSUM: A Collection of Datasets for Long-form Narrative Summarization

BOOKSUM: A Collection of Datasets for Long-form Narrative Summarization Authors: Wojciech Kryściński, Nazneen Rajani, Divyansh Agarwal, Caiming Xiong,

Salesforce 125 Dec 31, 2022
YOLOv7 - Framework Beyond Detection

🔥🔥🔥🔥 YOLO with Transformers and Instance Segmentation, with TensorRT acceleration! 🔥🔥🔥

JinTian 3k Jan 01, 2023
Photo2cartoon - 人像卡通化探索项目 (photo-to-cartoon translation project)

人像卡通化 (Photo to Cartoon) 中文版 | English Version 该项目为小视科技卡通肖像探索项目。您可使用微信扫描下方二维码或搜索“AI卡通秀”小程序体验卡通化效果。

Minivision_AI 3.5k Dec 30, 2022