pytorch implementation of openpose including Hand and Body Pose Estimation.

Overview

pytorch-openpose

pytorch implementation of openpose including Body and Hand Pose Estimation, and the pytorch model is directly converted from openpose caffemodel by caffemodel2pytorch. You could implement face keypoint detection in the same way if you are interested in. Pay attention to that the face keypoint detector was trained using the procedure described in [Simon et al. 2017] for hands.

openpose detects hand by the result of body pose estimation, please refer to the code of handDetector.cpp. In the paper, it states as:

This is an important detail: to use the keypoint detector in any practical situation, 
we need a way to generate this bounding box. 
We directly use the body pose estimation models from [29] and [4], 
and use the wrist and elbow position to approximate the hand location, 
assuming the hand extends 0.15 times the length of the forearm in the same direction.

If anybody wants a pure python wrapper, please refer to my pytorch implementation of openpose, maybe it helps you to implement a standalone hand keypoint detector.

Don't be mean to star this repo if it helps your research.

Getting Started

Install Requriements

Create a python 3.7 environement, eg:

conda create -n pytorch-openpose python=3.7
conda activate pytorch-openpose

Install pytorch by following the quick start guide here (use pip) https://download.pytorch.org/whl/torch_stable.html

Install other requirements with pip

pip install -r requirements.txt

Download the Models

*.pth files are pytorch model, you could also download caffemodel file if you want to use caffe as backend.

Download the pytorch models and put them in a directory named model in the project root directory

Run the Demo

Run:

python demo_camera.py

to run a demo with a feed from your webcam or run

python demo.py

to use a image from the images folder or run

python demo_video.py <video-file>

to process a video file (requires ffmpeg-python).

Todo list

  • convert caffemodel to pytorch.
  • Body Pose Estimation.
  • Hand Pose Estimation.
  • Performance test.
  • Speed up.

Demo

Skeleton

Body Pose Estimation

Hand Pose Estimation

Body + Hand

Video Body

Attribution: this video.

Video Hand

Attribution: this video.

Citation

Please cite these papers in your publications if it helps your research (the face keypoint detector was trained using the procedure described in [Simon et al. 2017] for hands):

@inproceedings{cao2017realtime,
  author = {Zhe Cao and Tomas Simon and Shih-En Wei and Yaser Sheikh},
  booktitle = {CVPR},
  title = {Realtime Multi-Person 2D Pose Estimation using Part Affinity Fields},
  year = {2017}
}

@inproceedings{simon2017hand,
  author = {Tomas Simon and Hanbyul Joo and Iain Matthews and Yaser Sheikh},
  booktitle = {CVPR},
  title = {Hand Keypoint Detection in Single Images using Multiview Bootstrapping},
  year = {2017}
}

@inproceedings{wei2016cpm,
  author = {Shih-En Wei and Varun Ramakrishna and Takeo Kanade and Yaser Sheikh},
  booktitle = {CVPR},
  title = {Convolutional pose machines},
  year = {2016}
}
Comments
  • Add script to process video files

    Add script to process video files

    I wrote a script to process video files and add the pose annotations. It processes frame by frame and it's not very fast but it works. Also, I had to add a line for numerical stability in src/body.py because I hit zero division errors.

    opened by gngdb 3
  • ZeroDivisionError: float division by zero in body.py

    ZeroDivisionError: float division by zero in body.py

    Thanks for your great work!

    When I run the demo.py with a change of test_image = 'images/090932040.jpg', there is an error :

    body.py:123: RuntimeWarning: invalid value encountered in true_divide
      vec = np.divide(vec, norm)
    Traceback (most recent call last):
      File "demo.py", line 16, in <module>
        candidate, subset = body_estimation(oriImg)
      File "src\body.py", line 135, in __call__
        0.5 * oriImg.shape[0] / norm - 1, 0)
    ZeroDivisionError: float division by zero
    

    090932040

    This is the image I used. Could you help me with the error?

    opened by hankroldd 3
  • Is this available for commercial work?

    Is this available for commercial work?

    Hi, Appreciations for such a nice work!!

    I was looking this project and noticed that you didn't add any license to this project. I want to know whether this can be used for commercial projects or not.

    I searched in official Openpose and found out that they don't offer commercial license for free.

    Since your project is a derivative of their work, so it's owned by CMU based on the license of openpose. Could you look this issue from OpenPose repo for more detail?

    Also, we can't use their pretrained model which follows the same license as their code, this is the issue, I'm referring to. Since you converted their Caffe model to PyTorch model, it's kind of derivative of their work only and as per their license, your work is CMU's work if used commercially and CMU's Openpose license apply by default.

    So, this or any other implementation of Openpose can't be used commercially!

    What do you think about this?

    opened by kartikeyporwal 3
  • 3D real-time single-person keypoint detection using 3D triangulation from multiple single views

    3D real-time single-person keypoint detection using 3D triangulation from multiple single views

    I'm especially interested in the 3D real-time single-person keypoint detection using 3D triangulation which is available in the original OpenPose Caffe. I read in the README that you used caffemodel2pytorch for converting this code from Caffe. Could you maybe give some more details on this? So I could also convert the 3D triangulation code from the original repo?

    Thanks in advance!

    opened by JeremyKeusters 2
  • Understading the candiate indexes

    Understading the candiate indexes

    Hi

    Thanks for the great work. Can you tell me what are 3rd and 4th column in the candidate vector returned from body_estimation() model. The first two are x and y coordinates I guess.

    opened by saniazahan 1
  • ZeroDivisionError: float division by zero in body.py

    ZeroDivisionError: float division by zero in body.py

    RuntimeWarning: invalid value encountered in true_divide vec = np.divide(vec, norm) Traceback (most recent call last): File "demo.py", line 16, in candidate, subset = body_estimation(oriImg) File "src\body.py", line 135, in call 0.5 * oriImg.shape[0] / norm - 1, 0) ZeroDivisionError: float division by zero

    opened by Adeel-Intizar 1
  • Error in hand tracking on video

    Error in hand tracking on video

    Hey i am running into a very weird issue where i used the model to estimate poses from a video stream it works on the first frame but fails after that with this error..

    label_img, label_numbers = label(binary, return_num=True, connectivity = binary.ndim)
    TypeError: 'str' object is not callable
    

    Any guidance you can provide on the most probable cause of the error would be very helpful thanks!

    opened by mehulsuresh 1
  • 样例代码里面,有个candidate字段无法解析。

    样例代码里面,有个candidate字段无法解析。

    https://www.paddlepaddle.org.cn/hubdetail?name=openpose_body_estimation&en_category=KeyPointDetection

    人体关键点检测的服务部署部分代码,

    canvas = base64_to_cv2(r.json()["results"]['data']) cv2.imwrite('keypoint_body.png', canvas)

    确实可以把data字段解析出来,但是candidate用 base64_to_cv2 解析出来,压根没有可读性。candidate本来表示的是21个关键点的位置,可是用canvas = base64_to_cv2(r.json()["results"]['candidate']) 算出来,数据很奇怪,压根不是预测出来的关键点的位置序列。

    各位大佬,是如何解析出来这个 r.json()["results"]['candidate'] 字段并且可解释里面字段的含义呢?

    opened by austinxln 0
  • Add section to readme how to setup the environment and improve imports

    Add section to readme how to setup the environment and improve imports

    Hi,

    thank you for your repository!

    I added info on how to install the requirements and get started with the demo to the readme. I also improved the imports by removing the sys.path.insert() line and adding a __init__.py, so the directory gets recognized as a module by python. I also renamed the python directory to src as it might be confusing when running from python import ...

    Cheers, Fabian

    opened by FabianHertwig 0
  • How can I fix the FPS at 10?

    How can I fix the FPS at 10?

    First of all, thank you for creating this code. I am currently working on a video and the FPS value is not stable. Therefore, I would like to fix the FPS at 10. I would like to know what position and what kind of code I should write.

    opened by konntamonn 0
  • FileNotFoundError: [WinError 2] 系统找不到指定的文件。

    FileNotFoundError: [WinError 2] 系统找不到指定的文件。

    C:\Users\a505s.conda\envs\pytorch-openpose\lib\site-packages\torchvision\io\image.py:13: UserWarning: Failed to load image Python extension: warn(f"Failed to load image Python extension: {e}") Traceback (most recent call last): File "F:\pytorch-openpose\demo_video.py", line 77, in ffprobe_result = ffprobe(args.file) File "F:\pytorch-openpose\demo_video.py", line 31, in ffprobe result = subprocess.run(command_array, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) File "C:\Users\a505s.conda\envs\pytorch-openpose\lib\subprocess.py", line 488, in run with Popen(*popenargs, **kwargs) as process: File "C:\Users\a505s.conda\envs\pytorch-openpose\lib\subprocess.py", line 800, in init restore_signals, start_new_session) File "C:\Users\a505s.conda\envs\pytorch-openpose\lib\subprocess.py", line 1207, in _execute_child startupinfo) FileNotFoundError: [WinError 2] 系统找不到指定的文件。

    HELP!!

    opened by zhangtsingtsi 5
  • What values are in the paf and heatmap?

    What values are in the paf and heatmap?

    Hello. What values are stored in the variables heatmap and paf that are calculated in the body.py program? Why is the number of sizes in heatmap and paf larger than the number of sizes of the loaded images? For example, the shape of the loaded image is (480, 640, 3), but the heatmap is (480, 640, 19) and the paf is (480, 640, 38).

    opened by shimakei3302 0
  • python demo_video.py

    python demo_video.py "****.mp4" occurs to error called OSFailed

    python demo_video.py --file "PXL_20220824_135947155.mp4" ffmpeg version 5.0.1-essentials_build-www.gyan.dev Copyright (c) 2000-2022 the FFmpeg developers built with gcc 11.2.0 (Rev7, Built by MSYS2 project) configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutl s --enable-libxml2 --enable-gmp --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libweb p --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-libfreetype --enable-lib fribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nve nc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberband libavutil 57. 17.100 / 57. 17.100 libavcodec 59. 18.100 / 59. 18.100 libavformat 59. 16.100 / 59. 16.100 libavdevice 59. 4.100 / 59. 4.100 libavfilter 8. 24.100 / 8. 24.100 libswscale 6. 4.100 / 6. 4.100 libswresample 4. 3.100 / 4. 3.100 libpostproc 56. 3.100 / 56. 3.100 Input #0, rawvideo, from 'pipe:': Duration: N/A, start: 0.000000, bitrate: 589938 kb/s Stream #0:0: Video: rawvideo (BGR[24] / 0x18524742), bgr24, 853x480, 589938 kb/s, 60.04 tbr, 60.04 tbn Stream mapping: Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264)) [swscaler @ 00000214048bb9c0] [swscaler @ 00000214048d23c0] deprecated pixel format used, make sure you did set range correctly [swscaler @ 00000214048bb9c0] [swscaler @ 000002140491d780] deprecated pixel format used, make sure you did set range correctly [swscaler @ 00000214048bb9c0] [swscaler @ 0000021404aad580] deprecated pixel format used, make sure you did set range correctly [swscaler @ 00000214048bb9c0] [swscaler @ 0000021404af1d00] deprecated pixel format used, make sure you did set range correctly [swscaler @ 00000214048bb9c0] [swscaler @ 0000021404b36180] deprecated pixel format used, make sure you did set range correctly [swscaler @ 00000214048bb9c0] [swscaler @ 0000021404b83180] deprecated pixel format used, make sure you did set range correctly [swscaler @ 00000214048bb9c0] [swscaler @ 0000021404bc6c00] deprecated pixel format used, make sure you did set range correctly [swscaler @ 00000214048bb9c0] [swscaler @ 0000021404c12e80] deprecated pixel format used, make sure you did set range correctly [swscaler @ 00000214048bb9c0] [swscaler @ 0000021404c3fe80] deprecated pixel format used, make sure you did set range correctly [swscaler @ 00000214048bb9c0] [swscaler @ 0000021404ca00c0] deprecated pixel format used, make sure you did set range correctly [swscaler @ 00000214048bb9c0] [swscaler @ 0000021404d02040] deprecated pixel format used, make sure you did set range correctly [swscaler @ 00000214048bb9c0] [swscaler @ 0000021404d52040] deprecated pixel format used, make sure you did set range correctly [swscaler @ 00000214048bb9c0] [swscaler @ 0000021404d60cc0] deprecated pixel format used, make sure you did set range correctly [swscaler @ 00000214048bb9c0] [swscaler @ 0000021404dd7040] deprecated pixel format used, make sure you did set range correctly [swscaler @ 00000214048bb9c0] [swscaler @ 0000021404df0740] deprecated pixel format used, make sure you did set range correctly [swscaler @ 00000214048bb9c0] [swscaler @ 0000021404e56040] deprecated pixel format used, make sure you did set range correctly [swscaler @ 00000214048bb9c0] [swscaler @ 0000021404e7b040] deprecated pixel format used, make sure you did set range correctly [libx264 @ 000002140486f000] width not divisible by 2 (853x480) Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height Conversion failed! Traceback (most recent call last): File "D:\project\OpenPose\demo_video.py", line 133, in writer(posed_frame) File "D:\project\OpenPose\demo_video.py", line 109, in call self.ff_proc.stdin.write(frame.tobytes()) OSError: [Errno 22] Invalid argument

    how to solve it?please. 怎么解决这个问题,是ffmpeg-python的错误吗

    opened by bibibabibo26 2
Owner
Hzzone
To be talented & positive.
Hzzone
FrankMocap: A Strong and Easy-to-use Single View 3D Hand+Body Pose Estimator

FrankMocap pursues an easy-to-use single view 3D motion capture system developed by Facebook AI Research (FAIR). FrankMocap provides state-of-the-art 3D pose estimation outputs for body, hand, and body+hands in a single system. The core objective of FrankMocap is to democratize the 3D human pose estimation technology, enabling anyone (researchers, engineers, developers, artists, and others) can easily obtain 3D motion capture outputs from videos and images.

Facebook Research 1.9k Jan 7, 2023
Human POSEitioning System (HPS): 3D Human Pose Estimation and Self-localization in Large Scenes from Body-Mounted Sensors, CVPR 2021

Human POSEitioning System (HPS): 3D Human Pose Estimation and Self-localization in Large Scenes from Body-Mounted Sensors Human POSEitioning System (H

Aymen Mir 66 Dec 21, 2022
HPRNet: Hierarchical Point Regression for Whole-Body Human Pose Estimation

HPRNet: Hierarchical Point Regression for Whole-Body Human Pose Estimation Official PyTroch implementation of HPRNet. HPRNet: Hierarchical Point Regre

Nermin Samet 53 Dec 4, 2022
Demo for Real-time RGBD-based Extended Body Pose Estimation paper

Real-time RGBD-based Extended Body Pose Estimation This repository is a real-time demo for our paper that was published at WACV 2021 conference The ou

Renat Bashirov 118 Dec 26, 2022
Expressive Body Capture: 3D Hands, Face, and Body from a Single Image

Expressive Body Capture: 3D Hands, Face, and Body from a Single Image [Project Page] [Paper] [Supp. Mat.] Table of Contents License Description Fittin

Vassilis Choutas 1.3k Jan 7, 2023
Full body anonymization - Realistic Full-Body Anonymization with Surface-Guided GANs

Realistic Full-Body Anonymization with Surface-Guided GANs This is the official

Håkon Hukkelås 30 Nov 18, 2022
WormMovementSimulation - 3D Simulation of Worm Body Movement with Neurons attached to its body

Generate 3D Locomotion Data This module is intended to create 2D video trajector

null 1 Aug 9, 2022
A gesture recognition system powered by OpenPose, k-nearest neighbours, and local outlier factor.

OpenHands OpenHands is a gesture recognition system powered by OpenPose, k-nearest neighbours, and local outlier factor. Currently the system can iden

Paul Treanor 12 Jan 10, 2022
Re-implementation of the Noise Contrastive Estimation algorithm for pyTorch, following "Noise-contrastive estimation: A new estimation principle for unnormalized statistical models." (Gutmann and Hyvarinen, AISTATS 2010)

Noise Contrastive Estimation for pyTorch Overview This repository contains a re-implementation of the Noise Contrastive Estimation algorithm, implemen

Denis Emelin 42 Nov 24, 2022
SE3 Pose Interp - Interpolate camera pose or trajectory in SE3, pose interpolation, trajectory interpolation

SE3 Pose Interpolation Pose estimated from SLAM system are always discrete, and

Ran Cheng 4 Dec 15, 2022
Simple Pose: Rethinking and Improving a Bottom-up Approach for Multi-Person Pose Estimation

SimplePose Code and pre-trained models for our paper, “Simple Pose: Rethinking and Improving a Bottom-up Approach for Multi-Person Pose Estimation”, a

Jia Li 256 Dec 24, 2022
A hand tracking demo made with mediapipe where you can control lights with pinching your fingers and moving your hand up/down.

HandTrackingBrightnessControl A hand tracking demo made with mediapipe where you can control lights with pinching your fingers and moving your hand up

Teemu Laurila 19 Feb 12, 2022
MohammadReza Sharifi 27 Dec 13, 2022
Repository for the paper "PoseAug: A Differentiable Pose Augmentation Framework for 3D Human Pose Estimation", CVPR 2021.

PoseAug: A Differentiable Pose Augmentation Framework for 3D Human Pose Estimation Code repository for the paper: PoseAug: A Differentiable Pose Augme

Pyjcsx 328 Dec 17, 2022
This repository contains codes of ICCV2021 paper: SO-Pose: Exploiting Self-Occlusion for Direct 6D Pose Estimation

SO-Pose This repository contains codes of ICCV2021 paper: SO-Pose: Exploiting Self-Occlusion for Direct 6D Pose Estimation This paper is basically an

shangbuhuan 52 Nov 25, 2022
Python scripts for performing 3D human pose estimation using the Mobile Human Pose model in ONNX.

Python scripts for performing 3D human pose estimation using the Mobile Human Pose model in ONNX.

Ibai Gorordo 99 Dec 31, 2022
Hand-distance-measurement-game - Hand Distance Measurement Game

Hand Distance Measurement Game This is program is made to calculate the distance

Priyansh 2 Jan 12, 2022
Face and Pose detector that emits MQTT events when a face or human body is detected and not detected.

Face Detect MQTT Face or Pose detector that emits MQTT events when a face or human body is detected and not detected. I built this as an alternative t

Jacob Morris 38 Oct 21, 2022
Web service for facial landmark detection, head pose estimation, facial action unit recognition, and eye-gaze estimation based on OpenFace 2.0

OpenGaze: Web Service for OpenFace Facial Behaviour Analysis Toolkit Overview OpenFace is a fantastic tool intended for computer vision and machine le

Sayom Shakib 4 Nov 3, 2022