Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: chtarun/deep-high-resolution-net.pytorch
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: leoxiaobin/deep-high-resolution-net.pytorch
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 13 commits
  • 16 files changed
  • 6 contributors

Commits on Feb 1, 2020

  1. add demo code (leoxiaobin#161)

    * add demo code
    
    * demo code review update: use BGR for pose model
    
    * demo code review update 2
    alex9311 authored Feb 1, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    e00377a View commit details
  2. Update README.md

    leoxiaobin authored Feb 1, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    015c946 View commit details

Commits on Feb 24, 2020

  1. unify addressing to cfg, reuse cfg['MODEL']['EXTRA']

    some data retrieving from cfg looks like retrieving from dict, some like from Namespace's instance or custom class' instance
    "extra" is defined, why does the code ignore it later?
    NickVeld authored and leoxiaobin committed Feb 24, 2020
    Copy the full SHA
    9475032 View commit details
  2. Update REAME

    leoxiaobin authored Feb 24, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    bf4e9c5 View commit details

Commits on Mar 13, 2020

  1. Update README.md

    welleast authored Mar 13, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b73a31e View commit details

Commits on Mar 26, 2020

  1. Update README.md

    welleast authored Mar 26, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    aaecb0f View commit details
  2. Update README.md

    welleast authored Mar 26, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    be81104 View commit details

Commits on Apr 3, 2020

  1. Re-write demo/inference.py

    * Now can work with multiple person
    * Don't need the docker
    * Force people detection and pose estimation to be executed on same context (gpu or cpu)
    * Add same example output
    gachiemchiep authored and leoxiaobin committed Apr 3, 2020
    Copy the full SHA
    69934d5 View commit details

Commits on Jul 15, 2020

  1. Update README.md

    leoxiaobin authored Jul 15, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ba50a82 View commit details

Commits on Apr 12, 2021

  1. Add the HRNet-DEKR link

    welleast authored Apr 12, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    1ee551d View commit details

Commits on May 19, 2021

  1. Copy the full SHA
    00616df View commit details
  2. update demo/README.md

    CrystalSixone authored and leoxiaobin committed May 19, 2021
    Copy the full SHA
    ce8f362 View commit details

Commits on Dec 14, 2022

  1. Update README.md

    Add implementation of timm and modelscope.
    leoxiaobin authored Dec 14, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    6f69e46 View commit details
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Deep High-Resolution Representation Learning for Human Pose Estimation (CVPR 2019)
## News
- [2021/04/12] Welcome to check out our recent work on bottom-up pose estimation (CVPR 2021) [HRNet-DEKR](https://github.com/HRNet/DEKR)!
- [2020/07/05] [A very nice blog](https://towardsdatascience.com/overview-of-human-pose-estimation-neural-networks-hrnet-higherhrnet-architectures-and-faq-1954b2f8b249) from Towards Data Science introducing HRNet and HigherHRNet for human pose estimation.
- [2020/03/13] A longer version is accepted by TPAMI: [Deep High-Resolution Representation Learning for Visual Recognition](https://arxiv.org/pdf/1908.07919.pdf). It includes more HRNet applications, and the codes are available: [semantic segmentation](https://github.com/HRNet/HRNet-Semantic-Segmentation), [objection detection](https://github.com/HRNet/HRNet-Object-Detection), [facial landmark detection](https://github.com/HRNet/HRNet-Facial-Landmark-Detection), and [image classification](https://github.com/HRNet/HRNet-Image-Classification).
- [2020/02/01] We have added demo code for HRNet. Thanks [Alex Simes](https://github.com/alex9311).
- Visualization code for showing the pose estimation results. Thanks Depu!
- If you are interested in internship or research positions related to computer vision in ByteDance AI Lab, feel free to contact me(leoxiaobin-at-gmail.com).
- [2019/08/27] HigherHRNet is now on [ArXiv](https://arxiv.org/abs/1908.10357), which is a bottom-up approach for human pose estimation powerd by HRNet. We will also release code and models at [Higher-HRNet-Human-Pose-Estimation](https://github.com/HRNet/Higher-HRNet-Human-Pose-Estimation), stay tuned!
- Our new work [High-Resolution Representations for Labeling Pixels and Regions](https://arxiv.org/abs/1904.04514) is available at [HRNet](https://github.com/HRNet). Our HRNet has been applied to a wide range of vision tasks, such as [image classification](https://github.com/HRNet/HRNet-Image-Classification), [objection detection](https://github.com/HRNet/HRNet-Object-Detection), [semantic segmentation](https://github.com/HRNet/HRNet-Semantic-Segmentation) and [facial landmark](https://github.com/HRNet/HRNet-Facial-Landmark-Detection).

@@ -239,6 +242,12 @@ python visualization/plot_coco.py \
### Other applications
Many other dense prediction tasks, such as segmentation, face alignment and object detection, etc. have been benefited by HRNet. More information can be found at [High-Resolution Networks](https://github.com/HRNet).

### Other implementation
[mmpose](https://github.com/open-mmlab/mmpose) </br>
[ModelScope (中文)](https://modelscope.cn/models/damo/cv_hrnetv2w32_body-2d-keypoints_image/summary)</br>
[timm](https://huggingface.co/docs/timm/main/en/models/hrnet)


### Citation
If you use our code or models in your research, please cite with:
```
@@ -261,8 +270,7 @@ If you use our code or models in your research, please cite with:
author={Jingdong Wang and Ke Sun and Tianheng Cheng and
Borui Jiang and Chaorui Deng and Yang Zhao and Dong Liu and Yadong Mu and
Mingkui Tan and Xinggang Wang and Wenyu Liu and Bin Xiao},
journal = {CoRR},
volume = {abs/1908.07919},
journal = {TPAMI}
year={2019}
}
```
3 changes: 3 additions & 0 deletions demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output
models
videos
112 changes: 112 additions & 0 deletions demo/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
FROM nvidia/cuda:10.2-cudnn7-devel-ubuntu16.04

ENV OPENCV_VERSION="3.4.6"

# Basic toolchain
RUN apt-get update && apt-get install -y \
apt-utils \
build-essential \
git \
wget \
unzip \
yasm \
pkg-config \
libcurl4-openssl-dev \
zlib1g-dev \
htop \
cmake \
nano \
python3-pip \
python3-dev \
python3-tk \
libx264-dev \
&& cd /usr/local/bin \
&& ln -s /usr/bin/python3 python \
&& pip3 install --upgrade pip \
&& apt-get autoremove -y

# Getting OpenCV dependencies available with apt
RUN apt-get update && apt-get install -y \
libeigen3-dev \
libjpeg-dev \
libpng-dev \
libtiff-dev \
libjasper-dev \
libswscale-dev \
libavcodec-dev \
libavformat-dev && \
apt-get autoremove -y

# Getting other dependencies
RUN apt-get update && apt-get install -y \
cppcheck \
graphviz \
doxygen \
p7zip-full \
libdlib18 \
libdlib-dev && \
apt-get autoremove -y


# Install OpenCV + OpenCV contrib (takes forever)
RUN mkdir -p /tmp && \
cd /tmp && \
wget --no-check-certificate -O opencv.zip https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip && \
wget --no-check-certificate -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip && \
unzip opencv.zip && \
unzip opencv_contrib.zip && \
mkdir opencv-${OPENCV_VERSION}/build && \
cd opencv-${OPENCV_VERSION}/build && \
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D WITH_CUDA=ON \
-D CUDA_FAST_MATH=1 \
-D WITH_CUBLAS=1 \
-D WITH_FFMPEG=ON \
-D WITH_OPENCL=ON \
-D WITH_V4L=ON \
-D WITH_OPENGL=ON \
-D OPENCV_EXTRA_MODULES_PATH=/tmp/opencv_contrib-${OPENCV_VERSION}/modules \
.. && \
make -j$(nproc) && \
make install && \
echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf && \
ldconfig && \
cd /tmp && \
rm -rf opencv-${OPENCV_VERSION} opencv.zip opencv_contrib-${OPENCV_VERSION} opencv_contrib.zip && \
cd /

# Compile and install ffmpeg from source
RUN git clone https://github.com/FFmpeg/FFmpeg /root/ffmpeg && \
cd /root/ffmpeg && \
./configure --enable-gpl --enable-libx264 --enable-nonfree --disable-shared --extra-cflags=-I/usr/local/include && \
make -j8 && make install -j8

# clone deep-high-resolution-net
ARG POSE_ROOT=/pose_root
RUN git clone https://github.com/leoxiaobin/deep-high-resolution-net.pytorch.git $POSE_ROOT
WORKDIR $POSE_ROOT
RUN mkdir output && mkdir log

RUN pip3 install -r requirements.txt && \
pip3 install torch==1.1.0 \
torchvision==0.3.0 \
opencv-python \
pillow==6.2.1

# build deep-high-resolution-net lib
WORKDIR $POSE_ROOT/lib
RUN make

# install COCO API
ARG COCOAPI=/cocoapi
RUN git clone https://github.com/cocodataset/cocoapi.git $COCOAPI
WORKDIR $COCOAPI/PythonAPI
# Install into global site-packages
RUN make install

# download fastrrnn pretrained model for person detection
RUN python -c "import torchvision; model = torchvision.models.detection.fasterrcnn_resnet50_fpn(pretrained=True); model.eval()"

COPY inference.py $POSE_ROOT/tools
COPY inference-config.yaml $POSE_ROOT/
75 changes: 75 additions & 0 deletions demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Inference hrnet

Inferencing the deep-high-resolution-net.pytoch without using Docker.

## Prep
1. Download the researchers' pretrained pose estimator from [google drive](https://drive.google.com/drive/folders/1hOTihvbyIxsm5ygDpbUuJ7O_tzv4oXjC?usp=sharing) to this directory under `models/`
2. Put the video file you'd like to infer on in this directory under `videos`
3. (OPTIONAL) build the docker container in this directory with `./build-docker.sh` (this can take time because it involves compiling opencv)
4. update the `inference-config.yaml` file to reflect the number of GPUs you have available and which trained model you want to use.

## Running the Model
### 1. Running on the video
```
python demo/inference.py --cfg demo/inference-config.yaml \
--videoFile ../../multi_people.mp4 \
--writeBoxFrames \
--outputDir output \
TEST.MODEL_FILE ../models/pytorch/pose_coco/pose_hrnet_w32_256x192.pth
```

The above command will create a video under *output* directory and a lot of pose image under *output/pose* directory.
Even with usage of GPU (GTX1080 in my case), the person detection will take nearly **0.06 sec**, the person pose match will
take nearly **0.07 sec**. In total. inference time per frame will be **0.13 sec**, nearly 10fps. So if you prefer a real-time (fps >= 20)
pose estimation then you should try other approach.

**===Result===**

Some output images are as:

![1 person](inference_1.jpg)
Fig: 1 person inference

![3 person](inference_3.jpg)
Fig: 3 person inference

![3 person](inference_5.jpg)
Fig: 3 person inference

### 2. Demo with more common functions
Remember to update` TEST.MODEL_FILE` in `demo/inference-config.yaml `according to your model path.

`demo.py` provides the following functions:

- use `--webcam` when the input is a real-time camera.
- use `--video [video-path]` when the input is a video.
- use `--image [image-path]` when the input is an image.
- use `--write` to save the image, camera or video result.
- use `--showFps` to show the fps (this fps includes the detection part).
- draw connections between joints.

#### (1) the input is a real-time carema
```python
python demo/demo.py --webcam --showFps --write
```

#### (2) the input is a video
```python
python demo/demo.py --video test.mp4 --showFps --write
```
#### (3) the input is a image

```python
python demo/demo.py --image test.jpg --showFps --write
```

**===Result===**

![show_fps](inference_6.jpg)

Fig: show fps

![multi-people](inference_7.jpg)

Fig: multi-people
27 changes: 27 additions & 0 deletions demo/_init_paths.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# ------------------------------------------------------------------------------
# pose.pytorch
# Copyright (c) 2018-present Microsoft
# Licensed under The Apache-2.0 License [see LICENSE for details]
# Written by Bin Xiao (Bin.Xiao@microsoft.com)
# ------------------------------------------------------------------------------

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import os.path as osp
import sys


def add_path(path):
if path not in sys.path:
sys.path.insert(0, path)


this_dir = osp.dirname(__file__)

lib_path = osp.join(this_dir, '..', 'lib')
add_path(lib_path)

mm_path = osp.join(this_dir, '..', 'lib/poseeval/py-motmetrics')
add_path(mm_path)
1 change: 1 addition & 0 deletions demo/build-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker build -t hrnet_demo_inference .
Loading