Skip to content

Commit

Permalink
readme update. image changed.
Browse files Browse the repository at this point in the history
  • Loading branch information
ildoonet committed Oct 26, 2017
1 parent 5fd4c57 commit ac42999
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 16 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,22 @@ CMU's original model can not be executed due to 'out of memory' on '368x368' siz

## Demo

### Test Inference

You can test the inference feature with a single image.

```
$ python3 inference.py --model=mobilenet --imgpath=...
```

Then you will see the screen as below with pafmap, heatmap, result and etc.

![inferent_result](./etcs/inference_result.png)

### Realtime Webcam

```
$ python3 realtime_webcam.py --camera=0 --model=mobilenet
$ python3 realtime_webcam.py --camera=0 --model=mobilenet --zoom=1.0
```

## Training
Expand Down
4 changes: 2 additions & 2 deletions common_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_mobilenet(self):
elapsed = time.time() - t
logging.info('[test_mobilenet] elapsed=%f' % elapsed)

self._show('./images/person3.jpg', inpmat, heatmat, pafmat, humans)
self._show('./images/p3.jpg', inpmat, heatmat, pafmat, humans)

def test_cmu(self):
inpmat = np.load('./tests/person3.pickle')
Expand All @@ -54,7 +54,7 @@ def test_cmu(self):
elapsed = time.time() - t
logging.info('[test_mobilenet] elapsed=%f' % elapsed)

# self._show('./images/person3.jpg', inpmat, heatmat, pafmat, humans)
# self._show('./images/p3.jpg', inpmat, heatmat, pafmat, humans)

if __name__ == '__main__':
unittest.main()
Binary file added etcs/inference_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added images/p2.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 images/p3.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 removed images/person2.jpg
Binary file not shown.
Binary file removed images/person3.jpg
Binary file not shown.
2 changes: 1 addition & 1 deletion inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Tensorflow Openpose Inference')
parser.add_argument('--imgpath', type=str, default='./images/person3.jpg')
parser.add_argument('--imgpath', type=str, default='./images/p2.jpg')
parser.add_argument('--input-width', type=int, default=368)
parser.add_argument('--input-height', type=int, default=368)
parser.add_argument('--stage-level', type=int, default=6)
Expand Down
26 changes: 17 additions & 9 deletions networks.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
import os

import tensorflow as tf

from network_cmu import CmuNetwork
from network_mobilenet import MobilenetNetwork


def _get_base_path():
if not os.environ.get('OPENPOSE_MODEL', ''):
return './models'
return os.environ.get('OPENPOSE_MODEL')


def get_network(type, placeholder_input, sess_for_load=None):
if type == 'mobilenet':
net = MobilenetNetwork({'image': placeholder_input}, conv_width=0.75, conv_width2=0.50)
pretrain_path = './models/pretrained/mobilenet_v1_0.75_224_2017_06_14/mobilenet_v1_0.75_224.ckpt'
pretrain_path = 'pretrained/mobilenet_v1_0.75_224_2017_06_14/mobilenet_v1_0.75_224.ckpt'
last_layer = 'MConv_Stage6_L{aux}_5'
elif type == 'mobilenet_accurate':
net = MobilenetNetwork({'image': placeholder_input}, conv_width=1.00)
pretrain_path = './models/pretrained/mobilenet_v1_1.0_224_2017_06_14/mobilenet_v1_1.0_224.ckpt'
pretrain_path = 'pretrained/mobilenet_v1_1.0_224_2017_06_14/mobilenet_v1_1.0_224.ckpt'
last_layer = 'MConv_Stage6_L{aux}_5'
elif type == 'mobilenet_fast':
net = MobilenetNetwork({'image': placeholder_input}, conv_width=0.50)
pretrain_path = './models/pretrained/mobilenet_v1_0.50_224_2017_06_14/mobilenet_v1_0.50_224.ckpt'
pretrain_path = 'pretrained/mobilenet_v1_0.50_224_2017_06_14/mobilenet_v1_0.50_224.ckpt'
last_layer = 'MConv_Stage6_L{aux}_5'
elif type == 'cmu':
net = CmuNetwork({'image': placeholder_input})
pretrain_path = './models/numpy/openpose_coco.npy'
pretrain_path = 'numpy/openpose_coco.npy'
last_layer = 'Mconv7_stage6_L{aux}'
else:
raise Exception('Invalid Mode.')
Expand All @@ -30,11 +38,11 @@ def get_network(type, placeholder_input, sess_for_load=None):
else:
s = '%dx%d' % (placeholder_input.shape[2], placeholder_input.shape[1])
ckpts = {
'mobilenet': './models/trained/mobilenet_%s/model-release' % s,
'mobilenet_fast': './models/trained/mobilenet_fast/model-163000',
'mobilenet_accurate': './models/trained/mobilenet_accurate/model-170000'
'mobilenet': 'trained/mobilenet_%s/model-release' % s,
'mobilenet_fast': 'trained/mobilenet_fast/model-163000',
'mobilenet_accurate': 'trained/mobilenet_accurate/model-170000'
}
loader = tf.train.Saver()
loader.restore(sess_for_load, ckpts[type])
loader.restore(sess_for_load, os.path.join(_get_base_path(), ckpts[type]))

return net, pretrain_path, last_layer
return net, os.path.join(_get_base_path(), pretrain_path), last_layer
6 changes: 3 additions & 3 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@
for images_test, heatmaps, vectmaps in df_valid.get_data():
validation_cache.append((images_test, heatmaps, vectmaps))

val_image = read_imgfile('./images/person1.jpg', args.input_width, args.input_height)
val_image2 = read_imgfile('./images/person2.jpg', args.input_width, args.input_height)
val_image3 = read_imgfile('./images/person3.jpg', args.input_width, args.input_height)
val_image = read_imgfile('./images/p1.jpg', args.input_width, args.input_height)
val_image2 = read_imgfile('./images/p2.jpg', args.input_width, args.input_height)
val_image3 = read_imgfile('./images/p3.jpg', args.input_width, args.input_height)

# define model for multi-gpu
q_inp_split = tf.split(q_inp, args.gpus)
Expand Down

0 comments on commit ac42999

Please sign in to comment.