Skip to content

Commit

Permalink
restruct folders (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarithm committed Oct 9, 2018
1 parent b1259c8 commit ae6cd59
Show file tree
Hide file tree
Showing 21 changed files with 39 additions and 35 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ __pycache__
/cmake-build
/coco
/data
/models
/tensorlayer
/vis
cmake_install.cmake
Expand All @@ -29,7 +28,6 @@ CTestTestfile.cmake
inference/*png
libstdtensor-prefix
libstdtracer-prefix
models_hao*
test.py
test.py
Testing
Expand Down
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ before_install:
script:
- docker build --rm -t openpose-plus-test:snapshot -f docker/Dockerfile.builder-cpu-bionic .
- docker run --rm -it openpose-plus-test:snapshot sh -c './configure && make && make test'
- python ./test_inference.py --path-to-npz='' --images=$(ls data/media/*.jpg | sort | head -n 3 | tr '\n' ',') --base-model=vgg
- python ./test_inference.py --path-to-npz='' --images=$(ls data/media/*.jpg | sort | head -n 3 | tr '\n' ',') --base-model=vggtiny
- python ./test_inference.py --path-to-npz='' --images=$(ls data/media/*.jpg | sort | head -n 3 | tr '\n' ',') --base-model=mobilenet
- python ./test_inference.py --path-to-npz='' --images=$(ls data/media/*.jpg | sort | head -n 3 | tr '\n' ',') --base-model=hao28_experimental
- python ./examples/example-inference-1.py --path-to-npz='' --images=$(ls data/media/*.jpg | sort | head -n 3 | tr '\n' ',') --base-model=vgg
- python ./examples/example-inference-1.py --path-to-npz='' --images=$(ls data/media/*.jpg | sort | head -n 3 | tr '\n' ',') --base-model=vggtiny
- python ./examples/example-inference-1.py --path-to-npz='' --images=$(ls data/media/*.jpg | sort | head -n 3 | tr '\n' ',') --base-model=mobilenet
- python ./examples/example-inference-1.py --path-to-npz='' --images=$(ls data/media/*.jpg | sort | head -n 3 | tr '\n' ',') --base-model=hao28_experimental
8 changes: 5 additions & 3 deletions test_inference.py → examples/example-inference-1.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
import tensorflow as tf
import tensorlayer as tl

from inference.common import measure, plot_humans, read_imgfile
from inference.estimator2 import TfPoseEstimator as TfPoseEstimator2
from models import get_model
sys.path.append('.')

from openpose_plus.inference.common import measure, plot_humans, read_imgfile
from openpose_plus.inference.estimator2 import TfPoseEstimator as TfPoseEstimator2
from openpose_plus.models import get_model

tf.logging.set_verbosity(tf.logging.INFO)
tl.logging.set_verbosity(tl.logging.INFO)
Expand Down
6 changes: 4 additions & 2 deletions test_inference-2.py → examples/example-inference-2.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
import tensorflow as tf
import tensorlayer as tl

from inference.common import measure, plot_humans, read_imgfile
from inference.estimator2 import TfPoseEstimator as TfPoseEstimator2
sys.path.append('.')

from openpose_plus.inference.common import measure, plot_humans, read_imgfile, load_graph
from openpose_plus.inference.estimator2 import TfPoseEstimator as TfPoseEstimator2


class TfPoseEstimator2Loader(TfPoseEstimator2):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import tensorflow as tf
import tensorlayer as tl

from inference.post_process import PostProcessor
from .post_process import PostProcessor

logger = logging.getLogger('TfPoseEstimator')
logger.setLevel(logging.DEBUG)
Expand Down Expand Up @@ -33,10 +33,10 @@ def __del__(self):
self.persistent_sess.close()

def inference(self, npimg):
heatmap, pafmap = self.persistent_sess.run([self.tensor_heatmap, self.tensor_paf],
feed_dict={
self.tensor_image: [npimg],
})
heatmap, pafmap = self.persistent_sess.run(
[self.tensor_heatmap, self.tensor_paf], feed_dict={
self.tensor_image: [npimg],
})

t = time.time()
humans, heatmap_up, pafmap_up = self.post_processor(heatmap[0], pafmap[0])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import scipy.stats as st
import tensorflow as tf

from inference import common
from inference.common import CocoPart
from . import common
from .common import CocoPart


def _normalize(t):
Expand Down Expand Up @@ -82,7 +82,7 @@ def __repr__(self):


def estimate_paf(peaks, heat_mat, paf_mat):
from inference.pafprocess import pafprocess # TODO: don't depend on it
from .pafprocess import pafprocess # TODO: don't depend on it
pafprocess.process_paf(peaks, heat_mat, paf_mat)

humans = []
Expand Down Expand Up @@ -141,11 +141,12 @@ def __call__(self, heatmap_input, pafmap_input):
heatmap_input = heatmap_input.transpose(p)
pafmap_input = pafmap_input.transpose(p)

peaks, heatmap, pafmap = self.sess.run([self.peaks, self.heapmap_upsample, self.paf_upsample],
feed_dict={
self.heatmap_input: [heatmap_input],
self.paf_input: [pafmap_input],
})
peaks, heatmap, pafmap = self.sess.run(
[self.peaks, self.heapmap_upsample, self.paf_upsample],
feed_dict={
self.heatmap_input: [heatmap_input],
self.paf_input: [pafmap_input],
})

humans = estimate_paf(peaks[0], heatmap[0], pafmap[0])
return humans, heatmap[0], pafmap[0]
13 changes: 7 additions & 6 deletions models.py → openpose_plus/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import tensorflow as tf
from config import config
from inference.common import rename_tensor

from ..config import config
from ..inference.common import rename_tensor

__all__ = [
'get_base_model',
Expand All @@ -22,13 +23,13 @@ def _input_image(height, width, data_format, name):

def get_base_model(name):
if name == 'vgg':
from models_vgg import model
from .models_vgg import model
elif name == 'vggtiny':
from models_vggtiny import model
from .models_vggtiny import model
elif name == 'mobilenet':
from models_mobilenet import model
from .models_mobilenet import model
elif name == 'hao28_experimental':
from models_hao28_experimental import model
from .models_hao28_experimental import model
else:
raise RuntimeError('unknown base model %s' % name)
return model
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion scripts/install-pafprocess.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
set -e

cd $(dirname $0)/../inference
cd $(dirname $0)/../openpose_plus/inference

[ ! -d pafprocess ] && svn export https://github.com/ildoonet/tf-pose-estimation/trunk/tf_pose/pafprocess
cd pafprocess
Expand Down
8 changes: 4 additions & 4 deletions scripts/profile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export PYTHONUNBUFFERED=1
MODEL_DIR=${HOME}/Downloads
DATA_DIR=$HOME/var/data/openpose

IMAGES=$(ls ${DATA_DIR}/examples/media/*.png | sort | tr '\n' ',')
IMAGES=$(ls ${DATA_DIR}/examples/media/*.jpg | sort | tr '\n' ',')

REPEAT=10
LIMIT=1
Expand All @@ -41,7 +41,7 @@ profile_model() {
return
fi

./test_inference.py --path-to-npz=${MODEL_DIR}/$npz \
./examples/example-inference-1.py --path-to-npz=${MODEL_DIR}/$npz \
--base-model=$model \
--images=${IMAGES} \
--data-format=$data_format \
Expand All @@ -51,10 +51,10 @@ profile_model() {
}

mkdir -p logs
# measure profile_model vggtiny new-models/hao18/pose350000.npz NHWC
measure profile_model vggtiny new-models/hao18/pose350000.npz NHWC
# measure profile_model vggtiny new-models/hao18/pose350000.npz NCHW
# measure profile_model mobilenet mbn280000.npz NHWC
# measure profile_model vgg vgg450000_no_cpm.npz NHWC
# measure profile_model vgg vgg450000_no_cpm.npz NCHW
# measure profile_model hao28_experimental hao28/pose345000.npz NHWC
measure profile_model hao28_experimental hao28/pose345000.npz NCHW
# measure profile_model hao28_experimental hao28/pose345000.npz NCHW

0 comments on commit ae6cd59

Please sign in to comment.