Giter Club home page Giter Club logo

retinaface-tf2's Introduction

Retinaface:人脸检测模型在Tensorflow2当中的实现


目录

  1. 仓库更新 Top News
  2. 性能情况 Performance
  3. 所需环境 Environment
  4. 文件下载 Download
  5. 预测步骤 How2predict
  6. 训练步骤 How2train
  7. 评估步骤 Eval
  8. 参考资料 Reference

Top News

2022-03:进行了大幅度的更新,支持step、cos学习率下降法、支持adam、sgd优化器选择、支持学习率根据batch_size自适应调整。
BiliBili视频中的原仓库地址为:https://github.com/bubbliiiing/retinaface-tf2/tree/bilibili

2020-09:仓库创建,支持模型训练,大量的注释,多个主干的选择,多个可调整参数。

性能情况

训练数据集 权值文件名称 测试数据集 输入图片大小 Easy Medium Hard
Widerface-Train retinaface_mobilenet025.h5 Widerface-Val 1280x1280 88.94% 86.76% 73.83%
Widerface-Train retinaface_resnet50.h5 Widerface-Val 1280x1280 94.69% 93.08% 84.31%

注意事项

本库下载过来可以直接进行预测,已经在model_data文件夹下存放了retinaface_mobilenet025.h5文件,可用于预测。
如果想要使用基于resnet50的retinaface请下载retinaface_resnet50.h5进行预测。

所需环境

tensorflow-gpu==2.2.0

文件下载

训练所需的retinaface_resnet50.h5、resnet50_weights_tf_dim_ordering_tf_kernels_notop.h5等文件可以在百度云下载。
链接: https://pan.baidu.com/s/1wnAP2AHdpJEP7AhPoO5H2w 提取码: j6wq

数据集可以在如下连接里下载。
链接: https://pan.baidu.com/s/1bsgay9iMihPlAKE49aWNTA 提取码: bhee

预测步骤

a、使用预训练权重

  1. 下载完库后解压,运行predict.py,输入
img/timg.jpg
  1. 在predict.py里面进行设置可以进行fps测试和video视频检测。

b、使用自己训练的权重

  1. 按照训练步骤训练。
  2. 在retinaface.py文件里面,在如下部分修改model_path和backbone使其对应训练好的文件。
_defaults = {
    "model_path"        : 'model_data/retinaface_mobilenet025.h5',
    "backbone"          : 'mobilenet',
    "confidence"        : 0.5,
    "nms_iou"           : 0.45,
    #----------------------------------------------------------------------#
    #   是否需要进行图像大小限制。
    #   开启后,会将输入图像的大小限制为input_shape。否则使用原图进行预测。
    #   keras代码中主干为mobilenet时存在小bug,当输入图像的宽高不为32的倍数
    #   会导致检测结果偏差,主干为resnet50不存在此问题。
    #----------------------------------------------------------------------#
    "input_shape"       : [1280, 1280, 3],
    "letterbox_image"   : True
}
  1. 运行predict.py,输入
img/timg.jpg
  1. 在predict.py里面进行设置可以进行fps测试和video视频检测。

训练步骤

  1. 本文使用widerface数据集进行训练。
  2. 可通过上述百度网盘下载widerface数据集。
  3. 覆盖根目录下的data文件夹。
  4. 根据自己需要选择从头开始训练还是在已经训练好的权重下训练,需要修改train.py文件下的代码,在训练时需要注意backbone和权重文件的对应。 使用mobilenet为主干特征提取网络的示例如下:
    从头开始训练:
#-------------------------------#
#   创立模型
#-------------------------------#
model = RetinaFace(cfg, backbone=backbone)
model_path = "model_data/mobilenet_2_5_224_tf_no_top.h5"
model.load_weights(model_path,by_name=True,skip_mismatch=True)

在已经训练好的权重下训练:

#-------------------------------#
#   创立模型
#-------------------------------#
model = RetinaFace(cfg, backbone=backbone)
model_path = "model_data/retinaface_mobilenet025.h5"
model.load_weights(model_path,by_name=True,skip_mismatch=True)
  1. 可以在logs文件夹里面获得训练好的权值文件。

评估步骤

  1. 在retinaface.py文件里面,在如下部分修改model_path和backbone使其对应训练好的文件。
_defaults = {
    "model_path"        : 'model_data/retinaface_mobilenet025.h5',
    "backbone"          : 'mobilenet',
    "confidence"        : 0.5,
    "nms_iou"           : 0.45,
    #----------------------------------------------------------------------#
    #   是否需要进行图像大小限制。
    #   开启后,会将输入图像的大小限制为input_shape。否则使用原图进行预测。
    #   keras代码中主干为mobilenet时存在小bug,当输入图像的宽高不为32的倍数
    #   会导致检测结果偏差,主干为resnet50不存在此问题。
    #----------------------------------------------------------------------#
    "input_shape"       : [1280, 1280, 3],
    "letterbox_image"   : True
}
  1. 下载好百度网盘上上传的数据集,其中包括了验证集,解压在根目录下。
  2. 运行evaluation.py即可开始评估。

Reference

https://github.com/biubug6/Pytorch_Retinaface

retinaface-tf2's People

Contributors

bubbliiiing avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

retinaface-tf2's Issues

ap,耗时测试

你好,你有进行ap和耗时的测试吗?在mobilenet的backbone下是多少?

训练问题

请问网盘中训练好的mobilenet大概训练了几轮,loss是多少呢?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.