Skip to content

Commit 00616df

Browse files
CrystalSixoneleoxiaobin
authored andcommitted
Add demo/demo.py with more common functions and update demo/README.md
1 parent 1ee551d commit 00616df

6 files changed

+416
-8
lines changed

demo/README.md

+44-6
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ Inferencing the deep-high-resolution-net.pytoch without using Docker.
55
## Prep
66
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/`
77
2. Put the video file you'd like to infer on in this directory under `videos`
8-
3. build the docker container in this directory with `./build-docker.sh` (this can take time because it involves compiling opencv)
9-
4. update the `inference-config.yaml` file to reflect the number of GPUs you have available
8+
3. (OPTIONAL) build the docker container in this directory with `./build-docker.sh` (this can take time because it involves compiling opencv)
9+
4. update the `inference-config.yaml` file to reflect the number of GPUs you have available and which trained model you want to use.
1010

1111
## Running the Model
12+
### 1. Running on the video
1213
```
13-
python inference.py --cfg inference-config.yaml \
14+
python demo/inference.py --cfg demo/inference-config.yaml \
1415
--videoFile ../../multi_people.mp4 \
1516
--writeBoxFrames \
1617
--outputDir output \
@@ -23,9 +24,9 @@ Even with usage of GPU (GTX1080 in my case), the person detection will take near
2324
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)
2425
pose estimation then you should try other approach.
2526

26-
## Result
27+
**===Result===**
2728

28-
Some output image is as:
29+
Some output images are as:
2930

3031
![1 person](inference_1.jpg)
3132
Fig: 1 person inference
@@ -34,4 +35,41 @@ Fig: 1 person inference
3435
Fig: 3 person inference
3536

3637
![3 person](inference_5.jpg)
37-
Fig: 3 person inference
38+
Fig: 3 person inference
39+
40+
### 2. Demo with more common functions
41+
Remember to update` TEST.MODEL_FILE` in `demo/inference-config.yaml `according to your model path.
42+
43+
`demo.py` provides the following functions:
44+
45+
- use `--webcam` when the input is a real-time camera.
46+
- use `--video [video-path]` when the input is a video.
47+
- use `--image [image-path]` when the input is an image.
48+
- use `--write` to save the image, camera or video result.
49+
- use `--showFps` to show the fps (this fps includes the detection part).
50+
- draw connections between joints.
51+
52+
#### (1) the input is a real-time carema
53+
```python
54+
python demo/demo.py --webcam --showFps --writeVideo
55+
```
56+
57+
#### (2) the input is a video
58+
```python
59+
python demo/demo.py --video test.mp4 --showFps --writeVideo
60+
```
61+
#### (3) the input is a image
62+
63+
```python
64+
python demo/demo.py --image test.jpg --showFps --writeImage
65+
```
66+
67+
**===Result===**
68+
69+
![show_fps](inference_6.jpg)
70+
71+
Fig: show fps
72+
73+
![multi-people](inference_7.jpg)
74+
75+
Fig: multi-people

demo/_init_paths.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# ------------------------------------------------------------------------------
2+
# pose.pytorch
3+
# Copyright (c) 2018-present Microsoft
4+
# Licensed under The Apache-2.0 License [see LICENSE for details]
5+
# Written by Bin Xiao (Bin.Xiao@microsoft.com)
6+
# ------------------------------------------------------------------------------
7+
8+
from __future__ import absolute_import
9+
from __future__ import division
10+
from __future__ import print_function
11+
12+
import os.path as osp
13+
import sys
14+
15+
16+
def add_path(path):
17+
if path not in sys.path:
18+
sys.path.insert(0, path)
19+
20+
21+
this_dir = osp.dirname(__file__)
22+
23+
lib_path = osp.join(this_dir, '..', 'lib')
24+
add_path(lib_path)
25+
26+
mm_path = osp.join(this_dir, '..', 'lib/poseeval/py-motmetrics')
27+
add_path(mm_path)

0 commit comments

Comments
 (0)