-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcellCodeBody.py
More file actions
executable file
·158 lines (118 loc) · 3.48 KB
/
cellCodeBody.py
File metadata and controls
executable file
·158 lines (118 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# coding: utf-8
# In[1]:
# all the f'ing imports
import scipy.io as sio
import os,sys
import myutils
import re
from stephenBodyConfig import conf as conf
import shutil
get_ipython().magic(u'matplotlib inline')
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import scipy
import cv2
import math
import lmdb
import caffe
from random import randint,sample
import pickle
import h5py
import mpld3
mpld3.enable_notebook()
import multiResData
reload(multiResData)
multiResData.createDB(conf)
# In[2]:
# all the f'ing imports
import scipy.io as sio
import os,sys
import myutils
import re
from stephenBodyConfig import sideconf as conf
import shutil
get_ipython().magic(u'matplotlib inline')
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import scipy
import cv2
import math
import lmdb
import caffe
from random import randint,sample
import pickle
import h5py
import mpld3
mpld3.enable_notebook()
import multiResData
reload(multiResData)
multiResData.createDB(conf)
# In[1]:
import PoseTrain
import tensorflow as tf
tf.reset_default_graph()
from stephenBodyConfig import conf as conf
pobj = PoseTrain.PoseTrain(conf)
pobj.baseTrain(restore=False)
tf.reset_default_graph()
from stephenBodyConfig import sideconf as conf
pobj = PoseTrain.PoseTrain(conf)
pobj.baseTrain(restore=False)
# In[1]:
import localSetup
import PoseTools
import multiResData
import os
import re
import tensorflow as tf
from scipy import io
import cv2
from cvc import cvc
# os.environ['CUDA_VISIBLE_DEVICES'] = '0'
redo = True
makemovie = False
for view in range(2):
tf.reset_default_graph()
if view == 1:
# For SIDE
from stephenBodyConfig import sideconf as conf
conf.useMRF = False
outtype = 1
extrastr = '_side'
else:
# For FRONT
from stephenBodyConfig import conf as conf
conf.useMRF = False
outtype = 1
extrastr = '_front'
# conf.batch_size = 1
self = PoseTools.create_network(conf, outtype)
sess = tf.InteractiveSession()
PoseTools.init_network(self, sess, outtype)
scale = conf.rescale*conf.pool_scale
_,valmovies = multiResData.get_movie_lists(conf)
for ndx in range(len(valmovies)):
mname,_ = os.path.splitext(os.path.basename(valmovies[ndx]))00
oname = re.sub('!','__',conf.getexpname(valmovies[ndx]))
pname = os.path.join(localSetup.bdir, 'data', 'out', oname + extrastr)
if os.path.isfile(pname + '.mat') and not redo:
continue
if not os.path.isfile(valmovies[ndx]):
continue
predList = PoseTools.classify_movie(conf, valmovies[ndx], outtype, self, sess)
# PoseTools.createPredMovie(conf,predList,valmovies[ndx],pname + '.avi',outtype)
cap = cv2.VideoCapture(valmovies[ndx])
height = int(cap.get(cvc.FRAME_HEIGHT))
width = int(cap.get(cvc.FRAME_WIDTH))
orig_crop_loc = conf.cropLoc[(height,width)]
crop_loc = [x/scale for x in orig_crop_loc]
end_pad = [height/scale-crop_loc[0]-conf.imsz[0]/scale,width/scale-crop_loc[1]-conf.imsz[1]/scale]
pp = [(0,0),(crop_loc[0],end_pad[0]),(crop_loc[1],end_pad[1]),(0,0),(0,0)]
predScores = np.pad(predList[1],pp,mode='constant',constant_values=-1.)
predLocs = predList[0]
predLocs[:,:,:,0] += orig_crop_loc[1]
predLocs[:,:,:,1] += orig_crop_loc[0]
io.savemat(pname + '.mat',{'locs':predLocs,'scores':predScores[...,0],'expname':valmovies[ndx]})
print 'Done:%s'%oname