def visualize_predictions_mesh(self, prediction_data, feature_data, target=None): image = feature_data['image'] dp = prediction_data['deformed_points'] probs = prediction_data['probs'] if not hasattr(self, '_mesh_fn') or self._mesh_fn is None: self._mesh_fn = self._mesh_transformation() image -= np.min(image) image /= np.max(image) plt.imshow(image) plt.show() mesh = self._mesh_fn(probs, dp) vertices, faces, original_vertices = (mesh[k] for k in ('vertices', 'faces', 'original_vertices')) visualize_mesh(original_vertices, faces) mlab.show() visualize_mesh(vertices, faces, color=(1, 0, 0), include_wireframe=False) mlab.show() visualize_point_cloud(vertices, color=(1, 0, 0), scale_factor=0.01) mlab.show()
def visualize_data_pointcloud(self, feature_data, target): image = feature_data['image'] image -= np.min(image) image /= np.max(image) plt.imshow(image) plt.show() visualize_point_cloud(target, color=(1, 0, 0), scale_factor=0.01) mlab.show() plt.close()
def visualize_predicted_pointclouds(self): evaluation_ids = self.data_splitter.get_data( tf.estimator.ModeKeys.PREDICT) template_ids, bs, ps = zip(*self.get_ffd_data()) with tf.Graph().as_default(): dataset = get_dataset(self.preprocessed_data_path, self.cat_id, self.view_angles, self.cloud_resamples, evaluation_ids, False, False, batch_size=len(evaluation_ids)) features, targets = dataset.make_one_shot_iterator().get_next() predictions = self.build_estimator( features, targets, tf.estimator.ModeKeys.PREDICT).predictions saver = tf.train.Saver() with tf.train.MonitoredSession() as sess: saver.restore(sess, tf.train.latest_checkpoint(self.model_dir)) data = sess.run([features, predictions]) for prediction_tensor in nested_generator(data): image = prediction_tensor[0]['image'] image -= np.min(image) image /= np.max(image) plt.imshow(image) plt.show() dp = prediction_tensor[1]['deformed_points'] probs = prediction_tensor[1]['probs'] i = np.argmax(probs) predicted_vertices = np.matmul(bs[i], ps[i] + dp[i]) visualize_point_cloud(np.matmul(bs[i], ps[i]), color=(0, 0, 1), scale_factor=0.01) mlab.show() visualize_point_cloud(predicted_vertices, color=(1, 0, 0), scale_factor=0.01) mlab.show()
ds = get_template_ffd("/media/saurabh/e56e40fb-030d-4f7f-9e63-42ed5f7f6c711/preprocessing_new", desc_to_id("pistol"), edge_length_threshold=None, n_samples=16384) key = "1f646ff59cabdddcd810dcd63f342aca" with ds: b = np.array(ds[key]['b']) p = np.array(ds[key]['p']) mesh_dataset = get_thresholded_template_mesh("/media/saurabh/e56e40fb-030d-4f7f-9e63-42ed5f7f6c711/preprocessing_new", desc_to_id("pistol"), None) with mesh_dataset: f = np.array(mesh_dataset[key]['faces']) v_orignal = np.array(mesh_dataset[key]['vertices']) # print(b) # visualize_mesh(v_orignal, f) # mlab.show() visualize_mesh(np.matmul(b, p), f) mlab.show() visualize_point_cloud(np.matmul(b, p)) mlab.show() # from deformations.FFD import calculate_ffd # b, p = calculate_ffd(v_orignal, f) # isualize_mesh(np.matmul(b, p), f) # mlab.show()
from graphicUtils.visualizer.mayaviVisualizer import visualize_point_cloud from graphicUtils.visualizer.mayaviVisualizer import visualize_normals from datasetReader.h5py.cloudReader import CloudReader from mayavi import mlab import numpy as np reader = CloudReader("/media/saurabh/e56e40fb-030d-4f7f-9e63-42ed5f7f6c71/preprocessing_new/") dataset = reader.get_dataset("03948459", "pointCloud") with dataset: visualize_point_cloud( np.array(dataset['800cf19b2f7ce07e1ee14c0944aebb52']), scale_factor=0.005, color=(0, 1, 0)) mlab.show() #dataset = reader.get_dataset("03948459", "cloudNormal") #with dataset: # a = visualize_normals( # np.array(dataset['139ecc9b5ec25ea77a9772e56db4cd44']['points']), # np.array(dataset['139ecc9b5ec25ea77a9772e56db4cd44']['normals']), # scale_factor=0.005, color=(1, 0, 1)) # mlab.show()