前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Yolov8-pose关键点检测:训练实战篇 | 手部关键点检测

Yolov8-pose关键点检测:训练实战篇 | 手部关键点检测

原创
作者头像
AI小怪兽
修改2023-12-26 14:31:00
5.4K1
修改2023-12-26 14:31:00
举报
文章被收录于专栏:YOLO大作战YOLO大作战

????本文解决什么问题:教会你如何用自己的数据集训练Yolov8-pose关键点检测

???手把手教你从数据标记到生成适合Yolov8-pose的yolo数据集;

???模型性能提升、pose模式部署能力;

???应用范围:工业工件定位、人脸、摔倒检测等支持各个关键点检测;

?

1.YOLOv8 介绍

YOLOv8目前支持目标检测、实例分割、图像分类、目标跟踪、姿态估计,也许还有更多惊喜在后面。

代码地址:https://github.com/ultralytics/ultralytics

进军工业界标杆,并向着“CV全家桶”阔步向前。

?

pose官方在COCO数据集上做了更多测试:

1.1数据集介绍

数据集大小300张:训练集236张,验证集64张

关键点共21个

代码语言:javascript
复制
# 关键点的类别
keypoint_class = ['Ulna', 'Radius', 'FMCP','FPIP', 'FDIP', 'MCP5','MCP4', 'MCP3', 'MCP2','PIP5', 'PIP4', 'PIP3'
                  ,'PIP2', 'MIP5', 'MIP4','MIP3', 'MIP2', 'DIP5','DIP4', 'DIP3', 'DIP2']

?

2.手部关键点训练

2.1 新建ultralytics/cfg/datasets/hand_keypoint.yaml

参考coco8-pose.yaml即可

代码语言:javascript
复制
# Ultralytics YOLO ?, AGPL-3.0 license
# COCO8-pose dataset (first 8 images from COCO train2017) by Ultralytics
# Example usage: yolo train data=coco8-pose.yaml
# parent
# ├── ultralytics
# └── datasets
#     └── coco8-pose  ← downloads here (1 MB)


# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: ./ultralytics-7.31/data/hand_keypoint  # dataset root dir
train: images/train  # train images (relative to 'path') 4 images
val: images/val  # val images (relative to 'path') 4 images
test:  # test images (optional)

# Keypoints
kpt_shape: [21, 3]  # number of keypoints, number of dims (2 for x,y or 3 for x,y,visible)
flip_idx: [0, 2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15,17,18,19,20]

# Classes
names:
  0: hand

# Download script/URL (optional)
#download: https://ultralytics.com/assets/coco8-pose.zip

2.2修改ultralytics/cfg/models/v8/yolov8-pose.yaml

修改为21个关键点和一个类别nc:1

代码语言:javascript
复制
# Ultralytics YOLO ?, AGPL-3.0 license
# YOLOv8-pose keypoints/pose estimation model. For Usage examples see https://docs.ultralytics.com/tasks/pose

# Parameters
nc: 1  # number of classes
kpt_shape: [21, 3]  # number of keypoints, number of dims (2 for x,y or 3 for x,y,visible)
scales: # model compound scaling constants, i.e. 'model=yolov8n-pose.yaml' will call yolov8-pose.yaml with scale 'n'
  # [depth, width, max_channels]
  n: [0.33, 0.25, 1024]
  s: [0.33, 0.50, 1024]
  m: [0.67, 0.75, 768]
  l: [1.00, 1.00, 512]
  x: [1.00, 1.25, 512]

2.3默认参数开启训练

代码语言:javascript
复制
               from  n    params  module                                       arguments                     
  0                  -1  1       464  ultralytics.nn.modules.conv.Conv             [3, 16, 3, 2]                 
  1                  -1  1      4672  ultralytics.nn.modules.conv.Conv             [16, 32, 3, 2]                
  2                  -1  1      7360  ultralytics.nn.modules.block.C2f             [32, 32, 1, True]             
  3                  -1  1     18560  ultralytics.nn.modules.conv.Conv             [32, 64, 3, 2]                
  4                  -1  2     49664  ultralytics.nn.modules.block.C2f             [64, 64, 2, True]             
  5                  -1  1     73984  ultralytics.nn.modules.conv.Conv             [64, 128, 3, 2]               
  6                  -1  2    197632  ultralytics.nn.modules.block.C2f             [128, 128, 2, True]           
  7                  -1  1    295424  ultralytics.nn.modules.conv.Conv             [128, 256, 3, 2]              
  8                  -1  1    460288  ultralytics.nn.modules.block.C2f             [256, 256, 1, True]           
  9                  -1  1    164608  ultralytics.nn.modules.block.SPPF            [256, 256, 5]                 
 10                  -1  1         0  torch.nn.modules.upsampling.Upsample         [None, 2, 'nearest']          
 11             [-1, 6]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           
 12                  -1  1    148224  ultralytics.nn.modules.block.C2f             [384, 128, 1]                 
 13                  -1  1         0  torch.nn.modules.upsampling.Upsample         [None, 2, 'nearest']          
 14             [-1, 4]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           
 15                  -1  1     37248  ultralytics.nn.modules.block.C2f             [192, 64, 1]                  
 16                  -1  1     36992  ultralytics.nn.modules.conv.Conv             [64, 64, 3, 2]                
 17            [-1, 12]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           
 18                  -1  1    123648  ultralytics.nn.modules.block.C2f             [192, 128, 1]                 
 19                  -1  1    147712  ultralytics.nn.modules.conv.Conv             [128, 128, 3, 2]              
 20             [-1, 9]  1         0  ultralytics.nn.modules.conv.Concat           [1]                           
 21                  -1  1    493056  ultralytics.nn.modules.block.C2f             [384, 256, 1]                 
 22        [15, 18, 21]  1   1125538  ultralytics.nn.modules.head.Pose             [1, [21, 3], [64, 128, 256]]  
YOLOv8-pose summary: 250 layers, 3385074 parameters, 3385058 gradients, 9.7 GFLOPs

2.4训练结果分析

100个epoch以后

BoxPR_curve.png

PosePR_curve.png

预测图片结果如下:

存在部分关键点预测不准确的现象

3《YOLOv8-Pose关键点检测》专栏介绍

实时更新中,模型轻量化创新结果如下:

layers

parameters

GFLOPs

kb

mAP50

mAP50-95

yolov8-pose

187

3379496

9.6

6842

0.921

0.697

yolov8-C2f_GhostBottleneck-pose

362

2590296

7.7

5393

0.929

0.769

yolov8-C2f_GhostBottleneckV2-pose

298

2927192

8.3

5989

0.904

0.74

yolov8-C2f_repghost-pose

334

2959784

8.4

6080

0.892

0.736

yolov8-C2f_g_ghostBottleneck-pose

214

2954744

8.4

6022

0.932

0.71

yolov8-C2f_DCNV3-pose

341

2895930

8.6

5970

0.926

0.743

yolov8-C2f_PConv-pose

205

3018296

8.5

6134

0.925

0.695

yolov8-C2f_BiLevelRoutingAttention-pose

205

3018296

8.5

6134

0.926

0.734

yolov8-C2f_ScConv-pose

256

3188264

9

6479

0.921

0.7

yolov8-slimneck-pose

309

3378200

8.9

6932

0.93

0.829

yolov8-C2f_RepvggOREPA-pose

280

4565192

8.4

9359

0.915

0.677

yolov8-C2f_OREPA-pose

196

4562504

8.2

9303

0.931

0.691

YOLOv8-C2f_LSKA_Attention-pose

226

2987000

8.5

6080

0.925

0.652

yolov8-C2f_MultiDilatelocalAttention-pose

250

3004472

8.5

6101

0.909

0.726

yolov8-pose_PPLCNet.yaml

228

2223924

6.6

4574

0.901

0.752

by CSDN AI小怪兽

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1.YOLOv8 介绍
    • 1.1数据集介绍
    • 2.手部关键点训练
      • 2.1 新建ultralytics/cfg/datasets/hand_keypoint.yaml
        • 2.2修改ultralytics/cfg/models/v8/yolov8-pose.yaml
          • 2.3默认参数开启训练
            • 2.4训练结果分析
            • 3《YOLOv8-Pose关键点检测》专栏介绍
            领券
            问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
            http://www.vxiaotou.com