本次实验所用的是服务器上的GPU:RTX 2080 Ti(11GB) ,环境配置为:Ubuntu18.04、TensorFlow1.15.0以及cuda 10.0,python3.6.0。之前就在该网络上跑通了S3DIS数据集,所以沿用之前的环境配置进行了数据拷贝以及实例迁移。出于需要对自己的古建筑数据集在该网络进行测评。所以本内容着重基于讲解如何修改参数和路径以便跑通网络,对于环境配置内容不重点阐述。内容按照py文件进行修改。
1.数据预处理
1.克隆存储库:
git clone --depth=1 https://github.com/QingyongHu/RandLA-Net && cd RandLA-Net
然后放在根目录下进行解压:unzip RandLA-Net-master.zip
2.设置python环境:
conda create -n randlanet python=3.5
source activate randlanet
pip install -r helper_requirements.txt
sh compile_op.sh
3.准备训练数据:
准备好自己的数据集,将其进行解压,在RandLA-Net-master目录下创建一个文件夹命名为“data"然后将数据放在该文件夹下。
2.data_prepare_s3dis.py
from sklearn.neighbors import KDTree
from os.path import join, exists, dirname, abspath
import numpy as np
import pandas as pd
import os, sys, glob, pickle
BASE_DIR = dirname(abspath(__file__))
ROOT_DIR = dirname(BASE_DIR)
sys.path.append(BASE_DIR)
sys.path.append(ROOT_DIR)
from helper_ply import write_ply
from helper_tool import DataProcessing as DP
dataset_path = '/root/autodl-tmp/RandLA-Net-master/data/S3DIS' #修改数据路径
anno_paths = [line.rstrip() for line in open(join(BASE_DIR, 'meta/anno_paths.txt'))]
anno_paths = [join(dataset_path, p) for p in anno_paths]
gt_class = [x.rstrip() for x in open(join(BASE_DIR, 'meta/class_names.txt'))]
gt_class2label = {cls: i for i, cls in enumerate(gt_class)}
sub_grid_size = 0.04
original_pc_folder = join(dirname(dataset_path), 'original_ply')
sub_pc_folder = join(dirname(dataset_path), 'input_{:.3f}'.format(sub_grid_size))
os.mkdir(original_pc_folder) if not exists(original_pc_folder) else None
os.mkdir(sub_pc_folder) if not exists(sub_pc_folder) else None
out_format = '.ply'
def convert_pc2ply(anno_path, save_path):
"""
Convert original dataset files to ply file (each line is XYZRGBL).
We aggregated all the points from each instance in the room.
:param anno_path: path to annotations. e.g. Area_1/office_2/Annotations/
:param save_path: path to save original point clouds (each line is XYZRGBL)
:return: None
"""
data_list = []
for f in glob.glob(join(anno_path, '*.txt')):