Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added possibility to use it as a module in other projects #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
4 changes: 2 additions & 2 deletions src/body.py → build/lib/openpose/body.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import torch
from torchvision import transforms

from src import util
from src.model import bodypose_model
from openpose import util
from openpose.model import bodypose_model

class Body(object):
def __init__(self, model_path):
Expand Down
4 changes: 2 additions & 2 deletions src/hand.py → build/lib/openpose/hand.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import torch
from skimage.measure import label

from src.model import handpose_model
from src import util
from openpose.model import handpose_model
from openpose import util

class Hand(object):
def __init__(self, model_path):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from tqdm import tqdm
import json

from src.model import handpose_model
from openpose.model import handpose_model

model = handpose_model()

Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import copy
import numpy as np

from src import model
from src import util
from src.body import Body
from src.hand import Hand
from openpose import model
from openpose import util
from openpose.body import Body
from openpose.hand import Hand

body_estimation = Body('model/body_pose_model.pth')
hand_estimation = Hand('model/hand_pose_model.pth')
Expand Down
8 changes: 4 additions & 4 deletions demo_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import numpy as np
import torch

from src import model
from src import util
from src.body import Body
from src.hand import Hand
from openpose import model
from openpose import util
from openpose.body import Body
from openpose.hand import Hand

body_estimation = Body('model/body_pose_model.pth')
hand_estimation = Hand('model/hand_pose_model.pth')
Expand Down
Binary file added dist/openpose-0.1.0-py3-none-any.whl
Binary file not shown.
Binary file added dist/openpose-0.1.0.tar.gz
Binary file not shown.
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[build-system]
requires = ["setuptools>=61.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "openpose"
readme = "README.md"
version = "0.1.0"

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}
124 changes: 124 additions & 0 deletions src/openpose.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
Metadata-Version: 2.1
Name: openpose
Version: 0.1.0
Description-Content-Type: text/markdown

## pytorch-openpose

pytorch implementation of [openpose](https://github.com/CMU-Perceptual-Computing-Lab/openpose) including **Body and Hand Pose Estimation**, and the pytorch model is directly converted from [openpose](https://github.com/CMU-Perceptual-Computing-Lab/openpose) caffemodel by [caffemodel2pytorch](https://github.com/vadimkantorov/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](https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/src/openpose/hand/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](https://github.com/Hzzone/pytorch-openpose) 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

* [dropbox](https://www.dropbox.com/sh/7xbup2qsn7vvjxo/AABWFksdlgOMXR_r5v3RwKRYa?dl=0)
* [baiduyun](https://pan.baidu.com/s/1IlkvuSi0ocNckwbnUe7j-g)
* [google drive](https://drive.google.com/drive/folders/1JsvI4M4ZTg98fmnCZLFM-3TeovnCRElG?usp=sharing)

`*.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][ffmpeg]).

[ffmpeg]: https://pypi.org/project/ffmpeg-python/

### Todo list
- [x] convert caffemodel to pytorch.
- [x] Body Pose Estimation.
- [x] Hand Pose Estimation.
- [ ] Performance test.
- [ ] Speed up.

### Demo
#### Skeleton

![](images/skeleton.jpg)
#### Body Pose Estimation

![](images/body_preview.jpg)

#### Hand Pose Estimation
![](images/hand_preview.png)

#### Body + Hand
![](images/demo_preview.png)

#### Video Body

![](images/kc-e129SBb4-sample.processed.gif)

Attribution: [this video](https://www.youtube.com/watch?v=kc-e129SBb4).

#### Video Hand

![](images/yOAmYSW3WyU-sample.small.processed.gif)

Attribution: [this video](https://www.youtube.com/watch?v=yOAmYSW3WyU).

### 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}
}
```
12 changes: 12 additions & 0 deletions src/openpose.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
README.md
pyproject.toml
src/openpose/__init__.py
src/openpose/body.py
src/openpose/hand.py
src/openpose/hand_model_outputsize.py
src/openpose/model.py
src/openpose/util.py
src/openpose.egg-info/PKG-INFO
src/openpose.egg-info/SOURCES.txt
src/openpose.egg-info/dependency_links.txt
src/openpose.egg-info/top_level.txt
1 change: 1 addition & 0 deletions src/openpose.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions src/openpose.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
openpose
Empty file added src/openpose/__init__.py
Empty file.
Loading