def test_Embedding_ASM_act_14_exp_2_ACCV_fc_j0(): """ just check the pose displaying """ from mpl_toolkits.mplot3d import Axes3D import imgproc import iread.h36m_hmlpe as h36m data_path = "/opt/visal/tmp/for_sijin/Data/H36M/H36MExp/folder_Embedding_ASM_act_14_exp_2_ACCV_fc_j0/batches.meta" data_path1 = "/opt/visal/tmp/for_sijin/Data/H36M/H36MExp/folder_SP_t004_act_14/batches.meta" meta = mio.unpickle(data_path) meta1 = mio.unpickle(data_path1) print "Len of feature list is {} \t dims = {}".format(len(meta["feature_list"]), meta["feature_dim"]) for i, e in enumerate(meta["feature_list"]): print "idx {}:\t shapes = {}".format(i, e.shape) f0 = meta["feature_list"][0] f0_1 = meta1["feature_list"][0] ndata = f0.shape[-1] limbs, params = h36m.part_idx, {"elev": -89, "azim": -107, "linewidth": 3} fig = pl.figure() idx = 0 fig.add_subplot(2, 1, 1, projection="3d") p = f0[..., idx].reshape((-1, 1), order="F") * 1200 p1 = f0_1[..., idx].reshape((-1, 1), order="F") print p pp = df.convert_relskel2rel(p).reshape((-1, 1), order="F") diff = pp.reshape((-1, 1), order="F") - p1 imgproc.turn_off_axis() dutils.show_3d_skeleton(p1, limbs, params) pl.show() print """
def test_Embedding_ASM_act_14_exp_2_ACCV_fc_j0(): """ just check the pose displaying """ from mpl_toolkits.mplot3d import Axes3D import imgproc import iread.h36m_hmlpe as h36m data_path = '/opt/visal/tmp/for_sijin/Data/H36M/H36MExp/folder_Embedding_ASM_act_14_exp_2_ACCV_fc_j0/batches.meta' data_path1 = '/opt/visal/tmp/for_sijin/Data/H36M/H36MExp/folder_SP_t004_act_14/batches.meta' meta = mio.unpickle(data_path) meta1 = mio.unpickle(data_path1) print 'Len of feature list is {} \t dims = {}'.format( len(meta['feature_list']), meta['feature_dim']) for i, e in enumerate(meta['feature_list']): print 'idx {}:\t shapes = {}'.format(i, e.shape) f0 = meta['feature_list'][0] f0_1 = meta1['feature_list'][0] ndata = f0.shape[-1] limbs, params = h36m.part_idx, {'elev': -89, 'azim': -107, 'linewidth': 3} fig = pl.figure() idx = 0 fig.add_subplot(2, 1, 1, projection='3d') p = f0[..., idx].reshape((-1, 1), order='F') * 1200 p1 = f0_1[..., idx].reshape((-1, 1), order='F') print p pp = df.convert_relskel2rel(p).reshape((-1, 1), order='F') diff = pp.reshape((-1, 1), order='F') - p1 imgproc.turn_off_axis() dutils.show_3d_skeleton(p1, limbs, params) pl.show() print '''
def do_accveval(self): images_folder = self.op.get_value('images_folder') # get all jpg file in images_folder allfiles = iu.getfilelist(images_folder, '.*\.jpg') images_path = [iu.fullfile(images_folder, p) for p in allfiles] n_image = len(images_path) images = self.load_images(images_path) mean_image_path = self.op.get_value('mean_image_path') mean_image = sio.loadmat(mean_image_path)['cropped_mean_image'] mean_image_arr = mean_image.reshape((-1, 1), order='F') input_images = images - mean_image_arr # pack input images into batch data data = [ input_images, np.zeros((51, n_image), dtype=np.single), np.zeros((1700, n_image), dtype=np.single) ] # allocate the buffer for prediction pred_buffer = np.zeros((n_image, 51), dtype=np.single) data.append(pred_buffer) ext_data = [ np.require(elem, dtype=np.single, requirements='C') for elem in data ] # run the model ## get the joint prediction layer indexes self.pred_layer_idx = self.get_layer_idx('fc_j2', check_type='fc') self.libmodel.startFeatureWriter(ext_data, self.pred_layer_idx) self.finish_batch() raw_pred = ext_data[-1].T pred = dhmlpe_features.convert_relskel2rel(raw_pred) * 1200.0 # show the first prediction show_idx = 0 img = np.array(Image.open(images_path[show_idx])) fig = pl.figure(0) ax1 = fig.add_subplot(121) ax1.imshow(img) ax2 = fig.add_subplot(122, projection='3d') cur_pred = pred[..., show_idx].reshape((3, -1), order='F') part_idx = iread.h36m_hmlpe.part_idx params = {'elev': -94, 'azim': -86, 'linewidth': 6, 'order': 'z'} dutils.show_3d_skeleton(cur_pred.T, part_idx, params)
def do_accveval(self): images_folder = self.op.get_value('images_folder') # get all jpg file in images_folder allfiles = iu.getfilelist(images_folder, '.*\.jpg') images_path = [iu.fullfile(images_folder, p) for p in allfiles] n_image = len(images_path) images = self.load_images(images_path) mean_image_path = self.op.get_value('mean_image_path') mean_image = sio.loadmat(mean_image_path)['cropped_mean_image'] mean_image_arr = mean_image.reshape((-1,1),order='F') input_images = images - mean_image_arr # pack input images into batch data data = [input_images, np.zeros((51,n_image),dtype=np.single), np.zeros((1700,n_image), dtype=np.single)] # allocate the buffer for prediction pred_buffer = np.zeros((n_image, 51),dtype=np.single) data.append(pred_buffer) ext_data = [np.require(elem,dtype=np.single, requirements='C') for elem in data] # run the model ## get the joint prediction layer indexes self.pred_layer_idx = self.get_layer_idx('fc_j2',check_type='fc') self.libmodel.startFeatureWriter(ext_data, self.pred_layer_idx) self.finish_batch() raw_pred = ext_data[-1].T pred = dhmlpe_features.convert_relskel2rel(raw_pred) * 1200.0 # show the first prediction show_idx = 0 img = np.array(Image.open(images_path[show_idx])) fig = pl.figure(0) ax1 = fig.add_subplot(121) ax1.imshow(img) ax2 = fig.add_subplot(122,projection='3d') cur_pred = pred[..., show_idx].reshape((3,-1),order='F') part_idx = iread.h36m_hmlpe.part_idx params = {'elev':-94, 'azim':-86, 'linewidth':6, 'order':'z'} dutils.show_3d_skeleton(cur_pred.T, part_idx, params)
def convert_relskel2rel(cls, x): import dhmlpe_features as df return df.convert_relskel2rel(x)