This project implements a memory-efficient 3D point cloud classifier utilizing single-resolution spatial hashing. It compresses a 32³ binary voxel grid into a fixed-size 1D hash table, followed by classification using a lightweight Multi-Layer Perceptron (MLP). The methodology is evaluated on a 10-class ModelNet subset against a dense 3D CNN baseline.
data/processed/raw/ModelNet40/header_fix/
experiment_results/src/__init__.pydata/__init__.pydataset.pydense_dataset.pyoff_to_pointcloudv1.pyoff_to_pointcloudv2.pyvoxelization.py
experiments/__init__.pyplot_results.pyrun_hash_sweep.py
models/__init__.pycnn_3d_baseline.pyhash_encoder.pyhash_model.pymlp_classifier.py
training/__init__.pymetrics_logger.pytrain_cnn.pytrain_hash.py
utils/__init__.pyconfig.pyhash_function.py
.gitignorerequirements.txtrun_cnn.pytest_cnn.pytest_collision.pytest_dataset.pytest_models.pyvoxel_visual.pyvoxel_visualv2.py
We use a 10-class subset of ModelNet40 (airplane, car, chair, table, sofa, bed, bookshelf, desk, dresser, monitor). The dataset can be downloaded from Princeton ModelNet.
Z. Wu, S. Song, A. Khosla, F. Yu, L. Zhang, X. Tang and J. Xiao.
3D ShapeNets: A Deep Representation for Volumetric Shapes.
CVPR 2015.
Create a virtual environment and install dependencies:
python -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windows
pip install -r requirements.txt- Download and extract ModelNet40.zip.
- Place the extracted folder as
data/raw/ModelNet40/so that each category appears as a subdirectory, e.g.data/raw/ModelNet40/airplane/,data/raw/ModelNet40/car/, etc. - Run the preprocessing script:
python src/data/off_to_pointcloudv2.pyThis samples 2048 points per mesh, voxelizes into a 32³ binary grid, extracts occupied coordinates, and precomputes hash indices. Processed data is saved in data/processed/.
After configuring the desired parameters in the source files, execute the following: Run hash table size sweep (T = 256, 4096, 65536, 1048576):
python src/experiments/run_hash_sweep.pyRun CNN baseline:
python run_cnn.pyGenerate accuracy, memory, and collision rate plots:
python src/experiments/plot_results.pyResults are saved in experiment_results/.
| Method | Memory (MB) | Accuracy (%) | Collision Rate (%) |
|---|---|---|---|
| 3D CNN Baseline | 4.52 | 95.7 | 0.0 |
| Hash T = 1048576 | 32.00 | 85.8 | 0.0 |
| Hash T = 65536 | 2.00 | 82.8 | 0.5 |
| Hash T = 4096 | 0.12 | 85.3 | 11.8 |
| Hash T = 256 | 0.01 | 44.2 | 74.3 |
The spatial hash model at T=4096 reduces memory by 37.6x compared to the dense CNN baseline, with only a 10.4% drop in accuracy. Aggressive compression to T=256 leads to a 74.3% collision rate and collapses accuracy to near-random (44.2%). Moderate collisions (12%) are well tolerated, confirming that spatial hashing is a viable compression strategy for memory-constrained edge devices.