Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffffffli committed Jun 19, 2018
0 parents commit 821acee
Show file tree
Hide file tree
Showing 87 changed files with 165,482 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
human_detection/output
examples/results
PoseFlow/__pycache__
PoseFlow/*.npy
PoseFlow/alpha-pose-results-test.json
PoseFlow/alpha-pose-results-val.json
PoseFlow/test-predict
PoseFlow/val-predict
ssd/examples

*.npy
*.so
*.pyc
.ipynb_checkpoints
*/.ipynb_checkpoints/

*.pth
*.json
*.h5
*.zip

515 changes: 515 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

71 changes: 71 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@

<div align="center">
<img src="doc/logo.jpg", width="400">
</div>


## News!

This is the **beta pytorch** version of AlphaPose. Stable version will be ready in two days. Currently AlphaPose runs at about **5 fps**. Realtime version is coming very soon. Stay tuned!

## AlphaPose
[Alpha Pose](http://www.mvig.org/research/alphapose.html) is an accurate multi-person pose estimator, which is the **first open-source system that achieves 70+ mAP (72.3 mAP) on COCO dataset and 80+ mAP (82.1 mAP) on MPII dataset.**
To match poses that correspond to the same person across frames, we also provide an efficient online pose tracker called Pose Flow. It is the **first open-source online pose tracker that achieves both 60+ mAP (66.5 mAP) and 50+ MOTA (58.3 MOTA) on PoseTrack Challenge dataset.**




## Installation
1. Get the code.
```Shell
git clone -b pytorch https://github.com/MVIG-SJTU/AlphaPose.git

```

2. Install [pytorch](https://github.com/pytorch/pytorch)
```Shell
chmod +x install.sh
./install.sh
```

1. Download the models manually: **fpnssd512_20_trained.pth**([Baidu pan](https://pan.baidu.com/s/10ZQfHAqvn8SdFnPnuEg0fg)), **pyra_4.pth** ([Baidu pan](https://pan.baidu.com/s/13jZRPT21zK5L-cqyfe0Qww)). Place them into `./models/ssd` and `./models/sppe` respectively.


## Quick Start
- **Demo**: Run AlphaPose for all images in a folder and visualize the results with:
```
python demo_fast.py \
--inputlist ./list-coco-minival500.txt \
--imgpath ${img_directory} \
--outputpath ./coco-minival
```



## Contributors
AlphaPose is based on RMPE(ICCV'17), authored by [Hao-shu Fang](https://fang-haoshu.github.io/), Shuqin Xie, [Yu-Wing Tai](https://scholar.google.com/citations?user=nFhLmFkAAAAJ&hl=en) and [Cewu Lu](http://www.mvig.org/), [Cewu Lu](http://mvig.sjtu.edu.cn/) is the corresponding author. Currently, it is developed and maintained by [Hao-shu Fang](https://fang-haoshu.github.io/), [Jiefeng Li](http://jeff-leaf.site/), [Yuliang Xiu](http://xiuyuliang.cn/about/) and [Ruiheng Chang](https://crh19970307.github.io/).

The main contributors are listed in [doc/contributors.md](doc/contributors.md).

## Citation
Please cite these papers in your publications if it helps your research:

@inproceedings{fang2017rmpe,
title={{RMPE}: Regional Multi-person Pose Estimation},
author={Fang, Hao-Shu and Xie, Shuqin and Tai, Yu-Wing and Lu, Cewu},
booktitle={ICCV},
year={2017}
}

@ARTICLE{2018arXiv180200977X,
author = {Xiu, Yuliang and Li, Jiefeng and Wang, Haoyu and Fang, Yinghong and Lu, Cewu},
title = {{Pose Flow}: Efficient Online Pose Tracking},
journal = {ArXiv e-prints},
eprint = {1802.00977},
year = {2018}
}



## License
AlphaPose is freely available for free non-commercial use, and may be redistributed under these conditions. For commercial queries, contact [Cewu Lu](http://www.mvig.org/)
2 changes: 2 additions & 0 deletions SPPE/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
114 changes: 114 additions & 0 deletions SPPE/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

.vscode/
*.pkl
exp
exp/*
data
data/*
model
model/*
*/images
*/images/*

*.h5
*.pth

21 changes: 21 additions & 0 deletions SPPE/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Jeff-sjtu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions SPPE/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# pytorch-AlphaPose
Empty file added SPPE/__init__.py
Empty file.
Empty file added SPPE/src/__init__.py
Empty file.
79 changes: 79 additions & 0 deletions SPPE/src/main_fast_inference.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import torch
import torch.nn as nn
import torch.utils.data
import torch.utils.data.distributed
import torch.nn.functional as F
import numpy as np
from opt import opt
import h5py
from tqdm import tqdm
from SPPE.src.utils.img import flip_v, shuffleLR
from SPPE.src.utils.eval import getPrediction
from SPPE.src.models.hgPRM import createModel_Inference

import visdom
import time


import torch._utils
try:
torch._utils._rebuild_tensor_v2
except AttributeError:
def _rebuild_tensor_v2(storage, storage_offset, size, stride, requires_grad, backward_hooks):
tensor = torch._utils._rebuild_tensor(storage, storage_offset, size, stride)
tensor.requires_grad = requires_grad
tensor._backward_hooks = backward_hooks
return tensor
torch._utils._rebuild_tensor_v2 = _rebuild_tensor_v2


torch.backends.cudnn.benchmark = True
batch_size = 128 * 8


def gaussian(size):
sigma = 1
x = np.arange(0, size, 1, float)
y = x[:, np.newaxis]
x0 = y0 = size // 2
sigma = size / 4.0
# The gaussian is not normalized, we want the center value to equal 1
g = np.exp(- ((x - x0) ** 2 + (y - y0) ** 2) / (2 * sigma ** 2))
g = g[np.newaxis, :]
return g


class InferenNet(nn.Module):
def __init__(self, kernel_size, dataset):
super(InferenNet, self).__init__()

model = createModel_Inference().cuda()
print('Loading Model from {}'.format('./models/sppe/pyra_4.pth'))
model.load_state_dict(torch.load('./models/sppe/pyra_4.pth'))
model.eval()
self.pyranet = model
self.gaussian = nn.Conv2d(17, 17, kernel_size=kernel_size,
stride=1, padding=2, groups=17, bias=False)

g = torch.from_numpy(gaussian(kernel_size)).clone()
g = torch.unsqueeze(g, 1)
g = g.repeat(17, 1, 1, 1)
assert g.shape == self.gaussian.weight.data.shape
self.gaussian.weight.data = g.float()

self.dataset = dataset

def forward(self, x):
out = self.pyranet(x)
out = out.narrow(1, 0, 17)

flip_out = self.pyranet(flip_v(x))
flip_out = flip_out.narrow(1, 0, 17)

flip_out = flip_v(shuffleLR(
flip_out, self.dataset))

out = (flip_out + out) / 2
out = self.gaussian(F.relu(out, inplace=True))

return out
1 change: 1 addition & 0 deletions SPPE/src/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import *
Loading

0 comments on commit 821acee

Please sign in to comment.