-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from PaddlePaddle/develop
update
- Loading branch information
Showing
598 changed files
with
80,754 additions
and
55,452 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,13 +9,13 @@ This is a simple demonstration of re-implementation in [PaddlePaddle.Fluid](http | |
## Requirements | ||
|
||
- Python == 2.7 | ||
- PaddlePaddle >= 1.1.0 | ||
- Python == 2.7 or 3.6 | ||
- PaddlePaddle >= 1.1.0 (<= 1.3.0) | ||
- opencv-python >= 3.3 | ||
|
||
## Environment | ||
|
||
The code is developed and tested under 4 Tesla K40/P40 GPUS cards on CentOS with installed CUDA-9.2/8.0 and cuDNN-7.1. | ||
The code is developed and tested under 4 Tesla K40/P40 GPUS cards on CentOS with installed CUDA-9.0/8.0 and cuDNN-7.0. | ||
|
||
## Results on MPII Val | ||
| Arch | Head | Shoulder | Elbow | Wrist | Hip | Knee | Ankle | Mean | [email protected]| Models | | ||
|
@@ -85,19 +85,21 @@ python2 setup.py install --user | |
Downloading the checkpoints of Pose-ResNet-50 trained on MPII dataset from [here](https://paddlemodels.bj.bcebos.com/pose/pose-resnet50-mpii-384x384.tar.gz). Extract it into the folder `checkpoints` under the directory root of this repo. Then run | ||
|
||
```bash | ||
python val.py --dataset 'mpii' --checkpoint 'checkpoints/pose-resnet50-mpii-384x384' | ||
python val.py --dataset 'mpii' --checkpoint 'checkpoints/pose-resnet50-mpii-384x384' --data_root 'data/mpii' | ||
``` | ||
|
||
### Perform Training | ||
|
||
```bash | ||
python train.py --dataset 'mpii' # or coco | ||
python train.py --dataset 'mpii' --data_root 'data/mpii' | ||
``` | ||
|
||
**Note**: Configurations for training are aggregated in the `lib/mpii_reader.py` and `lib/coco_reader.py`. | ||
|
||
### Perform Test on Images | ||
|
||
We also support to apply pre-trained models on customized images. | ||
|
||
Put the images into the folder `test` under the directory root of this repo. Then run | ||
|
||
```bash | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Copyright (c) 2019-present, Baidu, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
############################################################################## | ||
from __future__ import absolute_import | ||
from __future__ import division | ||
from __future__ import print_function | ||
|
||
import numpy as np | ||
|
||
|
||
def oks_iou(g, d, a_g, a_d, sigmas=None, in_vis_thre=None): | ||
if not isinstance(sigmas, np.ndarray): | ||
sigmas = np.array([.26, .25, .25, .35, .35, .79, .79, .72, .72, .62, .62, 1.07, 1.07, .87, .87, .89, .89]) / 10.0 | ||
vars = (sigmas * 2) ** 2 | ||
xg = g[0::3] | ||
yg = g[1::3] | ||
vg = g[2::3] | ||
ious = np.zeros((d.shape[0])) | ||
for n_d in range(0, d.shape[0]): | ||
xd = d[n_d, 0::3] | ||
yd = d[n_d, 1::3] | ||
vd = d[n_d, 2::3] | ||
dx = xd - xg | ||
dy = yd - yg | ||
e = (dx ** 2 + dy ** 2) / vars / ((a_g + a_d[n_d]) / 2 + np.spacing(1)) / 2 | ||
if in_vis_thre is not None: | ||
ind = list(vg > in_vis_thre) and list(vd > in_vis_thre) | ||
e = e[ind] | ||
ious[n_d] = np.sum(np.exp(-e)) / e.shape[0] if e.shape[0] != 0 else 0.0 | ||
return ious | ||
|
||
|
||
def oks_nms(kpts_db, thresh, sigmas=None, in_vis_thre=None): | ||
""" | ||
greedily select boxes with high confidence and overlap with current maximum <= thresh | ||
rule out overlap >= thresh, overlap = oks | ||
:param kpts_db | ||
:param thresh: retain overlap < thresh | ||
:return: indexes to keep | ||
""" | ||
if len(kpts_db) == 0: | ||
return [] | ||
|
||
scores = np.array([kpts_db[i]['score'] for i in range(len(kpts_db))]) | ||
kpts = np.array([kpts_db[i]['keypoints'].flatten() for i in range(len(kpts_db))]) | ||
areas = np.array([kpts_db[i]['area'] for i in range(len(kpts_db))]) | ||
|
||
order = scores.argsort()[::-1] | ||
|
||
keep = [] | ||
while order.size > 0: | ||
i = order[0] | ||
keep.append(i) | ||
|
||
oks_ovr = oks_iou(kpts[i], kpts[order[1:]], areas[i], areas[order[1:]], sigmas, in_vis_thre) | ||
|
||
inds = np.where(oks_ovr <= thresh)[0] | ||
order = order[inds + 1] | ||
|
||
return keep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.