diff --git a/ScaFFold/datagen/instance.py b/ScaFFold/datagen/instance.py index 91067ee..801cb0b 100644 --- a/ScaFFold/datagen/instance.py +++ b/ScaFFold/datagen/instance.py @@ -25,7 +25,6 @@ from pathlib import Path import numpy as np -import open3d from mpi4py import MPI from ScaFFold.datagen.generate_fractal_points import generate_fractal_points @@ -170,33 +169,18 @@ def main(config: Config): # Generate points points = generate_single_instance(config.point_num, params) - # Force point_data to be contiguous -- prevents possible segfaults in later Vector3dVector call from non-contiguous arrays + # Force point_data to be contiguous points_contiguous = np.ascontiguousarray(points, dtype=DEFAULT_NP_DTYPE) - # Create o3d PointCloud object - pointcloud = open3d.geometry.PointCloud() - - # Populate PointCloud points attribute with point_data - pointcloud.points = open3d.utility.Vector3dVector(points_contiguous) - - # Construct the long path and short filename + # Construct the output path out_dir = Path(instance_write_dir) / f"{category:06d}" - filename = f"{category:06d}_{instance:04d}.ply" + filename = f"{category:06d}_{instance:04d}.npy" # Ensure parent directory exists out_dir.mkdir(parents=True, exist_ok=True) - # Save current working directory so we can restore it later - cwd = os.getcwd() - try: - # Change to the output directory - os.chdir(out_dir) - - # Write with short relative path - open3d.io.write_point_cloud(filename, pointcloud) - finally: - # Always restore the working directory - os.chdir(cwd) + # Save array to out_dir + np.save(out_dir / filename, points_contiguous) end_time = time.time() total_time = end_time - start_time diff --git a/ScaFFold/datagen/volumegen.py b/ScaFFold/datagen/volumegen.py index d1120ab..479e67e 100644 --- a/ScaFFold/datagen/volumegen.py +++ b/ScaFFold/datagen/volumegen.py @@ -23,7 +23,6 @@ from typing import Dict import numpy as np -import open3d as o3d from mpi4py import MPI from ScaFFold.utils.config_utils import Config @@ -31,12 +30,11 @@ DEFAULT_NP_DTYPE = np.float64 -def load_ply_with_open3d(path: str) -> np.ndarray: +def load_np_ptcloud(path: str) -> np.ndarray: """ - Read a .ply via Open3D and return an (N,3) array of dtype float64. + Read a .npy file and return an (N,3) array of dtype float64. """ - pcd = o3d.io.read_point_cloud(path) - pts = np.asarray(pcd.points) + pts = np.load(path) return pts.astype(DEFAULT_NP_DTYPE, copy=False) @@ -204,7 +202,7 @@ def main(config: Dict): "fractals", instances_dir, f"{curr_category:06d}", - f"{curr_category:06d}_{curr_instance:04d}.ply", + f"{curr_category:06d}_{curr_instance:04d}.npy", ) if not os.path.exists(point_cloud_path): @@ -213,7 +211,7 @@ def main(config: Dict): ) sys.exit(1) - points = load_ply_with_open3d(point_cloud_path) + points = load_np_ptcloud(point_cloud_path) mask3d = points_to_voxelgrid(points, grid_size) assert mask3d.shape == volume.shape[:3], ( diff --git a/pyproject.toml b/pyproject.toml index 1caa3a3..4f8ed54 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,7 +49,6 @@ dependencies = [ "numba>=0.60.0", "tqdm>=4.67.1", "wandb>=0.19.6", - "open3d>=0.18.0", "PyYAML>=6.0.2", "distconv @ git+https://github.com/LBANN/DistConv.git@232cba6", ] diff --git a/requirements.txt b/requirements.txt index 8361868..e0165fb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,6 @@ numpy>=1.26.4 numba>=0.60.0 tqdm>=4.67.1 wandb>=0.19.6 -open3d>=0.18.0 PyYAML>=6.0.2 mpi4py==4.1.1 --no-binary mpi4py distconv @ git+https://github.com/LBANN/DistConv.git@232cba6