if (t == (int(db_helen['testset']['img'].shape[0]/testing_batch)+1)): t_batch_x = db_helen['testset']['img'][(t*testing_batch):] t_batch_y = db_helen['testset']['pts'][(t*testing_batch):] batch_map=sess.run(pred_annotation, feed_dict={image: t_batch_x/255, keep_probability: 1.0, train_phase:conf.training}) if (t == 0): infered_pts = utils.map2pts(batch_map , gau = True) else: infered_pts = np.concatenate((infered_pts, utils.map2pts(batch_map, gau = True)), axis=0) used_time = time.time()-start_time print('Avg. inference time: %.4f' % (used_time/db_helen['testset']['img'].shape[0])) for idx, content in enumerate(zip(db_helen['testset']['img'],infered_pts)): img = content[0].copy() for kp_idx, keypoint in enumerate(content[1]): cv2.circle(img,(keypoint[0],keypoint[1]), 2, (0,255,0), -1) cv2.imwrite(pred_dir + str(idx)+ '.png', img) with open(model_dir + 'pts_'+ str(conf.testing)+ '.pickle', 'wb') as handle: pickle.dump(infered_pts, handle) norm_error_image, norm_error_image_eye = utils.eval_norm_error_image(infered_pts, db_helen['testset']['pts']) pandas.DataFrame({'loss':norm_error_image,'loss_eye':norm_error_image_eye}).to_csv(model_dir + 'norm_error_image_' + str(conf.testing)+ '.csv') sess.close()
infered_pts, acc_valid= sess.run([y_out_point, avg_losses], feed_dict=feed_dict) if (t == 0): inferred_map = infered_pts else: inferred_map = np.concatenate((inferred_map, infered_pts), axis=0) used_time = time.time()-start_time print('Avg. inference time: %.4f' % (used_time/db_helen['testset']['img'].shape[0])) inferred_map = np.asarray(inferred_map) pts_maps = np.reshape(inferred_map, newshape=(-1,inferred_map.shape[1],inferred_map.shape[2])) norm_error_image, norm_error_image_eye= utils.eval_norm_error_image(pts_maps, db_helen['testset']['pts']) with open(model_dir + 'pts_'+ str(conf.testing)+ '.pickle', 'wb') as handle: pickle.dump(pts_maps, handle) pandas.DataFrame({'loss':norm_error_image,'loss_eye':norm_error_image_eye}).to_csv(model_dir + 'norm_error_image_' + str(conf.testing)+ '.csv') for idx, content in enumerate(zip(db_helen['testset']['img'],pts_maps)): img = content[0].copy() for kp_idx, keypoint in enumerate(content[1]): cv2.circle(img,(keypoint[0],keypoint[1]), 2, (0,255,0), -1) cv2.imwrite(pred_dir + str(idx)+ '.png', img) sess.close()