news 2026/6/10 7:52:46

基于深度学习LightWeight的人体姿态检测跌倒系统源码

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
基于深度学习LightWeight的人体姿态检测跌倒系统源码

一. LightWeight概述

light weight openpose是openpose的简化版本,使用了openpose的大体流程。

Light weight openpose和openpose的区别是:

a 前者使用的是Mobilenet V1(到conv5_5),后者使用的是Vgg19(前10层)。

b 前者部分层使用了空洞卷积(dilated convolution)来提升感受视野,后者使用一般的卷积。

c 前者卷积核大小为3*3,后者为7*7。

d 前者只有一个refine stage,后者有5个stage。

e 前者的initial stage和refine stage里面的两个分支(hotmaps和pafs)使用权值共享,后者则是并行的两个分支

二. LightWeight的网络结构

openpose的每个stage使用下图中左侧的两个并行的分支,分别预测hotmaps和pafs,为了进一步降低计算量,light weight openpose中将前几层进行权值共享,如下图右侧所示。

其网络流程:

三. LightWeight的网络结构代码

import torch from torch import nn from modules.conv import conv, conv_dw, conv_dw_no_bn class Cpm(nn.Module): def __init__(self, in_channels, out_channels): super().__init__() self.align = conv(in_channels, out_channels, kernel_size=1, padding=0, bn=False) self.trunk = nn.Sequential( conv_dw_no_bn(out_channels, out_channels), conv_dw_no_bn(out_channels, out_channels), conv_dw_no_bn(out_channels, out_channels) ) self.conv = conv(out_channels, out_channels, bn=False) def forward(self, x): x = self.align(x) x = self.conv(x + self.trunk(x)) return x class InitialStage(nn.Module): def __init__(self, num_channels, num_heatmaps, num_pafs): super().__init__() self.trunk = nn.Sequential( conv(num_channels, num_channels, bn=False), conv(num_channels, num_channels, bn=False), conv(num_channels, num_channels, bn=False) ) self.heatmaps = nn.Sequential( conv(num_channels, 512, kernel_size=1, padding=0, bn=False), conv(512, num_heatmaps, kernel_size=1, padding=0, bn=False, relu=False) ) self.pafs = nn.Sequential( conv(num_channels, 512, kernel_size=1, padding=0, bn=False), conv(512, num_pafs, kernel_size=1, padding=0, bn=False, relu=False) ) def forward(self, x): trunk_features = self.trunk(x) heatmaps = self.heatmaps(trunk_features) pafs = self.pafs(trunk_features) return [heatmaps, pafs] class RefinementStageBlock(nn.Module): def __init__(self, in_channels, out_channels): super().__init__() self.initial = conv(in_channels, out_channels, kernel_size=1, padding=0, bn=False) self.trunk = nn.Sequential( conv(out_channels, out_channels), conv(out_channels, out_channels, dilation=2, padding=2) ) def forward(self, x): initial_features = self.initial(x) trunk_features = self.trunk(initial_features) return initial_features + trunk_features class RefinementStage(nn.Module): def __init__(self, in_channels, out_channels, num_heatmaps, num_pafs): super().__init__() self.trunk = nn.Sequential( RefinementStageBlock(in_channels, out_channels), RefinementStageBlock(out_channels, out_channels), RefinementStageBlock(out_channels, out_channels), RefinementStageBlock(out_channels, out_channels), RefinementStageBlock(out_channels, out_channels) ) self.heatmaps = nn.Sequential( conv(out_channels, out_channels, kernel_size=1, padding=0, bn=False), conv(out_channels, num_heatmaps, kernel_size=1, padding=0, bn=False, relu=False) ) self.pafs = nn.Sequential( conv(out_channels, out_channels, kernel_size=1, padding=0, bn=False), conv(out_channels, num_pafs, kernel_size=1, padding=0, bn=False, relu=False) ) def forward(self, x): trunk_features = self.trunk(x) heatmaps = self.heatmaps(trunk_features) pafs = self.pafs(trunk_features) return [heatmaps, pafs] class PoseEstimationWithMobileNet(nn.Module): def __init__(self, num_refinement_stages=1, num_channels=128, num_heatmaps=19, num_pafs=38): super().__init__() self.model = nn.Sequential( conv( 3, 32, stride=2, bias=False), conv_dw( 32, 64), conv_dw( 64, 128, stride=2), conv_dw(128, 128), conv_dw(128, 256, stride=2), conv_dw(256, 256), conv_dw(256, 512), # conv4_2 conv_dw(512, 512, dilation=2, padding=2), conv_dw(512, 512), conv_dw(512, 512), conv_dw(512, 512), conv_dw(512, 512) # conv5_5 ) self.cpm = Cpm(512, num_channels) self.initial_stage = InitialStage(num_channels, num_heatmaps, num_pafs) self.refinement_stages = nn.ModuleList() for idx in range(num_refinement_stages): self.refinement_stages.append(RefinementStage(num_channels + num_heatmaps + num_pafs, num_channels, num_heatmaps, num_pafs)) def forward(self, x): backbone_features = self.model(x) backbone_features = self.cpm(backbone_features) stages_output = self.initial_stage(backbone_features) for refinement_stage in self.refinement_stages: stages_output.extend( refinement_stage(torch.cat([backbone_features, stages_output[-2], stages_output[-1]], dim=1))) return stages_output

四. LightWeight是怎么去识别跌倒呢

LightWeight可以检测到人体的关键点,所以可以通过两种方式来判断是否跌倒,第一种方法是通过计算角度,第二种方式,是通过判断整体的关键点(把抠出的关键点图送入到分类网络),本文的做法是第二种方式

五. LightWeight的演示效果(具有图片和摄像头识别功能)

演示视频:基于深度学习LightWeight的人体姿态检测跌倒系统源码_哔哩哔哩_bilibili

六. 整个工程的内容

提供源代码,模型,提供GUI界面代码

项目完整文件下载请见演示与介绍视频的简介处给出:➷➷➷

https://www.bilibili.com/video/BV1CBz5YDEgU/

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/6/7 5:30:58

学习大模型应用入门指南:MinerU云端体验,按需付费不怕投入大

学习大模型应用入门指南:MinerU云端体验,按需付费不怕投入大 你是不是也和我一样,原本是个普通上班族,现在想转行做程序员,尤其是对AI工程化方向特别感兴趣?但一想到要买显卡、搭环境、装驱动,…

作者头像 李华
网站建设 2026/6/10 15:10:46

告别传统启动盘:Ventoy带你进入智能启动新时代

告别传统启动盘:Ventoy带你进入智能启动新时代 【免费下载链接】Ventoy 一种新的可启动USB解决方案。 项目地址: https://gitcode.com/GitHub_Trending/ve/Ventoy 你是否曾经为了安装不同系统而反复格式化U盘?是否因为一个系统镜像损坏就不得不重…

作者头像 李华
网站建设 2026/5/23 0:52:39

Open5x开源5轴3D打印终极指南:从零基础到复杂曲面打印

Open5x开源5轴3D打印终极指南:从零基础到复杂曲面打印 【免费下载链接】Open5x This is a Github repository for 5-axis 3D printing 项目地址: https://gitcode.com/gh_mirrors/op/Open5x 想要突破传统3D打印的限制,实现真正的复杂曲面制造&…

作者头像 李华
网站建设 2026/6/10 14:21:45

VRCX:重新定义VRChat社交管理的技术方案

VRCX:重新定义VRChat社交管理的技术方案 【免费下载链接】VRCX Friendship management tool for VRChat 项目地址: https://gitcode.com/GitHub_Trending/vr/VRCX 在虚拟现实社交平台VRChat的生态系统中,用户关系管理一直是影响体验质量的关键因素…

作者头像 李华
网站建设 2026/6/9 12:37:22

如何在3分钟内快速获取国家中小学电子教材?实用工具使用指南

如何在3分钟内快速获取国家中小学电子教材?实用工具使用指南 【免费下载链接】tchMaterial-parser 国家中小学智慧教育平台 电子课本下载工具 项目地址: https://gitcode.com/GitHub_Trending/tc/tchMaterial-parser 还在为教学资源获取困难而烦恼吗&#xf…

作者头像 李华
网站建设 2026/6/10 15:17:45

终极指南:使用自动化配置工具轻松构建专业级系统环境

终极指南:使用自动化配置工具轻松构建专业级系统环境 【免费下载链接】OpCore-Simplify A tool designed to simplify the creation of OpenCore EFI 项目地址: https://gitcode.com/GitHub_Trending/op/OpCore-Simplify 在当今技术快速发展的时代&#xff0…

作者头像 李华