当前位置:网站首页>人脸与关键点检测:YOLO5Face实战
人脸与关键点检测:YOLO5Face实战
2022-07-25 21:21:00 【烧技湾】

Github:https://github.com/deepcam-cn/yolov5-face
导读:居然花了一天时间把该项目复现,主要是折腾在数据集格式上,作者居然在train2yolo中居然把Widerface训练集(12000+张图)重新一张一张保存,不这么做还报错,原因是无法读到数据缓存。搬运工,肝!
一、設置
Step by step
克隆仓库,进入conda环境
git clone https://github.com/deepcam-cn/yolov5-face.git
conda activate pytorch-cifar
测试模型
下载作者预训练的YOLO5m-face模型,并测试单张图片效果。运行detectface如下:

"args": [
// // // to run train2yolo:
// "data/widerface/train",
// "data/widerface/train/labels"
// // // to run val2yolo:
// "data/widerface",
// "data/widerface/val/labels"
// // to run detect_face
// "--img-size", "640",
// "--weights", "weights/yolov5m-face.pt",
// to train on widerface
// "CUDA_VISIBLE_DEVICES"," 0, ",
"--data", "data/widerface.yaml",
"--cfg", "models/yolov5s.yaml",
"--weights", "weights/yolov5s.pt"
]
以上是launch.json的配置参数,分别对应几个任务。其中运行train2yolo.py,巨慢;但不得不做。
二、训练
2.1 准备数据:
推荐去官网http://shuoyang1213.me/WIDERFACE/
下载widerface数据集,分别下载train、val、test三个包。本人参考RetinaFace下载的数据集不全面。
由于官网没找到人脸关键点的标注文本,在开头git链接YOLO5face可以下载带有keypoint的annotation文件。整个文件结构如下:
(base) [email protected]:NewProjects$ ln -s ~/Datasets/widerface yolov5-face/data/
//
yolov5-face
│ README.md
│ ...
│data
| └─widerface
│ └───test
| └───images
| └───labels
│ └───train
| └───images
| └───labels
| └───0..._1_5.jpg
| └───0..._1_5.txt
│ └───val
目录画得有点丑,但为了说明详细,也是拼了老命。
下载预训练好的yolo5检测模型,由于本工程基于的yolo版本比较旧(最新6.0版)久,下载链接参考:
https://github.com/ultralytics/yolov5/releases/tag/v4.0
准确读取数据路径,在widerface.yaml修改为:
train: /home/wqt/NewProjects/yolov5-face/data/widerface/train/labels
val: /home/wqt/NewProjects/yolov5-face/data/widerface/val/labels
# number of classes
nc: 1
# class names
names: [ 'face']
运行train,没报错,佛祖保佑!
autoanchor: Analyzing anchors... anchors/target = 4.02, Best Possible Recall (BPR) = 0.9997
Image sizes 800 train, 800 test
Using 4 dataloader workers
Logging results to runs/train/exp12
Starting training for 250 epochs...
Epoch gpu_mem box obj cls landmark total targets img_size
0/249 4.65G 0.1032 0.03953 0 0.1396 0.2823 25 800: 100%|███████████████████████████████████████████████| 801/801 [03:12<00:00, 4.16it/s]
Epoch gpu_mem box obj cls landmark total targets img_size
1/249 5.01G 0.08159 0.03674 0 0.02959 0.1479 15 800: 100%|███████████████████████████████████████████████| 801/801 [03:03<00:00, 4.38it/s]
训练还挺快,一个epoch才几分钟,共250epoch。
有关YOLO数据格式
原始的widerface标注如下:
0--Parade/0_Parade_marchingband_1_849.jpg
1
449 330 122 149 0 0 0 0 0 0
转化为YOLO格式,如下:
0--Parade/0_Parade_marchingband_1_849.jpg
449 330 122 149 488.906 373.643 0.0 542.089 376.442 0.0 515.031 412.83 0.0 485.174 425.893 0.0 538.357 431.491 0.0 0.82
即:bbox (xywh) + (xi, yi, flag)
COCO keypoints转化为YOLO格式(17个人体关键点),以下图片对应的标注如下:
0 0.686445 0.531960 0.082891 0.323967 0.667188 0.399061 1.000000 0.670312 0.396714 2.000000 0.000000 0.000000 0.000000 0.678125 0.394366 2.000000 0.000000 0.000000 0.000000 0.689063 0.415493 2.000000 0.696875 0.415493 2.000000 0.682813 0.469484 2.000000 0.671875 0.483568 2.000000 0.671875 0.516432 2.000000 0.656250 0.504695 2.000000 0.695312 0.530516 2.000000 0.706250 0.523474 2.000000 0.698438 0.610329 2.000000 0.709375 0.603286 2.000000 0.710938 0.680751 2.000000 0.717187 0.671362 2.000000

训练了12h之后,实测结果如下:
Epoch gpu_mem box obj cls landmark total targets img_size
249/249 5.01G 0.03923 0.02193 0 0.00727 0.06844 18 800:
Class Images Targets P R [email protected] [email protected]:.95:
all 3.22e+03 3.96e+04 0.576 0.723 0.715 0.34
即在WiderFace上取得了[email protected]=71.5%,[email protected]=0.34
实测1:

实测2:
使用缩放的效果图,还是检测有些误差,例如嘴角两边的点。
边栏推荐
- 浅谈web性能优化(一)
- Dear bosses, how can I print the result of Flink SQL to the console and display it completely?
- Experience sharing of system architecture designers preparing for the exam: from point to surface
- Airtest solves the problem that a password needs to be entered in the process of "automatic packaging" (the same applies to random bullet frame processing)
- Intel base instruction -- bnd
- My heart's broken! After being cheated by 30000, a 16-year-old girl was unconvinced and cheated by 50000
- 2022 latest examination questions and answers of eight members (standard staff) of Shanghai Architecture
- Talk about what's going on with C # backstage GC?
- On Web Performance Optimization (1)
- Isn't it too much to play Gobang in idea?
猜你喜欢

DDD的Go实战

Debugged PEB (beingdebugged, ntglobalflag)
![[FAQ] access the HMS core push service, and the server sends messages. Cause analysis and solutions of common error codes](/img/65/4dd3a521946e753c79d3db1fa0a4f4.png)
[FAQ] access the HMS core push service, and the server sends messages. Cause analysis and solutions of common error codes

The onnx model is exported as a TRT model

Interface testing tool restlet client

Product principles of non-financial decentralized application

Record the transfer of domain names from Alibaba cloud service providers to Huawei cloud

Add startup software items when the win system starts up

Decompile app
![[ManageEngine] value brought by Siem to enterprises](/img/1e/56d64d193e0428523418bef5e98866.png)
[ManageEngine] value brought by Siem to enterprises
随机推荐
图片怎么存储到数据库里「建议收藏」
Detailed explanation of Ag search tool parameters
The inexplicability of Intel disassembly
字节一面:TCP 和 UDP 可以使用同一个端口吗?
Leetcode-155: minimum stack
Airtest solves the problem that a password needs to be entered in the process of "automatic packaging" (the same applies to random bullet frame processing)
ag 搜索工具参数详解
When facing complex problems, systematic thinking helps you understand the essence of the problem
Canvas 填充渐变
day04_ array
Airtest解决“自动装包”过程中需要输入密码的问题(同适用于随机弹框处理)
基于腾讯地图实现精准定位,实现微信小程序考勤打卡功能
【FiddlerTX插件】使用Fiddler抓包腾讯课堂视频下载(抓不到包解决方案)
Research: more than 70% of doctors are still prescribing unsafe antibiotic drugs
[manageengine]itsm application in retail industry
数据库sql语句练习题「建议收藏」
Sum of two numbers and three numbers
Apache Shenyu admin authentication bypass vulnerability (cve-2021-37580) analysis and protection measures
Niuke-top101-bm38
Too many passwords, don't know how to record? Why don't you write a password box applet yourself