【RandLA-Net】基于自建数据训练大场景语义分割网络RandLA-Net

0. 相关文章

PointNet模型搭建
基于自建数据训练PointNet分割网络
【PointNet++】PointNet++复现(PyTorch版本)
【PointNet++】基于自建数据训练PointNet++场景语义分割网络
【RandLA-Net】大场景语义分割网络RandLA-Net复现

1. 实验条件

Ubuntu 22.04,RTX 3090

2. 代码

仓库地址:https://github.com/QingyongHu/RandLA-Net/tree/master

可选的下载方式:

git clone --depth=1 https://github.com/QingyongHu/RandLA-Net.git

目录结构:

image-20250304150817010

3. 数据集

采用自采自建的隧道数据集,数据集及数据制作过程参考【PointNet++】基于自建数据训练PointNet++场景语义分割网络

4. 环境搭建

python3.6.13 + tensorflow1.14.0 + cuda12.1

  1. 初始化环境

    conda create -n myrandlanet python=3.6
    conda activate myrandlanet
    
  2. 安装相关依赖

    pip install numpy==1.19.5 -i https://pypi.tuna.tsinghua.edu.cn/simple --timeout=120
    pip install h5py~=3.1.0 -i https://pypi.tuna.tsinghua.edu.cn/simple --timeout=120
    pip install cython==0.29.15 -i https://pypi.tuna.tsinghua.edu.cn/simple --timeout=120
    pip install open3d-python==0.3.0 -i https://pypi.tuna.tsinghua.edu.cn/simple --timeout=120
    pip install pandas==1.1.5 -i https://pypi.tuna.tsinghua.edu.cn/simple --timeout=120
    pip install scipy==1.5.4 -i https://pypi.tuna.tsinghua.edu.cn/simple --timeout=120
    pip install scikit-learn==0.21.3 -i https://pypi.tuna.tsinghua.edu.cn/simple --timeout=120
    pip install PyYAML==6.0.1 -i https://pypi.tuna.tsinghua.edu.cn/simple --timeout=120
    pip install tensorflow-gpu==1.14 -i https://pypi.tuna.tsinghua.edu.cn/simple --timeout=120
    conda install cudatoolkit=11.2 cudnn=8.1 -c=conda-forge
    pip install keras==2.6.0
    
  3. 编译相关函数

    cd 路径/myrandlanet
    sh compile_op.sh
    
  4. 数据集预处理

    cd 路径/myrandlanet/utils
    python data_prepare_s3dis.py
    

5. 训练模型

5.1 修改数据相关文件

  1. data_utils/meta/anno_paths.txt文件修改

    在anno_paths.txt文件中写入数据集Annotations文件夹路径即可,本文采用新建my_anno_paths.txt文件的方式,文件内容如图所示:

    image-20250304153428489

  2. data_utils/meta/class_names.txt文件修改

    在class_names.txt文件中添加场景的语义类别,本文采用新建my_class_names.txt文件的方式,在文件中写入数据集所使用的语义类别,文件内容如图所示:

    image-20250304153538345

  3. data_prepare_s3dis文件修改

    修改anno_pathsgt_class路径:

    image-20250304153726563

    修改dataset_path路径:

    image-20250304155621003

5.2 修改main_S3DIS脚本

数据集名称、数据集路径、数据集类别

image-20250304160226111

5.3 helper_tool脚本

我们使用的是S3DIS数据集,因此只需要修改对应的class即可,如图所示圈出的部分为数据集中的数据类数量,根据自己数据集自行修改,其他配置项根据实验设备性能进行调整

image-20250304161208965

此外,还有类别权重需要修改,根据自己的标签数量修改,也可新添加一个分支

image-20250304162639558

5.4 数据预处理

cd 路径/myrandlanet/utils
python data_prepare_s3dis.py

5.5 训练模型

cd 路径/myrandlanet
python -B main_S3DIS.py --gpu 0 --mode train --test_area 1

6. 测试模型

cd 路径/myrandlanet
python -B main_S3DIS.py --gpu 0 --mode test --test_area 2

7. 可视化测试结果

在可视化之前首先需要对6_fold_cv脚本进行修改:

  1. 修改路径

    image-20250304163503897

    base_dir路径中是test测试之后生成的.ply文件目录路径,original_data_dir是预处理后的生成的original_ply目录路径

  2. 修改标签数量

    image-20250304163734456

    image-20250304163936262

最后运行6_fold_cv脚本

python utils/6_fold_cv.py

可视化的结果如下:

原始数据:

image-20250304164111960

标注数据:

image-20250304164131731

预测数据:

image-20250304164158954

8.可能会遇到的问题

tensorflow版本问题
tensorflow版本问题
其他问题,这个本文在训练时出现,通过排查是数据集路径构建错了,传入的数据为空,所以这样的报错

Logo

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。

更多推荐