论文 Deep High-Resolution Representation Learning for Human Pose Estimation

也是 一个 top-down得对于人体姿态估计得检测方法。和Stack hourglass netword, CPN, MSPN等都大致一样。需要先学习一个人体检测器,将每个人都检测出来,然后在送进单个人体姿态估计模型。

从论文名字可以看出,HIgh-Resolution 高分辨率。

Stack hourglass netword, CPN, MSPN 模型结构都有一定得相似性,类型和Unet结构相似,加上一些残差。都经历一个下采样然后在进行上采样得过程。

然后HRNet 稍微有点不同,保持相同大小进行特征传递。每经过一个Transition是多出一个下采样得分支

如图:

模型得代码如下:

class PoseHighResolutionNet(nn.Module):def __init__(self, cfg, **kwargs):passdef forward(self, x):# 下面将x缩小了4倍  两个conv得s=2x = self.conv1(x)x = self.bn1(x)x = self.relu(x)x = self.conv2(x)x = self.bn2(x)x = self.relu(x)x = self.layer1(x)x_list = []# 每经过一个transition 产生一个下采样分支for i in range(self.stage2_cfg['NUM_BRANCHES']):if self.transition1[i] is not None:x_list.append(self.transition1[i](x))else:x_list.append(x)y_list = self.stage2(x_list)x_list = []# 每经过一个transition 产生一个下采样分支for i in range(self.stage3_cfg['NUM_BRANCHES']):if self.transition2[i] is not None:x_list.append(self.transition2[i](y_list[-1]))else:x_list.append(y_list[i])y_list = self.stage3(x_list)x_list = []# 每经过一个transition 产生一个下采样分支for i in range(self.stage4_cfg['NUM_BRANCHES']):if self.transition3[i] is not None:x_list.append(self.transition3[i](y_list[-1]))else:x_list.append(y_list[i])y_list = self.stage4(x_list)# 最终模型只取 最后一个stage得 第一层得输出来x = self.final_layer(y_list[0])return x

对于heatmaplabel的生成 和其他网络一样采用 2D高斯函数生成

    def generate_target(self, joints, joints_vis):''':param joints:  [num_joints, 3]:param joints_vis: [num_joints, 3]:return: target, target_weight(1: visible, 0: invisible)'''target_weight = np.ones((self.num_joints, 1), dtype=np.float32)target_weight[:, 0] = joints_vis[:, 0]assert self.target_type == 'gaussian', \'Only support gaussian map now!'if self.target_type == 'gaussian':target = np.zeros((self.num_joints,self.heatmap_size[1],self.heatmap_size[0]),dtype=np.float32)tmp_size = self.sigma * 3for joint_id in range(self.num_joints):feat_stride = self.image_size / self.heatmap_sizemu_x = int(joints[joint_id][0] / feat_stride[0] + 0.5)mu_y = int(joints[joint_id][1] / feat_stride[1] + 0.5)# Check that any part of the gaussian is in-boundsul = [int(mu_x - tmp_size), int(mu_y - tmp_size)]br = [int(mu_x + tmp_size + 1), int(mu_y + tmp_size + 1)]if ul[0] >= self.heatmap_size[0] or ul[1] >= self.heatmap_size[1] \or br[0] < 0 or br[1] < 0:# If not, just return the image as istarget_weight[joint_id] = 0continue# # Generate gaussian# 生成高斯函数进行赋值size = 2 * tmp_size + 1x = np.arange(0, size, 1, np.float32)y = x[:, np.newaxis]x0 = y0 = size // 2# The gaussian is not normalized, we want the center value to equal 1g = np.exp(- ((x - x0) ** 2 + (y - y0) ** 2) / (2 * self.sigma ** 2))# Usable gaussian rangeg_x = max(0, -ul[0]), min(br[0], self.heatmap_size[0]) - ul[0]g_y = max(0, -ul[1]), min(br[1], self.heatmap_size[1]) - ul[1]# Image rangeimg_x = max(0, ul[0]), min(br[0], self.heatmap_size[0])img_y = max(0, ul[1]), min(br[1], self.heatmap_size[1])v = target_weight[joint_id]if v > 0.5:target[joint_id][img_y[0]:img_y[1], img_x[0]:img_x[1]] = \g[g_y[0]:g_y[1], g_x[0]:g_x[1]]if self.use_different_joints_weight:target_weight = np.multiply(target_weight, self.joints_weight)return target, target_weight

对于人体姿态估计网络的损失函数 基本都是一样的 MSE

class JointsMSELoss(nn.Module):def __init__(self, use_target_weight):super(JointsMSELoss, self).__init__()# 采用 MSEself.criterion = nn.MSELoss(reduction='mean')self.use_target_weight = use_target_weightdef forward(self, output, target, target_weight):batch_size = output.size(0)num_joints = output.size(1)heatmaps_pred = output.reshape((batch_size, num_joints, -1)).split(1, 1)heatmaps_gt = target.reshape((batch_size, num_joints, -1)).split(1, 1)loss = 0for idx in range(num_joints):heatmap_pred = heatmaps_pred[idx].squeeze()heatmap_gt = heatmaps_gt[idx].squeeze()if self.use_target_weight:# 损失计算loss += 0.5 * self.criterion(heatmap_pred.mul(target_weight[:, idx]),heatmap_gt.mul(target_weight[:, idx]))else:loss += 0.5 * self.criterion(heatmap_pred, heatmap_gt)return loss / num_joints

从代码上看 其实和其他的top-down网络基本相似,貌似仅仅是在网络结构上进行了一定调整。

网络结构采用并行的传递方式。

基于inference代码 基本上和其他top-down网络代码相似。

有兴趣可以看看其他几篇top-down网络的源码分析

Rethinking on Multi-Stage Networks for Human Pose Estimation 源码分析_那时那月那人的博客-CSDN博客Rethinking on Multi-Stage Networks for Human Pose Estimation 源码分析https://blog.csdn.net/xiaoxu1025/article/details/127840623CPN-Cascaded Pyramid Network for Multi-Person Pose Estimation 源码分析_那时那月那人的博客-CSDN博客CPN 源码分析https://blog.csdn.net/xiaoxu1025/article/details/127838074Stacked Hourglass Networks for Human Pose Estimation 源码分析_那时那月那人的博客-CSDN博客Stacked Hourglass Networks for Human Pose Estimation 源码分析从源码分析 Stacked Hourglass Networks 在人体检测方向得具体实现https://blog.csdn.net/xiaoxu1025/article/details/127835690

到此 基于 top-down 方法的人体姿态检测 网络模型告一段落。

如果对采用bottom-up方式的HigherHRNet感兴趣可以移步下面链接

HigherHRNet 源码分析_那时那月那人的博客-CSDN博客

HRNet 源码分析相关推荐

  1. 【Golang源码分析】Go Web常用程序包gorilla/mux的使用与源码简析

    目录[阅读时间:约10分钟] 一.概述 二.对比: gorilla/mux与net/http DefaultServeMux 三.简单使用 四.源码简析 1.NewRouter函数 2.HandleF ...

  2. SpringBoot-web开发(四): SpringMVC的拓展、接管(源码分析)

    [SpringBoot-web系列]前文: SpringBoot-web开发(一): 静态资源的导入(源码分析) SpringBoot-web开发(二): 页面和图标定制(源码分析) SpringBo ...

  3. SpringBoot-web开发(二): 页面和图标定制(源码分析)

    [SpringBoot-web系列]前文: SpringBoot-web开发(一): 静态资源的导入(源码分析) 目录 一.首页 1. 源码分析 2. 访问首页测试 二.动态页面 1. 动态资源目录t ...

  4. SpringBoot-web开发(一): 静态资源的导入(源码分析)

    目录 方式一:通过WebJars 1. 什么是webjars? 2. webjars的使用 3. webjars结构 4. 解析源码 5. 测试访问 方式二:放入静态资源目录 1. 源码分析 2. 测 ...

  5. Yolov3Yolov4网络结构与源码分析

    Yolov3&Yolov4网络结构与源码分析 从2018年Yolov3年提出的两年后,在原作者声名放弃更新Yolo算法后,俄罗斯的Alexey大神扛起了Yolov4的大旗. 文章目录 论文汇总 ...

  6. ViewGroup的Touch事件分发(源码分析)

    Android中Touch事件的分发又分为View和ViewGroup的事件分发,View的touch事件分发相对比较简单,可参考 View的Touch事件分发(一.初步了解) View的Touch事 ...

  7. View的Touch事件分发(二.源码分析)

    Android中Touch事件的分发又分为View和ViewGroup的事件分发,先来看简单的View的touch事件分发. 主要分析View的dispatchTouchEvent()方法和onTou ...

  8. MyBatis原理分析之四:一次SQL查询的源码分析

    上回我们讲到Mybatis加载相关的配置文件进行初始化,这回我们讲一下一次SQL查询怎么进行的. 准备工作 Mybatis完成一次SQL查询需要使用的代码如下: Java代码   String res ...

  9. [转]slf4j + log4j原理实现及源码分析

    slf4j + log4j原理实现及源码分析 转载于:https://www.cnblogs.com/jasonzeng888/p/6051080.html

最新文章

  1. Android IJKPlayer缓冲区设置以及播放一段时间出错解决方案
  2. Nuget很慢,我们该怎么办
  3. Sprint 站立会议(个人)
  4. Ejabberd源码解析前奏--管理
  5. C# winform C/S WebBrowser 微信第三方登录
  6. 在C#程序设计中使用Win32 API
  7. getopt长参数(长选项)获取不到参数BUG
  8. [WPF 基础知识系列] —— 绑定中的数据校验Vaildation
  9. Linux系统删掉多个文件
  10. python xrange_Python学习中的知识点(range和xrange)
  11. wifi芯片_全新蜕变!康希通信第四代WIFI 6 FEM芯片将于2020年Q1量产
  12. Promise--优雅的异步回调解决方案
  13. php项目源码发布linux,php代码上传到linux服务器无法正常显示
  14. 游戏修改器制作教程七:注入DLL的各种姿势
  15. js 手机号、邮箱、身份证校验
  16. DAP-seq助力胡杨耐盐机制的研究Populus euphratica WRKY1 binds the promoter of H+-ATPase gene to enhance gene expr
  17. 周志华----机器学习2
  18. NPOI之Excel——合并单元格、设置样式、输入公式
  19. Java---设计【运动会成绩管理系统】
  20. 用数学归纳法证明n阶无向树T有n-1边

热门文章

  1. 贵金属系统外出入库管理理解与总结 kaki的博客
  2. 钉钉机器人(1)创建钉钉群机器人推送消息
  3. 微信域名如何防封?微信域名被封了怎么办?微信域名被封能够恢复吗?
  4. 一文读懂5G射频终端行业
  5. 20100921_Dawning_字符窜计算
  6. 江苏省普通高校软件计算机专业,江苏省普通高校“专转本”选拔考试 计算机专业大类专业综合基础理论考试大纲(14页)-原创力文档...
  7. 大整数加法java_JAVA 大整数加法的实现
  8. 人脸识别-人工智能领域的介绍有哪些
  9. 基于GeoHash算法的四大经纬度计算方案
  10. Mac电脑上没有允许任何来源选项的解决方法