The code has been tested with Python 3.6.9, TensorFlow 1.13.2, CUDA 10.0 and cuDNN 7.6.2 on Ubuntu 16.04.
Install TensorFlow. You can also use a TensorFlow Docker image. A Docker image that meets the TensorFlow, CUDA and cuDNN version that we used is tensorflow/tensorflow:1.13.2-gpu-py3.
Install h5py for Python:
sudo apt-get install libhdf5-dev
sudo pip install h5pyIn order to download the dataset for training and evaluation, wget package is required. To install wget:
sudo apt-get update
sudo apt-get install wgetCompile TensorFlow ops: nearest neighbor grouping, implemented by Qi et al.; structural losses, implemented by Fan et al. The ops are located under classification at grouping and structural losses folders, respectively. If needed, use a text editor and modify the corresponding sh file of each op to point to your nvcc path. Then, use:
cd classification/
sh compile_ops.shAn o and so files should be created in the corresponding folder of each op.
For a quick start please use:
sh runner_samplenet.shor:
sh runner_samplenet_progressive.shThese scripts train a classifier model with complete point clouds, use it to train a sampler (SampleNet or SampleNetProgressive), and then evaluate sampler by running its sampled points through the classifier model. In the following sections, we explain how to run each part of this pipeline separately.
Point clouds of ModelNet40 models in h5 files (provided by Qi et al.) will be automatically downloaded (416MB) on the first training of a classifier model. Each point cloud contains 2048 points uniformly sampled from a shape surface. Each cloud is zero-mean and normalized into an unit sphere. There are also json files specifying the IDs of shapes in the h5 files. The data will be downloaded to the folder classification/data/modelnet40_ply_hdf5_2048.
To train a PointNet model to classify point clouds, use:
python train_classifier.py --model pointnet_cls --log_dir log/PointNet1024To train the vanilla version of PointNet, use:
python train_classifier.py --model pointnet_cls_basic --log_dir log/PointNetVanilla1024To train SampleNet (with sample size 32 in this example), using an existing classifier (PointNet in this example) as the task network (provided in classifier_model_path argument), use:
python train_samplenet.py --classifier_model pointnet_cls --classifier_model_path log/PointNet1024/model.ckpt --num_out_points 32 --log_dir log/SampleNet32To evaluate classification with SampleNet's sampled points (with sample size 32 in this example), use:
python evaluate_samplenet.py --sampler_model_path log/SampleNet32/model.ckpt --num_out_points 32 --dump_dir log/SampleNet32/evalThis evaluation script computes classification accuracy results and saves them to the dump_dir.
To train SampleNetProgressive, using an existing classifier (PointNet vanilla in this example) as the task network (provided in classifier_model_path argument), use:
python train_samplenet_progressive.py --classifier_model pointnet_cls_basic --classifier_model_path log/PointNetVanilla1024/model.ckpt --log_dir log/SampleNetProgressiveEvaluation of SampleNetProgressive is done in two steps. First, infer SampleNetProgressive and save the ordered point clouds to h5 files:
python infer_samplenet_progressive.py --sampler_model_path log/SampleNetProgressive/model.ckpt --dump_dir log/SampleNetProgressiveThen, evaluate the classifier using SampleNetProgressive's sampled points:
python evaluate_from_files.py --classifier_model pointnet_cls_basic --classifier_model_path log/PointNetVanilla1024/model.ckpt --data_path log/SampleNetProgressive/sampled --dump_dir log/SampleNetProgressive/eval/sampledThis evaluation script computes classification accuracy results for different sample sizes and saves them to the dump_dir.
Our code builds upon the code provided by Qi et al. and Dovrat et al. We thank the authors for sharing their code.