Home ONNX HRNET Human Pose Estimation
Post
Cancel

Open In GithubOpen In Github

Python scripts for performing 2D human pose estimation using the HRNET family models (HRNET, Lite-HRNet) in ONNX.

!ONNX HRNET 2D Human Pose Estimation Original image: https://en.wikipedia.org/wiki/File:Flickr_-_The_U.S._Army_-_%27cavalry_charge%27.jpg

Important

  • For the multiperson examples, it might be more efficient to collect all the image crops and pass them together to the models that accept multiple image batches (Nxheightxwidth). I do it separately for simplicity.
  • There are more efficient models to perform multi pose estimation, the approach presented here is not optimal.

Requirements

  • Check the requirements.txt file.
  • For ONNX, if you have a NVIDIA GPU, then install the onnxruntime-gpu, otherwise use the onnxruntime library.
  • Additionally, pafy and youtube-dl are required for youtube video inference.

Installation

1
2
3
git clone https://github.com/ibaiGorordo/ONNX-HRNET-Human-Pose-Estimation.git --recursive
cd ONNX-HRNET-Human-Pose-Estimation
pip install -r requirements.txt

ONNX Runtime

For Nvidia GPU computers: pip install onnxruntime-gpu

Otherwise: pip install onnxruntime

For youtube video inference

1
2
pip install youtube_dl
pip install git+[https://github.com/zizo-pro/pafy@b8976f22c19e4ab5515cacbfae0a3970370c102b](https://github.com/zizo-pro/pafy@b8976f22c19e4ab5515cacbfae0a3970370c102b)

ONNX model

The original models were converted to different formats (including .onnx) by PINTO0309. Download the models from the link below and save them into the models folder”

  • HRNET [MIT License]: https://github.com/PINTO0309/PINTO_model_zoo/tree/main/271_HRNet
  • Lite HRNet [Apache 2.0 License]: https://github.com/PINTO0309/PINTO_model_zoo/tree/main/268_Lite-HRNet

YOLOv5 or YOLOv6 ONNX models

For the multiperson examples, both YOLOv5 and YOLOv6 models can be used. You can convert the original models to ONNX using the Google Colab repositories linked below, and save the converted onnx models in to the models folder.

  • YOLOv5 ONNX conversion: Open In Colab
  • YOLOv6 ONNX conversion: Open In Colab

Examples

  • Image Single Pose Estimation:
    1
    
     python image_singlepose_estimation.py
    
  • Image Multi Pose Estimation:
    1
    
     python image_multipose_estimation.py
    
  • Image Single Pose Heatmap:
    1
    
     python image_singlepose_heatmap.py
    
  • Webcam Multi Pose Estimation:
    1
    
     python webcam_multipose_estimation.py
    
  • Video Multi Pose Estimation:
    1
    
     python video_multipose_estimation.py
    

    !HRNET Video Pose Estimation

Original video: https://youtu.be/HI-BMpNByo0

References:

This post is licensed under CC BY 4.0 by the author.