diff --git a/.gitignore b/.gitignore index 6232d11..08ebda8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ *.pyc data/ test.dae -mesh_objects.py \ No newline at end of file +mesh_objects.py +out/ \ No newline at end of file diff --git a/mise.py b/mise.py index c19b961..94ea336 100644 --- a/mise.py +++ b/mise.py @@ -17,14 +17,10 @@ from visualization import plot_3d_points, plot_voxel, convert_to_sparse_voxel_grid, visualize_points_overlay from sdf_dataset import get_sdf_dataset, get_pcd -from embedding import cloud_embedding - -sys.path.append('/home/markvandermerwe/catkin_ws/src/ll4ma_3d_reconstruction/src/data_generation/') -from generate_view_splits import get_view_splits - _MODEL_FUNC = get_pointconv_model _MODEL_PATH = '/home/markvandermerwe/models/ICRA_Models/reconstruction/pointconv_mse_cf' -_SAVE_PATH = '/home/markvandermerwe/data/ReconstructedMeshesTest/Real' +_SPLITS_PATH = '/home/markvandermerwe/catkin_ws/src/ll4ma_3d_reconstruction/src/data_generation/data_split/test_fold.txt' +_SAVE_PATH = 'out/test_dir/' _PCD_DATABASE = '/dataspace/ICRA_Data/PyrenderData/Depth/' _GRASP_DATABASE = False _OBJECT_FRAME = False @@ -198,7 +194,7 @@ def mise_voxel(get_sdf, bound, initial_voxel_resolution, final_voxel_resolution, def get_test_meshes(grasp_database=True, ycb_database=False): meshes = set() - with open('/home/markvandermerwe/catkin_ws/src/ll4ma_3d_reconstruction/src/data_generation/data_split/test_fold.txt') as f: + with open(_SPLITS_PATH) as f: for view in f: if grasp_database and 'poisson' in view: meshes.add('_'.join(view.split('_')[:-1])) @@ -207,22 +203,16 @@ def get_test_meshes(grasp_database=True, ycb_database=False): fin_meshes = [] for mesh in meshes: - fin_meshes.append(mesh + '_10') + fin_meshes.append(mesh + '_10') # Only use the 10th rendered view. return fin_meshes - -def get_real_pt_cld(): - real_info = "/home/markvandermerwe/data/GraspTestData/recon_high/mustard_p1_a1/grasp_plan_info.pickle" - obj_dict = pickle.load(open(real_info)) - return obj_dict['scaled_object_cloud'], (obj_dict['max_dim'] * (1.03/1.0)), obj_dict['scale'], [0,0,0] def mesh_objects(model_func, model_path, save_path, pcd_folder, grasp_database=True): # Setup model. get_sdf, get_embedding, _ = get_sdf_prediction(model_func, model_path) # Get names of partial views. - # meshes = get_test_meshes(grasp_database=grasp_database, ycb_database=(not grasp_database)) - meshes = ["mustard_real"] + meshes = get_test_meshes(grasp_database=grasp_database, ycb_database=(not grasp_database)) # Bounds of 3D space to evaluate in: [-bound, bound] in each dim. bound = 0.8 @@ -234,8 +224,7 @@ def mesh_objects(model_func, model_path, save_path, pcd_folder, grasp_database=T # Mesh the views. for mesh in tqdm(meshes): # Point cloud for this view. - # pc_, length, scale, centroid_diff = get_pcd(mesh, pcd_folder, object_frame=_OBJECT_FRAME, verbose=False); - pc_, length, scale, centroid_diff = get_real_pt_cld() + pc_, length, scale, centroid_diff = get_pcd(mesh, pcd_folder, object_frame=_OBJECT_FRAME, verbose=False); voxel_size = (2.*bound * length) / float(final_voxel_resolution) if pc_ is None: diff --git a/run_sdf_model.py b/run_sdf_model.py index 49797a0..19d3d7a 100644 --- a/run_sdf_model.py +++ b/run_sdf_model.py @@ -13,7 +13,7 @@ from helper import get_num_trainable_variables, shuffle_in_unison, get_bn_decay, get_learning_rate from visualization import plot_3d_points, plot_voxel, convert_to_sparse_voxel_grid -def run(get_model, train_path, validation_path, model_path, logs_path, batch_size=32, epoch_start=0, epochs=100, learning_rate=1e-4, optimizer='adam', train=True, warm_start=False, alpha=0.5, loss_function='mse', sdf_count=64): +def run_sdf(get_model, train_path, validation_path, model_path, logs_path, batch_size=32, epoch_start=0, epochs=100, learning_rate=1e-4, optimizer='adam', train=True, warm_start=False, sdf_count=64, voxel=False): # Read in training and validation files. train_files = [os.path.join(train_path, filename) for filename in os.listdir(train_path) if ".tfrecord" in filename] @@ -48,7 +48,7 @@ def run(get_model, train_path, validation_path, model_path, logs_path, batch_siz xyz_in = tf.placeholder(tf.float32, name="query_points") sdf_labels = tf.placeholder(tf.float32, name="query_labels") is_training = tf.placeholder(tf.bool, name="is_training") - sdf_prediction, loss, debug = get_model(points, xyz_in, sdf_labels, is_training, bn_decay, batch_size=batch_size, alpha=alpha, loss_function=loss_function) + sdf_prediction, loss, debug = get_model(points, xyz_in, sdf_labels, is_training, bn_decay, batch_size=batch_size) # Get update ops for the BN. update_ops = tf.get_collection(tf.GraphKeys.UPDATE_OPS) @@ -92,7 +92,6 @@ def run(get_model, train_path, validation_path, model_path, logs_path, batch_siz # Track loss throughout updates. total_loss = 0.0 examples = 0 - while True: try: # Split the given features into batches. @@ -115,8 +114,8 @@ def run(get_model, train_path, validation_path, model_path, logs_path, batch_siz plot_3d_points(point_clouds_[0]) plot_3d_points(pts) - plot_3d_points(pts, truth) - plot_3d_points(pts, pred) + plot_3d_points(pts, signed_distances=truth) + plot_3d_points(pts, signed_distances=pred) total_loss += loss_