Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
HaziqRazali authored Sep 23, 2019
1 parent c841efd commit cf8d485
Show file tree
Hide file tree
Showing 52 changed files with 4,784 additions and 0 deletions.
9 changes: 9 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# History

* [master](https://github.com/vita-epfl/openpifpaf/compare/v0.6.0...master)
* [0.6.0](https://github.com/vita-epfl/openpifpaf/compare/v0.5.1...v0.6.0) (2019-05-07)
* Torch 1.1.0 compatibility (older versions work but have modified learning rate schedule due to https://github.com/pytorch/pytorch/pull/7889)
* more aggressive NMS
* multi-scale support for `eval_coco`: `--two-scale`, `--three-scale`, `--multi-scale`
* guaranteed complete poses with `--force-complete-pose`
* [0.5.1](https://github.com/vita-epfl/openpifpaf/compare/v0.5.0...v0.5.1) (2019-05-01)
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2019 by EPFL/VITA. All rights reserved.

This project and all its files are licensed under
GNU AGPLv3 or later version.

If this license is not suitable for your business or project
please contact us for a full commercial license.
661 changes: 661 additions & 0 deletions LICENSE.AGPL

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include openpifpaf/functional.pyx
include openpifpaf/functional.c
2 changes: 2 additions & 0 deletions all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

CUDA_VISIBLE_DEVICES="0" python3 -m openpifpaf.video --batch-size 1 --jaad_batch_size 1 --checkpoint outputs/resnet50block5-pif-paf-crm-edge401-190525-002719.pkl.epoch006
3 changes: 3 additions & 0 deletions backprop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CUDA_VISIBLE_DEVICES="0" python3 -m openpifpaf.backprop --batch-size 1 --jaad_batch_size 1 \
--checkpoint outputs/resnet50block5-pif-paf-crm-edge401-190526-203030.pkl.epoch006 \
--jaad_train "singletxt_pre_train_1s" --jaad_val "singletxt_val_1s" --jaad_pre_train "singletxt_pre_train_1s" \
Binary file not shown.
Binary file not shown.
Binary file added docs/coco/000000081988.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/coco/000000081988.jpg.skeleton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions docs/datasets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Datasets

Download MSCOCO data:

```sh
mkdir data-mscoco
cd data-mscoco
gsutil ls gs://images.cocodataset.org # to list available directories

mkdir -p images/val2017
gsutil -m rsync gs://images.cocodataset.org/val2017 images/val2017

mkdir -p images/train2017
gsutil -m rsync gs://images.cocodataset.org/train2017 images/train2017

gsutil cp gs://images.cocodataset.org/annotations/annotations_trainval2017.zip .
# or
wget http://images.cocodataset.org/annotations/annotations_trainval2017.zip
unzip annotations_trainval2017.zip
wget http://images.cocodataset.org/annotations/image_info_test2017.zip
unzip image_info_test2017.zip

# test images: run inside of images directory
wget http://images.cocodataset.org/zips/test2017.zip
unzip test2017.zip
```

Download MPII data:

```sh
mkdir data-mpii
cd data-mpii
wget https://datasets.d2.mpi-inf.mpg.de/andriluka14cvpr/mpii_human_pose_v1.tar.gz
wget https://datasets.d2.mpi-inf.mpg.de/andriluka14cvpr/mpii_human_pose_v1_u12_2.zip
```
2,108 changes: 2,108 additions & 0 deletions docs/decoder_flame.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
248 changes: 248 additions & 0 deletions docs/eval_logs.md

Large diffs are not rendered by default.

Binary file added docs/skeleton_coco.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/skeleton_dense.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/skeleton_kinematic_tree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
317 changes: 317 additions & 0 deletions docs/studies.ipynb

Large diffs are not rendered by default.

Binary file added docs/wave3.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions eval.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

CUDA_VISIBLE_DEVICES="0" python3 -m openpifpaf.eval --batch-size 1 --jaad_batch_size 1 \
--checkpoint outputs/resnet50block5-pif-paf-crm-edge401-190525-002719.pkl.epoch006 \
--truncate 0 \
--final_frame_offset 0 \
--result "trained0s_predict0s_truncated.txt" \
--jaad_train "singletxt_pre_train_0s_truncated" --jaad_val "singletxt_val_0s_truncated" --jaad_pre_train "singletxt_pre_train_0s_truncated"

CUDA_VISIBLE_DEVICES="0" python3 -m openpifpaf.eval --batch-size 1 --jaad_batch_size 1 \
--checkpoint outputs/resnet50block5-pif-paf-crm-edge401-190525-002719.pkl.epoch006 \
--truncate 0 \
--final_frame_offset 0 \
--result "trained0s_predict1s_truncated.txt" \
--jaad_train "singletxt_pre_train_1s_truncated" --jaad_val "singletxt_val_1s_truncated" --jaad_pre_train "singletxt_pre_train_1s_truncated"

CUDA_VISIBLE_DEVICES="0" python3 -m openpifpaf.eval --batch-size 1 --jaad_batch_size 1 \
--checkpoint outputs/resnet50block5-pif-paf-crm-edge401-190525-002719.pkl.epoch006 \
--truncate 0 \
--final_frame_offset 0 \
--result "trained0s_predict2s_truncated.txt" \
--jaad_train "singletxt_pre_train_2s_truncated" --jaad_val "singletxt_val_2s_truncated" --jaad_pre_train "singletxt_pre_train_2s_truncated"

CUDA_VISIBLE_DEVICES="0" python3 -m openpifpaf.eval --batch-size 1 --jaad_batch_size 1 \
--checkpoint outputs/resnet50block5-pif-paf-crm-edge401-190526-203030.pkl.epoch006 \
--truncate 0 \
--final_frame_offset 0 \
--result "trained1s_predict0s_truncated.txt" \
--jaad_train "singletxt_pre_train_0s_truncated" --jaad_val "singletxt_val_0s_truncated" --jaad_pre_train "singletxt_pre_train_0s_truncated"

CUDA_VISIBLE_DEVICES="0" python3 -m openpifpaf.eval --batch-size 1 --jaad_batch_size 1 \
--checkpoint outputs/resnet50block5-pif-paf-crm-edge401-190526-203030.pkl.epoch006 \
--truncate 0 \
--final_frame_offset 0 \
--result "trained1s_predict1s_truncated.txt" \
--jaad_train "singletxt_pre_train_1s_truncated" --jaad_val "singletxt_val_1s_truncated" --jaad_pre_train "singletxt_pre_train_1s_truncated"

CUDA_VISIBLE_DEVICES="0" python3 -m openpifpaf.eval --batch-size 1 --jaad_batch_size 1 \
--checkpoint outputs/resnet50block5-pif-paf-crm-edge401-190526-203030.pkl.epoch006 \
--truncate 0 \
--final_frame_offset 0 \
--result "trained1s_predict2s_truncated.txt" \
--jaad_train "singletxt_pre_train_2s_truncated" --jaad_val "singletxt_val_2s_truncated" --jaad_pre_train "singletxt_pre_train_2s_truncated"
1 change: 1 addition & 0 deletions eval_coco.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CUDA_VISIBLE_DEVICES=None python3 -m openpifpaf.eval_coco --checkpoint outputs/resnet50block5-pif-paf-crm-edge401-190526-203030.pkl.epoch006 --long-edge=321 --loader-workers=1
6 changes: 6 additions & 0 deletions eval_crm_recall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CUDA_VISIBLE_DEVICES="1" python3 -m openpifpaf.eval_crm_recall --batch-size 1 --jaad_batch_size 1 \
--checkpoint outputs/resnet50block5-pif-paf-crm-edge401-190526-203030.pkl.epoch006 \
--truncate 0 \
--final_frame_offset 0 \
--result "bbox-recall-crm.txt" \
--jaad_train "singletxt_pre_train_1s" --jaad_val "singletxt_val_1s" --jaad_pre_train "singletxt_pre_train_1s"
13 changes: 13 additions & 0 deletions eval_optimistic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CUDA_VISIBLE_DEVICES="0" python3 -m openpifpaf.eval_optimistic --batch-size 1 --jaad_batch_size 1 \
--checkpoint outputs/resnet50block5-pif-paf-crm-edge401-190526-203030.pkl.epoch006 \
--truncate 0 \
--final_frame_offset 0 \
--result "trained1s.txt" \
--jaad_train "singletxt_pre_train_0s" --jaad_val "singletxt_val_0s" --jaad_pre_train "singletxt_pre_train_0s"

CUDA_VISIBLE_DEVICES="0" python3 -m openpifpaf.eval_optimistic --batch-size 1 --jaad_batch_size 1 \
--checkpoint outputs/resnet50block5-pif-paf-crm-edge401-190527-174900.pkl.epoch006 \
--truncate 0 \
--final_frame_offset 0 \
--result "trained2s.txt" \
--jaad_train "singletxt_pre_train_0s" --jaad_val "singletxt_val_0s" --jaad_pre_train "singletxt_pre_train_0s"
6 changes: 6 additions & 0 deletions eval_pifpaf_recall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CUDA_VISIBLE_DEVICES="1" python3 -m openpifpaf.eval_pifpaf_recall --batch-size 1 --jaad_batch_size 1 \
--checkpoint outputs/resnet50block5-pif-paf-crm-edge401-190526-203030.pkl.epoch006 \
--truncate 0 \
--final_frame_offset 0 \
--result "bbox-recall-pifpaf.txt" \
--jaad_train "singletxt_pre_train_1s" --jaad_val "singletxt_val_1s" --jaad_pre_train "singletxt_pre_train_1s"
Binary file added im/000000000785.jpg.skeleton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added im/0001.png.skeleton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added im/0161.png.skeleton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
247 changes: 247 additions & 0 deletions openpifpaf.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
Metadata-Version: 2.1
Name: openpifpaf
Version: 0.6.0
Summary: PifPaf: Composite Fields for Human Pose Estimation
Home-page: https://github.com/vita-epfl/openpifpaf
Author: Sven Kreiss
Author-email: [email protected]
License: GNU AGPLv3
Description: # openpifpaf

[![Build Status](https://travis-ci.org/vita-epfl/openpifpaf.svg?branch=master)](https://travis-ci.org/vita-epfl/openpifpaf)

> We propose a new bottom-up method for multi-person 2D human pose
> estimation that is particularly well suited for urban mobility such as self-driving cars
> and delivery robots. The new method, PifPaf, uses a Part Intensity Field (PIF) to
> localize body parts and a Part Association Field (PAF) to associate body parts with each other to form
> full human poses.
> Our method outperforms previous methods at low resolution and in crowded,
> cluttered and occluded scenes
> thanks to (i) our new composite field PAF encoding fine-grained information and (ii) the choice of Laplace loss for regressions which incorporates a notion of uncertainty.
> Our architecture is based on a fully
> convolutional, single-shot, box-free design.
> We perform on par with the existing
> state-of-the-art bottom-up method on the standard COCO keypoint task
> and produce state-of-the-art results on a modified COCO keypoint task for
> the transportation domain.


```
@article{kreiss2019pifpaf,
title={PifPaf: Composite Fields for Human Pose Estimation},
author={Kreiss, Sven and Bertoni, Lorenzo and Alahi, Alexandre},
journal={CVPR, arXiv preprint arXiv:1903.06593},
year={2019}
}
```

[arxiv.org/abs/1903.06593](https://arxiv.org/abs/1903.06593)


# Demo

![example image with overlaid pose skeleton](docs/coco/000000081988.jpg.skeleton.png)

Image credit: "[Learning to surf](https://www.flickr.com/photos/fotologic/6038911779/in/photostream/)" by fotologic which is licensed under [CC-BY-2.0].<br />
Created with:
`python3 -m openpifpaf.predict --show docs/coco/000000081988.jpg`

For more demos, see the
[openpifpafwebdemo](https://github.com/vita-epfl/openpifpafwebdemo) project and
the `openpifpaf.webcam` command.
There is also a [Google Colab demo](https://colab.research.google.com/drive/1H8T4ZE6wc0A9xJE4oGnhgHpUpAH5HL7W).

<img src="docs/wave3.gif" height=250 alt="example image" />


# Install

Python 3 is required. Python 2 is not supported.
Do not clone this repository
and make sure there is no folder named `openpifpaf` in your current directory.

```sh
pip3 install openpifpaf
```

For a live demo, we recommend to try the
[openpifpafwebdemo](https://github.com/vita-epfl/openpifpafwebdemo) project.
Alternatively, `openpifpaf.webcam` provides a live demo as well.
It requires OpenCV. To use a globally installed
OpenCV from inside a virtual environment, create the virtualenv with the
`--system-site-packages` option and verify that you can do `import cv2`.

For development of the openpifpaf source code itself, you need to clone this repository and then:

```sh
pip3 install numpy cython
pip3 install --editable '.[train,test]'
```

The last command installs the Python package in the current directory
(signified by the dot) with the optional dependencies needed for training and
testing. The current changelog and the changelogs for prior releases are
in [HISTORY.md](HISTORY.md).


# Interfaces

* `python3 -m openpifpaf.predict --help`
* `python3 -m openpifpaf.webcam --help`
* `python3 -m openpifpaf.train --help`
* `python3 -m openpifpaf.eval_coco --help`
* `python3 -m openpifpaf.logs --help`

Example commands to try:

```sh
# live demo
MPLBACKEND=macosx python3 -m openpifpaf.webcam --scale 0.1 --source=0

# single image
python3 -m openpifpaf.predict my_image.jpg --show
```


# Pre-trained Models

Put the files from this
[Google Drive](https://drive.google.com/drive/folders/1v8UNDjZbqeMZY64T33tSDOq1jtcBJBy7?usp=sharing>)
into your `outputs` folder.
Alternative downloads:

| models | [Cloudflare IPFS gateway] to https | [IPFS] | [DAT] (broken?) |
|-------------------|------------------------------------|-------------|-----------------|
| ResNet50 (97MB) | [CF R50] | [IPFS R50] | [DAT repo] |
| ResNet101 (169MB) | [CF R101] | [IPFS R101] | [DAT repo] |
| ResNet152 (229MB) | [CF R152] | [IPFS R152] | [DAT repo] |

[Cloudflare IPFS gateway]: https://blog.cloudflare.com/distributed-web-gateway/
[IPFS]: https://ipfs.io/
[DAT]: https://datproject.org/
[CF R50]: https://cloudflare-ipfs.com/ipfs/QmVySuAqA2MMMPDHM1p4wLpNo93FPsZC21nApUdsqX7uDB
[IPFS R50]: ipfs://QmVySuAqA2MMMPDHM1p4wLpNo93FPsZC21nApUdsqX7uDB
[CF R101]: https://cloudflare-ipfs.com/ipfs/QmdmrxTRnDucpkEQhPY9bKFcP5sb9cqRZKPC7tGKWkfqJw
[IPFS R101]: ipfs://QmdmrxTRnDucpkEQhPY9bKFcP5sb9cqRZKPC7tGKWkfqJw
[CF R152]: https://cloudflare-ipfs.com/ipfs/QmPhJVjt3jw9q6bpKQgvuN2aszcwSBFYszyU9Lkeg9pPZu
[IPFS R152]: ipfs://QmPhJVjt3jw9q6bpKQgvuN2aszcwSBFYszyU9Lkeg9pPZu
[DAT repo]: dat://339c3ba0e0cc7e1dd3d3d6d2241004fda7ceabb36d17216027da87d48fd3ece8


Visualize logs:

```sh
python3 -m pifpaf.logs \
outputs/resnet50block5-pif-paf-edge401-190424-122009.pkl.log \
outputs/resnet101block5-pif-paf-edge401-190412-151013.pkl.log \
outputs/resnet152block5-pif-paf-edge401-190412-121848.pkl.log
```


# Train

See [datasets](docs/datasets.md) for setup instructions.
See [studies.ipynb](docs/studies.ipynb) for previous studies.

Train a model:

```sh
python3 -m openpifpaf.train \
--lr=1e-3 \
--momentum=0.95 \
--epochs=75 \
--lr-decay 60 70 \
--batch-size=8 \
--basenet=resnet50block5 \
--head-quad=1 \
--headnets pif paf \
--square-edge=401 \
--regression-loss=laplace \
--lambdas 30 2 2 50 3 3 \
--freeze-base=1
```

You can refine an existing model with the `--checkpoint` option.

To produce evaluations at every epoch, check the directory for new
snapshots every 5 minutes:

```
while true; do \
CUDA_VISIBLE_DEVICES=0 find outputs/ -name "resnet101block5-pif-paf-l1-190109-113346.pkl.epoch???" -exec \
python3 -m openpifpaf.eval_coco --checkpoint {} -n 500 --long-edge=641 --skip-existing \; \
; \
sleep 300; \
done
```


# Person Skeletons

COCO / kinematic tree / dense:

<img src="docs/skeleton_coco.png" height="250" /><img src="docs/skeleton_kinematic_tree.png" height="250" /><img src="docs/skeleton_dense.png" height="250" />

Created with `python3 -m openpifpaf.data`.


# Video

Processing a video frame by frame from `video.avi` to `video.pose.mp4` using ffmpeg:

```sh
export VIDEO=video.avi # change to your video file

mkdir ${VIDEO}.images
ffmpeg -i ${VIDEO} -qscale:v 2 -vf scale=641:-1 -f image2 ${VIDEO}.images/%05d.jpg
python3 -m openpifpaf.predict --checkpoint resnet152 ${VIDEO}.images/*.jpg
ffmpeg -framerate 24 -pattern_type glob -i ${VIDEO}.images/'*.jpg.skeleton.png' -vf scale=640:-1 -c:v libx264 -pix_fmt yuv420p ${VIDEO}.pose.mp4
```

In this process, ffmpeg scales the video to `641px` which can be adjusted.


# Evaluations

See [evaluation logs](docs/eval_logs.md) for a long list.
This result was produced with `python -m openpifpaf.eval_coco --checkpoint outputs/resnet101block5-pif-paf-edge401-190313-100107.pkl --long-edge=641 --loader-workers=8`:

```
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets= 20 ] = 0.657
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets= 20 ] = 0.866
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets= 20 ] = 0.719
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets= 20 ] = 0.619
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets= 20 ] = 0.718
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 20 ] = 0.712
Average Recall (AR) @[ IoU=0.50 | area= all | maxDets= 20 ] = 0.895
Average Recall (AR) @[ IoU=0.75 | area= all | maxDets= 20 ] = 0.768
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets= 20 ] = 0.660
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets= 20 ] = 0.785
Decoder 0: decoder time = 875.4406125545502s
total processing time = 1198.353811264038s
```


# Profiling Decoder

Run predict with the `--profile` option:

```sh
python3 -m openpifpaf.predict \
--checkpoint outputs/resnet152block5-pif-paf-edge401-190412-121848.pkl \
docs/coco/000000081988.jpg --show --profile --debug
```

This will write a stats table to the terminal and also produce a `decoder.prof` file.
You can use flameprof (`pip install flameprof`) to get a flame graph with
`flameprof decoder.prof > docs/decoder_flame.svg`:

![flame graph for decoder](docs/decoder_flame.svg)


[CC-BY-2.0]: https://creativecommons.org/licenses/by/2.0/

Platform: UNKNOWN
Description-Content-Type: text/markdown
Provides-Extra: train
Provides-Extra: test
Loading

0 comments on commit cf8d485

Please sign in to comment.