Skip to content

Commit

Permalink
add model and demo code
Browse files Browse the repository at this point in the history
  • Loading branch information
PO intern committed Aug 8, 2017
1 parent e4f329c commit 473e1c7
Show file tree
Hide file tree
Showing 16 changed files with 7,756 additions and 57 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file added model/.DS_Store
Binary file not shown.
2,965 changes: 2,965 additions & 0 deletions model/_trained_COCO/pose_deploy.prototxt

Large diffs are not rendered by default.

2,965 changes: 2,965 additions & 0 deletions model/_trained_MPI/pose_deploy.prototxt

Large diffs are not rendered by default.

Binary file added testing/.DS_Store
Binary file not shown.
Binary file added testing/python/.DS_Store
Binary file not shown.
987 changes: 987 additions & 0 deletions testing/python/.ipynb_checkpoints/demo_testing-checkpoint.ipynb

Large diffs are not rendered by default.

123 changes: 123 additions & 0 deletions testing/python/Alpha_shape.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
'''
author : Sean Gillies
edit : Winnie Hong
create date : 0714/2017
'''

import sys
sys.path.append('/Users/pointern/.virtualenvs/cv3/lib/python3.6/site-packages')

from scipy.spatial import Delaunay
from descartes import PolygonPatch

from matplotlib.collections import LineCollection
from shapely.ops import cascaded_union, polygonize
from shapely.geometry import MultiLineString
import shapely.geometry as geometry
import math
import numpy as np

import matplotlib as mpl
mpl.use('TkAgg')
import matplotlib.pyplot as plt



#import cv2


def add_edge(edges,edge_points, coords, i, j):
"""
Add a line between the i-th and j-th points,
if not in the list already
"""
if (i, j) in edges or (j, i) in edges:
# already added
return

# print((i,j))
edges.add( (i, j) )
edge_points.append(coords[ [i, j] ])

# print(edges)
# print(edge_points)

# loop over triangles:
# ia, ib, ic = indices of corner points of the triangle

def alpha_shape(points,alpha):
# circum_lst = []
tri = Delaunay(points)

edges = set()
edge_points = []

for ia, ib, ic in tri.vertices:
pa = points[ia]
pb = points[ib]
pc = points[ic]

# Lengths of sides of triangle
a = math.sqrt((pa[0]-pb[0])**2 + (pa[1]-pb[1])**2)
b = math.sqrt((pb[0]-pc[0])**2 + (pb[1]-pc[1])**2)
c = math.sqrt((pc[0]-pa[0])**2 + (pc[1]-pa[1])**2)

# Semiperimeter of triangle
s = (a + b + c)/2.0

# Area of triangle by Heron's formula
area = math.sqrt(s*(s-a)*(s-b)*(s-c))

circum_r = a*b*c/(4.0*area)

# Here's the radius filter.
# circum_lst.append(circum_r)
# print('val = ',circum_r)
# print('limit = ',1.0/alpha)
#
if circum_r < 1.0/alpha:
add_edge(edges,edge_points, points, ia, ib)
add_edge(edges,edge_points, points, ib, ic)
add_edge(edges,edge_points, points, ic, ia)

# print('ave = ',sum(circum_lst)/len(circum_lst))

m = MultiLineString(edge_points)
triangles = list(polygonize(m))

# ## Show Result
# # shoaw result of triangular
# lines = LineCollection(edge_points,linewidths=(0.5, 1, 1.5, 2))
# plt.figure()
# plt.title('Alpha=2.0 Delaunay triangulation')
# plt.plot(points[:,0], points[:,1], 'o', hold=1, color='#f16824')
# plt.gca().add_collection(lines)
#
# # show result of connected contour
# plt.figure()
# plt.title("Alpha=2.0 Hull")
# plt.gca().add_patch(PolygonPatch(cascaded_union(triangles), alpha=0.5))
# plt.gca().autoscale(tight=False)
# plt.plot(points[:,0], points[:,1], 'o', hold=1)
# plt.show()

return triangles, edge_points

if __name__ == '__main__' :

# pts of extending points calculated from HPE result
points = np.array([[79, 441], [85, 370], [150, 447], [98, 360], [173, 427], [166, 285], [241, 352], \
[372, 320], [337, 413], [270, 282], [235, 375], [501, 445], [480, 377], [433, 466], [205, 238], \
[298, 276], [254, 234], [299, 145], [214, 216], [257, 125], [338, 157], [307, 252], [342, 81], \
[274, 98], [359, 149], [58, 68], [127, 52], [74, 137], [190, 91], [145, 180], [365, 163], [344, 260], \
[446, 194], [387, 154], [406, 253]])


alpha = 0.013

triangles, edge_points = alpha_shape(points, alpha)





Binary file added testing/python/Alpha_shape.pyc
Binary file not shown.
36 changes: 36 additions & 0 deletions testing/python/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[param]

# CPU mode or GPU mode
use_gpu = 1

# GPU device number (doesn't matter for CPU mode)
GPUdeviceNumber = 0

# Select model (default: 1)
modelID = 1

# Look in matlab counterpart for explanation
octave = 3
starting_range = 0.8
ending_range = 2
scale_search = 0.5, 1, 1.5, 2
thre1 = 0.1
thre2 = 0.05
thre3 = 0.5
min_num = 4
mid_num = 10
crop_ratio = 2.5
bbox_ratio = 0.25

[models]
## don't edit this part

[[1]]
caffemodel = '../../model/_trained_COCO/pose_iter_440000.caffemodel'
deployFile = '../../model/_trained_COCO/pose_deploy.prototxt'
description = 'COCO Pose56 Two-level Linevec'
boxsize = 368
padValue = 128
np = 12
stride = 8
part_str = [nose, neck, Rsho, Relb, Rwri, Lsho, Lelb, Lwri, Rhip, Rkne, Rank, Lhip, Lkne, Lank, Leye, Reye, Lear, Rear, pt19]
4 changes: 0 additions & 4 deletions config_reader.py → testing/python/config_reader.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
'''
Author: Realtime_Multi-Person_Pose_Estimation, https://github.com/w102060018w/Realtime_Multi-Person_Pose_Estimation
'''

from configobj import ConfigObj
import numpy as np

Expand Down
Binary file added testing/python/config_reader.pyc
Binary file not shown.
620 changes: 620 additions & 0 deletions testing/python/demo.ipynb

Large diffs are not rendered by default.

109 changes: 60 additions & 49 deletions demo_testing.ipynb → testing/python/demo_testing.ipynb
100755 → 100644

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions util.py → testing/python/util.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
'''
Author: Realtime_Multi-Person_Pose_Estimation, https://github.com/w102060018w/Realtime_Multi-Person_Pose_Estimation
'''

import numpy as np
from cStringIO import StringIO
import PIL.Image
Expand Down
Binary file added testing/python/util.pyc
Binary file not shown.

0 comments on commit 473e1c7

Please sign in to comment.