Ubuntu20.04复现算法RandLa-Net 数据集S3DIS

最近在学习基于深度学习的点云分割算法,关注到牛津大学胡庆拥博士提出的RandLa-Net网络应用于城市级别的点云语义分割,所以想来复现一下。复现过程所参照的博文和代码如下(排序不分先后。没有各位大佬的分享,晚辈们必定寸步难行,感激不尽):

1、https://github.com/QingyongHu/RandLA-Net

2、https://zhuanlan.zhihu.com/p/105433460

3、https://github.com/luckyluckydadada/randla-net-tf2

4、在RTX 3090上复现点云语义分割算法RandLA-net_randlanet 3090-CSDN博客

5、Ubuntu18.04/20.04复现算法RandLa-net 数据集S3DIS_randlanet复现-CSDN博客

原论文代码的环境是python3.5+tensorflow1.11+cuda9(Hu Q, Yang B, Xie L, et al. Randla-net: Efficient semantic segmentation of large-scale point clouds[C]//Proceedings of the IEEE/CVF conference on computer vision and pattern recognition. 2020: 11108-11117.)

我学习复现的代码:https://github.com/luckyluckydadada/randla-net-tf2.git

我的复现环境:

RTX 4090 + Ubuntu20.04  + cuda12.1 + cudnn

Python 3.8, Tensorflow 2.4.1

复现步骤(Ubuntu系统终端):

conda create -n randlanet38 python=3.8
conda activate randlanet38
pip install tensorflow-gpu==2.4.1 -i https://pypi.tuna.tsinghua.edu.cn/simple  --timeout=120
cd /home/feng/PycharmProjects/randla-net-tf2-main
pip install -r helper_requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple  --timeout=120

注意:cd后面的路径根据自己情况修改!

“helper_requirements.txt“ 内容如下(如果不清楚自己安装的python环境和tensorflow、numpy等工具版本是否兼容的?可以尝试多问问大语言模型,本人也是在求助了多次AI之后,才最终得以解决版本适配的问题,多尝试几次总会成功):

numpy==1.20.3
h5py==3.1.0
cython==0.29.36
open3d==0.13.0
pandas==1.2.5
scikit-learn==0.24.2
scipy==1.6.3
PyYAML==5.4.1

sh compile_op.sh

在/home/feng/PycharmProjects/randla-net-tf2-main/data/S3DIS 下预存好Stanford3dDataset_v1.2_Aligned_Version 数据集;运行下面代码以准备好带注释的S3DIS数据集

python utils/data_prepare_s3dis.py

data_prepare_s3dis.py代码中涉及的路径可以最好像我一样直接给出绝对路径(这样最简单,不容易出错,如果有更好的解决办法,欢迎评论区留言):

python -B main_S3DIS.py --gpu 0 --mode train --test_area 1

 注意:上方代码如果报错类似下面这种:

ValueError: attempt to get argmin of an empty sequence
[[{{node PyFunc}}]]
[[IteratorGetNext]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main_S3DIS.py", line 300, in <module>
model.train(dataset)
File "/home/user/randla-net-tf2/RandLANet.py", line 290, in train
print(e.op.name)
AttributeError: 'NoneType' object has no attribute 'name'

可以尝试:定位到main_S3DIS.py中的 self.path = "/home/" + getpass.getuser() + "/data/S3DIS/" 将其修改为完整的文件夹路径即可,本人电脑的路径为: self.path = '/home/feng/PycharmProjects/randla-net-tf2-main/data/S3DIS/'

终端中显示下面内容(说明已经在正常训练啦):

经验之谈:可以将最大迭代次数调整到20次左右,下面是第23次迭代的结果:

欢迎点赞、收藏+转发,有问题随时评论区或私信交流,也尽情关注WX公众号“GRACE8Hydrology”  感谢支持

To be better!!!

### 复现 RandLA-Net 模型 #### 下载代码 为了获取 RandLA-Net 的源码,可以使用 Git 命令来克隆仓库: ```bash git clone --depth=1 https://github.com/QingyongHu/RandLA-Net && cd RandLA-Net ``` 此命令会从 GitHub 上拉取最新的 RandLA-Net 项目并进入该项目目录[^1]。 #### 准备环境依赖项 通常情况下,深度学习模型需要特定版本的 Python 和 PyTorch 库。建议创建一个新的虚拟环境,并安装所需的库。具体操作如下所示: ```bash conda create -n randla-net python=3.8 conda activate randla-net pip install torch torchvision torchaudio pip install -r requirements.txt ``` 其中 `requirements.txt` 文件包含了其他必要的Python包列表。 #### 修改数据预处理逻辑 对于自定义的数据集,在训练前需调整数据读取方式以适应新的存储结构。如果原始标签被嵌入到点云文件而不是单独保存,则应更新加载函数以便正确解析这些信息。另外,当输入不带色彩信息时,可简单地将颜色通道设为零向量: ```python import numpy as np def load_pointcloud(file_path): data = np.loadtxt(file_path, delimiter=',') points = data[:, :3] # 只保留xyz坐标 colors = np.zeros((points.shape[0], 3)) # 创建全零的颜色数组 return points, colors ``` 上述代码片段展示了如何忽略掉不存在的颜色属性[^2]。 #### 开始训练过程 完成以上准备工作之后,就可以按照官方文档中的指导启动训练脚本了。一般而言,这涉及到配置参数设置以及调用合适的API接口来进行迭代优化。具体的命令可能类似于下面这样: ```bash python train.py --data_dir /path/to/your/dataset \ --log_dir ./logs \ --batch_size 16 \ --num_workers 4 ``` 这里假设已经指定了正确的路径指向本地数据集位置以及其他超参选项。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

勇博士科研能干明白么

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值