torchvision使用keypoint rcnn 进行人体关键点定位

article/2025/9/10 8:31:16

系统:Windows 11

pytorch版本:1.11.0

torchvision版本:0.12.0

使用图片地址:vision/person1.jpg at main · pytorch/vision · GitHub

使用代码:


import torch
import torchvision.transforms
from torchvision.models.detection import keypointrcnn_resnet50_fpn
from torchvision.io import read_image# person_int = read_image(str(Path("assets") / "person1.jpg"))
person_int = read_image(r"E:\git_rep\vision-0.12.0\gallery\assets\person1.jpg")transforms1 = torchvision.transforms.ToPILImage()
transforms2 = torchvision.transforms.ToTensor()
person_float = transforms1(person_int)
person_float = transforms2(person_float)model = keypointrcnn_resnet50_fpn(True, progress=False)
model = model.eval()outputs = model([person_float])
print(outputs)kpts = outputs[0]['keypoints']
scores = outputs[0]['scores']print(kpts)
print(scores)detect_threshold = 0.75
idx = torch.where(scores > detect_threshold)
keypoints = kpts[idx]print(keypoints)import torch
import numpy as np
import matplotlib.pyplot as pltimport torchvision.transforms.functional as Fplt.rcParams["savefig.bbox"] = 'tight'def show(imgs):if not isinstance(imgs, list):imgs = [imgs]fig, axs = plt.subplots(ncols=len(imgs), squeeze=False)for i, img in enumerate(imgs):img = img.detach()img = F.to_pil_image(img)axs[0, i].imshow(np.asarray(img))axs[0, i].set(xticklabels=[], yticklabels=[], xticks=[], yticks=[])from torchvision.utils import draw_keypointsres = draw_keypoints(person_int, keypoints, colors="blue", radius=3)
show(res)

结果:

 

参考文献:

1.keypointrcnn_resnet50_fpn — Torchvision 0.13 documentation

2.Visualization utilities — Torchvision 0.13 documentation

3.Models and pre-trained weights — Torchvision 0.13 documentation

4.人体关键点检测(Keypoints Detection)


http://chatgpt.dhexx.cn/article/dK84aG12.shtml

相关文章

CenterNet: Keypoint Triplets for Object Detection

论文地址:https://arxiv.org/pdf/1904.08189.pdf 在本文中,作者将一个对象建模为一个单点,即其包围框的中心点。并使用关键点估计来找到中心点,并回归到所有其他对象属性,如大小、3D位置、方向,甚至姿势。C…

COCO数据集keypoint部分

COCO数据集总体格式如下: {"info": {...},"licenses": [...],"images": [...],"annotation": [...],"categories": [...], }coco数据集的使用: from pycocotools.coco import COCO import matplotl…

Rethinking Keypoint Representations: Modeling Keypoints and Poses as Objects for Multi-Person Human

该论文发表于ECCV2022 题目:重新思考关键点表征方法:将关键点和人体姿态作为目标建模以进行多人姿态估计 Abstract In keypoint estimation tasks such as human pose estimation,heatmap-based regression is the dominant approach despite possess…

[1] A Keypoint-based Global Association Network for Lane Detection

A Keypoint-based Global Association Network for Lane Detection 0. 摘要 概括车道线检测方法: (1)基于Anchor定位的方法,自顶向下根据路线图把预设定的Anchor回归到车道线上。缺点是对复杂车道线不够灵活; &#…

cv::KeyPoint中response的介绍

1. Opencv中的KeyPoint类介绍 KeyPoint类的构造函数如下: KeyPoint(); KeyPoint(Point2f _pt, float _size, float _angle-1, float _response0, int _octave0, int _class_id-1); KeyPoint(float x, float y, float _size, float _angle-1, float _response0, int _octave0…

11种Anchor-free目标检测综述 -- Keypoint-based篇

点击上方“3D视觉工坊”,选择“星标” 干货第一时间送达 导读 anchor-free目标检测算法分为两种,一种是DenseBox为代表的Dense Prediction类型,另一种则是以CornerNet为代表的Keypoint-bsaed Detection类型,以检测目标关键点为主…

SMOKE: Single-Stage Monocular 3D Object Detection via Keypoint Estimation

动机: in this paper that predicts a 3D bounding box for each detected object by combining a single keypoint estimate with regressed 3D variables. As a second contribution, we propose a multi-step disentangling approach for constructing the 3D b…

《PCL Docs 案例详解》KeyPoint——SIFT 关键点提取

SIFT 关键点提取 本节演示如何检测点云的SIFT 关键点。SIFT 即尺度不变特征变换(Scale-invariant feature transform,SIFT) ,最初用于图像处理领域的一种描述。这种描述具有尺度不变性,可以在图像中检测出关键点,是一种局部特征描述。 完整…

OpenCV中KeyPoint类

https://blog.csdn.net/u010821666/article/details/52883580 Opencv中KeyPoint类中的默认构造函数如下: CV_WRAP KeyPoint() : pt(0,0), size(0), angle(-1), response(0), octave(0), class_id(-1) {} 现分析各项属性 pt(x,y):关键点的点坐标; si…

Anchor-free目标检测综述 -- Keypoint-based篇

早期目标检测研究以anchor-based为主,设定初始anchor,预测anchor的修正值,分为two-stage目标检测与one-stage目标检测,分别以Faster R-CNN和SSD作为代表。后来,有研究者觉得初始anchor的设定对准确率的影响很大&#x…

Opencv中特征点Keypoint的解读(特征点与坐标的相互转换)

Opencv中特征点Keypoint的解读 特征点的生成特征点到坐标的转换坐标到特征点的转换 在我们学习特征点检测时,使用特征点检测器,比如ORB和SIFT生成特征点(FAST和SURF好像已经申请专利,较新版本可能用不了),通常生成的特征点形式是一…

COCO数据集Keypoint标注格式梳理和使用COCO-Annotator在自有数据集上进行标注

这里写自定义目录标题 COCO数据集Keypoint标注格式COCO数据集官网Keypoint Detection关键点检测统一数据格式Keypoint标注 使用COCO-Annotator标注自有数据集在Ubuntu 18.04上安装COCO-Annotator安装Docker和Docker-Compose安装COCO Annotator启动COCO Annotator使用COCO Annot…

OpenCV学习之KeyPoint

OpenCV中CV_EXPORTS类别KeyPoint与KeyPointsFilter头文件分析 用OpenCV一段时间了,说实话KeyPoint接触也算比较多,一直没有时间对其数据结构进行分析。今天打开源码对其keypoint.cpp文件进行简单分析一下:keypoint.cpp主要包含两个类KeyPoint…

ubuntu引导删除+win10引导修复

Windowsubuntu双系统,删除安装linux磁盘后没有删除其引导,删其引导的步骤为 使用快捷键winx,打开Windows PowerShell(管理员)(A),依次输入如下命令: 打开diskpart diskpart 列出系统中所有的磁盘 list disk 选择…

win10+ubuntu18.04 双系统修复ubuntu启动引导

win10ubuntu18.04 双系统修复ubuntu启动引导 因为windows是不能引导linux的,而每次win10升级或恢复都会将linux的启动引导覆盖掉,导致无法进入linux, 所以一直就禁止了win10更新.这几天win10出了点小毛病,所以就狠下心来恢复了系…

ubuntu 双系统启动引导修复

1、 准备一个安装U盘,插入电脑开机>选择U盘启动>选择试用Try ubuntu without install。 2、 进入系统后,用CtrlAltT快捷键打开终端,获取root权限,执行以下命令: sodu passwd sudo apt-get install s…

win10+ubuntu双系统,重装win10后修复ubuntu引导的方法

笔记本型号:联想拯救者Y7000P 2019版 操作系统:Windows 10Ubuntu 18.04 LTS 问题:重装系统后发现没办法进入到Ubuntu 解决办法: 首先,我们需要准备一个Ubuntu安装U盘,也就是我们之前进行Ubuntu系统安装…

Windows\Ubuntu修复UEFI引导

目录 1、修复Windows引导2、修复Ubuntu的引导 1、修复Windows引导 修复Windows的EFI引导需要使用到的工具为大白菜装机工具,官网是http://www.winbaicai.com/。使用大白菜制作好装机工具以后,重启选择U盘启动(一定要选“UEFI:你的…

Ubuntu boot-repair系统修复引导

Ubuntu系统修复引导 笔记本上本来已经有了一个ubuntu和一个windows,但是那天作死,想要在移动固态硬盘上安装一个ubuntu,方便使用,结果装完了之后必须要将移动固态插在笔记本上,才能够正常引导。 上网查了半天&#xf…

ubuntu修复启动引导

1. 解决步骤: 1:准备一个安装U盘,插入电脑->开机->选择试用Try ubuntu without install 2:打开终端(Open Terminal),获取root权限…