以下是一个详细的技术文档,描述了 `Pointnet_Pointnet2_pytorch` 项目中每个文件和文件夹的作用。
PointNet and PointNet++ in PyTorch
项目概述
`Pointnet_Pointnet2_pytorch` 是一个基于 PyTorch 实现的 PointNet 和 PointNet++ 的项目。该项目支持多种任务,包括分类、部分分割和语义分割。项目提供了预训练模型和详细的训练、测试脚本。
文件和文件夹结构
Pointnet_Pointnet2_pytorch/
├── data_utils/
├── log/
├── models/
├── visualizer/
├── .gitattributes
├── .gitignore
├── LICENSE
├── README.md
├── provider.py
├── test_classification.py
├── test_partseg.py
├── test_semseg.py
├── train_classification.py
├── train_partseg.py
├── train_semseg.py
文件和文件夹详细说明
根目录
- **.gitattributes**: Git 属性文件,用于配置 Git 行为。
- **.gitignore**: Git 忽略文件,用于指定哪些文件和目录不应被 Git 跟踪。
- **LICENSE**: 项目的许可证文件,指明了项目的使用条款。
- **README.md**: 项目的主文档,包含项目介绍、安装指南、使用说明等。
- **provider.py**: 数据加载和预处理工具,包含数据增强等功能。
- **test_classification.py**: 分类任务的测试脚本。
- **test_partseg.py**: 部分分割任务的测试脚本。
- **test_semseg.py**: 语义分割任务的测试脚本。
- **train_classification.py**: 分类任务的训练脚本。
- **train_partseg.py**: 部分分割任务的训练脚本。
- **train_semseg.py**: 语义分割任务的训练脚本。
文件夹
- **data_utils/**: 包含数据处理和预处理的脚本。
- **collect_indoor3d_data.py**: 用于处理 S3DIS 数据集的脚本。
- **indoor3d_util.py**: 用于处理室内点云数据的工具函数。
- **ModelNetDataLoader.py**: 用于加载 ModelNet 数据集的脚本。
- **ShapeNetDataLoader.py**: 用于加载 ShapeNet 数据集的脚本。
- **log/**: 存放训练日志和模型检查点的目录。
- **classification/**: 分类任务的日志和模型检查点。
- **partseg/**: 部分分割任务的日志和模型检查点。
- **semseg/**: 语义分割任务的日志和模型检查点。
- **models/**: 包含各种模型的定义。
- **pointnet2_msg.py**: PointNet++ MSG 模型的定义。
- **pointnet2_ssg.py**: PointNet++ SSG 模型的定义。
- **pointnet2_utils.py**: PointNet++ 中使用的实用函数和模块。
- **pointnet_cls.py**: PointNet 分类模型的定义。
- **pointnet_part_seg.py**: PointNet 部分分割模型的定义。
- **pointnet_sem_seg.py**: PointNet 语义分割模型的定义。
- **visualizer/**: 包含可视化工具和脚本。
- **build.sh**: 构建 C++ 可视化工具的脚本。
- **show3d_balls.py**: 用于可视化点云的 Python 脚本。
- **pic2.png**: 示例图片。
安装和环境配置
环境要求
- **操作系统**: Ubuntu 16.04
- **CUDA**: CUDA 10.1
- **PyTorch**: PyTorch 1.6
- **Python**: Python 3.7
安装依赖
conda install pytorch==1.6.0 cudatoolkit=10.1 -c pytorch
数据准备
分类任务 (ModelNet10/40)
1. 下载 ModelNet 数据集并解压到 `data/modelnet40_normal_resampled/`。
2. 如果需要离线数据预处理,可以使用 `--process_data` 选项。预处理后的数据可以下载并保存到 `data/modelnet40_normal_resampled/`。
部分分割任务 (ShapeNet)
1. 下载 ShapeNet 数据集并解压到 `data/shapenetcore_partanno_segmentation_benchmark_v0_normal/`。
语义分割任务 (S3DIS)
1. 下载 S3DIS 数据集并解压到 `data/s3dis/Stanford3dDataset_v1.2_Aligned_Version/`。
2. 运行数据处理脚本:
cd data_utils
python collect_indoor3d_data.py
处理后的数据将保存在 `data/stanford_indoor3d/`。
运行脚本
分类任务
1. 训练模型:
python train_classification.py --model pointnet2_cls_ssg --log_dir pointnet2_cls_ssg
2. 测试模型:
python test_classification.py --log_dir pointnet2_cls_ssg
部分分割任务
1. 训练模型:
python train_partseg.py --model pointnet2_part_seg_msg --normal --log_dir pointnet2_part_seg_msg
2. 测试模型:
python test_partseg.py --normal --log_dir pointnet2_part_seg_msg
语义分割任务
1. 训练模型:
python train_semseg.py --model pointnet2_sem_seg --test_area 5 --log_dir pointnet2_sem_seg
2. 测试模型:
python test_semseg.py --log_dir pointnet2_sem_seg --test_area 5 --visual
性能指标
分类任务 (ModelNet40)
| 模型 | 准确率 |
| --- | --- |
| PointNet (官方) | 89.2% |
| PointNet2 (官方) | 91.9% |
| PointNet (PyTorch, 无法线) | 90.6% |
| PointNet (PyTorch, 有法线) | 91.4% |
| PointNet2_SSG (PyTorch, 无法线) | 92.2% |
| PointNet2_SSG (PyTorch, 有法线) | 92.4% |
| PointNet2_MSG (PyTorch, 有法线) | 92.8% |
部分分割任务 (ShapeNet)
| 模型 | 实例平均 IoU | 类别平均 IoU |
| --- | --- | --- |
| PointNet (官方) | 83.7% | 80.4% |
| PointNet2 (官方) | 85.1% | 81.9% |
| PointNet (PyTorch) | 84.3% | 81.1% |
| PointNet2_SSG (PyTorch) | 84.9% | 81.8% |
| PointNet2_MSG (PyTorch) | 85.4% | 82.5% |
语义分割任务 (S3DIS)
| 模型 | 总体准确率 | 类别平均 IoU | 模型大小 |
| --- | --- | --- | --- |
| PointNet (PyTorch) | 78.9% | 43.7% | 40.7MB |
| PointNet2_SSG (PyTorch) | 83.0% | 53.5% | 11.2MB |
可视化
使用 `show3d_balls.py`
1. 构建 C++ 可视化工具:
cd visualizer
bash build.sh
2. 运行可视化脚本:
python show3d_balls.py
使用 MeshLab
1. 可视化结果保存在 `log/sem_seg/pointnet2_sem_seg/visual/` 目录下。
2. 使用 MeshLab 打开 `.obj` 文件进行可视化。
引用
如果在研究中使用了此项目,请引用以下文献:
bibtex
@article{Pytorch_Pointnet_Pointnet2,
Author = {Xu Yan},
Title = {Pointnet/Pointnet++ Pytorch},
Journal = {https://github.com/yanx27/Pointnet_Pointnet2_pytorch},
Year = {2019}
}
@InProceedings{yan2020pointasnl,
title={PointASNL: Robust Point Clouds Processing using Nonlocal Neural Networks with Adaptive Sampling},
author={Yan, Xu and Zheng, Chaoda and Li, Zhen and Wang, Sheng and Cui, Shuguang},
journal={Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition},
year={2020}
}
@InProceedings{yan2021sparse,
title={Sparse Single Sweep LiDAR Point Cloud Segmentation via Learning Contextual Shape Priors from Scene Completion},
author={Yan, Xu and Gao, Jiantao and Li, Jie and Zhang, Ruimao, and Li, Zhen and Huang, Rui and Cui, Shuguang},
journal={AAAI Conference on Artificial Intelligence ({AAAI})},
year={2021}
}
@InProceedings{yan20222dpass,
title={2DPASS: 2D Priors Assisted Semantic Segmentation on LiDAR Point Clouds},
author={Xu Yan and Jiantao Gao and Chaoda Zheng and Chao Zheng and Ruimao Zhang and Shuguang Cui and Zhen Li},
year={2022},
journal={ECCV}
}
其他项目
- **PointConv**: Deep Convolutional Networks on 3D Point Clouds, CVPR'19
- **On Isometry Robustness of Deep 3D Point Cloud Models under Adversarial Attacks**, CVPR'20
- **Label-Efficient Learning on Point Clouds using Approximate Convex Decompositions**, ECCV'20
- **PCT: Point Cloud Transformer**
- **PSNet: Fast Data Structuring for Hierarchical Deep Learning on Point Cloud**
- **Stratified Transformer for 3D Point Cloud Segmentation**, CVPR'22
联系方式
如果有任何问题或建议,请联系项目维护者:
- **作者**: Xu Yan
- **GitHub**: [yanx27](https://github.com/yanx27)
- **邮箱**: [yanx27@outlook.com]
希望这份技术文档对你有所帮助!如果有任何其他问题或需要进一步的帮助,请随时告知。