首页 > Open3D面向机器学习的扩展库

Open3D面向机器学习的扩展库

点击“蓝字”关注点云PCL,选择“星标”获取最新文章

Open3D-ML是Open3D的一个扩展,用于3D机器学习任务。它建立在Open3D核心库之上,并通过机器学习工具对其进行扩展,以进行3D数据处理。此repo集中于语义点云分割等应用程序,并提供可应用于常见任务的预训练模型以及用于训练的流程。

Open3D-ML与TensorFlow和PyTorch一起工作,可以轻松地集成到现有项目中,还可以提供独立于ML框架的通用功能,如数据可视化。

安装

Open3D-ML集成在Open3D v0.11+python发行版中,并与以下版本的ML框架兼容

* PyTorch 1.6

* TensorFlow 2.3

* CUDA 10.1 (On GNU/Linux x86_64, optional)

安装Open3D

# make sure you have the latest pip version
pip install --upgrade pip
# install open3d
pip install open3d

要安装Pythorch或TensorFlow的兼容版本,需要使用相应的需求文件:

# To install a compatible version of TensorFlow
pip install -r requirements-tensorflow.txt
# To install a compatible version of PyTorch with CUDA
pip install -r requirements-torch-cuda.txt

测试安装

# with PyTorch
$ python -c "import open3d.ml.torch as ml3d"# or with TensorFlow
$ python -c "import open3d.ml.tf as ml3d"

如果需要使用不同版本的ML框架或CUDA,可以从源代码重新构建Open3D。

使用教程

读取数据集

dataset命名空间包含用于读取公共数据集的类。这里我们读取SemanticKITTI数据集并将其可视化。

import open3d.ml.torch as ml3d  # or open3d.ml.tf as ml3d# construct a dataset by specifying dataset_path
dataset = ml3d.datasets.SemanticKITTI(dataset_path='/path/to/SemanticKITTI/')# get the 'all' split that combines training, validation and test set
all_split = dataset.get_split('all')# print the attributes of the first datum
print(all_split.get_attr(0))# print the shape of the first point cloud
print(all_split.get_data(0)['point'].shape)# show the first 100 frames using the visualizer
vis = ml3d.vis.Visualizer()
vis.visualize_dataset(dataset, 'all', indices=range(100))import open3d.ml.torch as ml3d # or open3d.ml.tf as ml3d
# construct a dataset by specifying dataset_pathdataset = ml3d.datasets.SemanticKITTI(dataset_path='/path/to/SemanticKITTI/')
# get the 'all' split that combines training, validation and test setall_split = dataset.get_split('all')
# print the attributes of the first datumprint(all_split.get_attr(0))
# print the shape of the first point cloudprint(all_split.get_data(0)['point'].shape)
# show the first 100 frames using the visualizervis = ml3d.vis.Visualizer()
vis.visualize_dataset(dataset, 'all', indices=range(100))

加载配置文件

模型、数据集和流程的配置存储在ml3d/Configs中。用户还可以构建自己的yaml文件来记录他们的定制配置。下面是一个读取配置文件并从中构造模块的示例。

import open3d.ml as _ml3d
import open3d.ml.torch as ml3d # or open3d.ml.tf as ml3d  framework = "torch" # or tf
cfg_file = "ml3d/configs/randlanet_semantickitti.yml"
cfg = _ml3d.utils.Config.load_from_file(cfg_file)# fetch the classes by the name
Pipeline = _ml3d.utils.get_module("pipeline", cfg.pipeline.name, framework)
Model = _ml3d.utils.get_module("model", cfg.model.name, framework)
Dataset = _ml3d.utils.get_module("dataset", cfg.dataset.name)# use the arguments in the config file to construct the instances 
cfg.dataset['dataset_path'] = "/path/to/your/dataset"
dataset = Dataset(cfg.dataset.pop('dataset_path', None), **cfg.dataset)
model = Model(**cfg.model)
pipeline = Pipeline(model, dataset, **cfg.pipeline)

运行一个预先训练过的模型

在上一个例子的基础上,我们可以用一个预先训练的语义分割模型实例化一个算法,并在数据集的点云上运行它。查看模型集合以获取预训练模型的权重。

import os
import open3d.ml as _ml3d
import open3d.ml.torch as ml3dcfg_file = "ml3d/configs/randlanet_semantickitti.yml"
cfg = _ml3d.utils.Config.load_from_file(cfg_file)model = ml3d.models.RandLANet(**cfg.model)
cfg.dataset['dataset_path'] = "/path/to/your/dataset"
dataset = ml3d.datasets.SemanticKITTI(cfg.dataset.pop('dataset_path', None), **cfg.dataset)
pipeline = ml3d.pipelines.SemanticSegmentation(model, dataset=dataset, device="gpu", **cfg.pipeline)# download the weights.
ckpt_folder = "./logs/"
os.makedirs(ckpt_folder, exist_ok=True)
ckpt_path = ckpt_folder + "randlanet_semantickitti_202009090354utc.pth"
randlanet_url = "https://storage.googleapis.com/open3d-releases/model-zoo/randlanet_semantickitti_202009090354utc.pth"
if not os.path.exists(ckpt_path):cmd = "wget {} -O {}".format(randlanet_url, ckpt_path)os.system(cmd)# load the parameters.
pipeline.load_ckpt(ckpt_path=ckpt_path)test_split = dataset.get_split("test")
data = test_split.get_data(0)# run inference on a single example.
# returns dict with 'predict_labels' and 'predict_scores'.
result = pipeline.run_inference(data)# evaluate performance on the test set; this will write logs to './logs'.
pipeline.run_test()

用户还可以使用预定义的脚本来加载预先训练的权重并运行测试。

训练模型

与推理类似,流程中提供了一个在数据集上训练模型的接口。

# use a cache for storing the results of the preprocessing (default path is './logs/cache')
dataset = ml3d.datasets.SemanticKITTI(dataset_path='/path/to/SemanticKITTI/', use_cache=True)# create the model with random initialization.
model = RandLANet()pipeline = SemanticSegmentation(model=model, dataset=dataset, max_epoch=100)# prints training progress in the console.
pipeline.run_train()

有关更多示例,请参见examples/和scripts/目录。

使用预定义脚本

scripts/semseg.py 提供了一个简单的数据集评估接口。准确地定义模型,避免了定义具体模型的麻烦。

python scripts/semseg.py {tf/torch} -c --

注意, extra args 将优先于配置文件中的相同参数。因此,在启动脚本时,可以将其作为命令行参数传递,而不是更改配置文件中的param。

例如:

# Launch training for RandLANet on SemanticKITTI with torch.
python scripts/semseg.py torch -c ml3d/configs/randlanet_semantickitti.yml --dataset.dataset_path  --dataset.use_cache True# Launch testing for KPConv on Toronto3D with tensorflow.
python scripts/semseg.py tf -c ml3d/configs/kpconv_toronto3d.yml --split test --dataset.dataset_path  --model.ckpt_path 

要获得进一步的帮助,可运行python脚本 python scripts/semseg.py --help

ML库结构

Open3D-ML的核心部分位于ml3d子文件夹中,该子文件夹被集成到ML命名空间中的Open3D中。除了核心部分之外,目录示例和脚本还提供了支持脚本,用于开始在数据集上设置训练流程或运行网络。

├─ docs                   # Markdown and rst files for documentation
├─ examples               # Place for example scripts and notebooks
├─ ml3d                   # Package root dir that is integrated in open3d├─ configs           # Model configuration files├─ datasets          # Generic dataset code; will be integratede as open3d.ml.{tf,torch}.datasets├─ utils             # Framework independent utilities; available as open3d.ml.{tf,torch}.utils├─ vis               # ML specific visualization functions├─ tf                # Directory for TensorFlow specific code. same structure as ml3d/torch.│                    # This will be available as open3d.ml.tf├─ torch             # Directory for PyTorch specific code; available as open3d.ml.torch├─ dataloaders  # Framework specific dataset code, e.g. wrappers that can make use of the│               # generic dataset code.├─ models       # Code for models├─ modules      # Smaller modules, e.g., metrics and losses├─ pipelines    # Pipelines for tasks like semantic segmentation
├─ scripts                # Demo scripts for training and dataset download scripts

任务和算法

分割

对于语义分割的任务,我们使用mIoU(mean interp-over-union)来衡量不同方法在所有类上的性能。下表显示了分段任务的可用模型和数据集以及各自的分数。每个分数链接到各自的权重文件。

模型集合

有关所有权重文件的完整列表,请参见模型文件 model_weights.txt 以及MD5校验model_weights.md5.

数据集集合

下面是我们为其提供数据集读取器类的数据集列表。

SemanticKITTI

Toronto 3D 

Semantic 3D 

S3DIS 

Paris-Lille 3D 

要下载这些数据集,请访问相应的网页,可查看scripts/download_datasets中的脚本。

资源

三维点云论文及相关应用分享

【点云论文速读】基于激光雷达的里程计及3D点云地图中的定位方法

3D目标检测:MV3D-Net

三维点云分割综述(上)

3D-MiniNet: 从点云中学习2D表示以实现快速有效的3D LIDAR语义分割(2020)

win下使用QT添加VTK插件实现点云可视化GUI

JSNet:3D点云的联合实例和语义分割

大场景三维点云的语义分割综述

PCL中outofcore模块---基于核外八叉树的大规模点云的显示

基于局部凹凸性进行目标分割

基于三维卷积神经网络的点云标记

点云的超体素(SuperVoxel)

基于超点图的大规模点云分割

更多文章可查看:点云学习历史文章大汇总

SLAM及AR相关分享

【开源方案共享】ORB-SLAM3开源啦!

【论文速读】AVP-SLAM:自动泊车系统中的语义SLAM

【点云论文速读】StructSLAM:结构化线特征SLAM

SLAM和AR综述

常用的3D深度相机

AR设备单目视觉惯导SLAM算法综述与评价

SLAM综述(4)激光与视觉融合SLAM

Kimera实时重建的语义SLAM系统

SLAM综述(3)-视觉与惯导,视觉与深度学习SLAM

易扩展的SLAM框架-OpenVSLAM

高翔:非结构化道路激光SLAM中的挑战

SLAM综述之Lidar SLAM

基于鱼眼相机的SLAM方法介绍

往期线上分享录播汇总

第一期B站录播之三维模型检索技术

第二期B站录播之深度学习在3D场景中的应用

第三期B站录播之CMake进阶学习

第四期B站录播之点云物体及六自由度姿态估计

第五期B站录播之点云深度学习语义分割拓展

第六期B站录播之Pointnetlk解读

[线上分享录播]点云配准概述及其在激光SLAM中的应用

[线上分享录播]cloudcompare插件开发

[线上分享录播]基于点云数据的 Mesh重建与处理

[线上分享录播]机器人力反馈遥操作技术及机器人视觉分享

[线上分享录播]地面点云配准与机载点云航带平差

点云PCL更多活动请查看:点云PCL活动之应届生校招群

扫描下方微信视频号二维码可查看最新研究成果及相关开源方案的演示:

如果你对本文感兴趣,请点击“原文阅读”获取知识星球二维码,务必按照“姓名+学校/公司+研究方向”备注加入免费知识星球,免费下载pdf文档,和更多热爱分享的小伙伴一起交流吧!

以上内容如有错误请留言评论,欢迎指正交流。如有侵权,请联系删除

扫描二维码

                   关注我们

让我们一起分享一起学习吧!期待有想法,乐于分享的小伙伴加入免费星球注入爱分享的新鲜活力。分享的主题包含但不限于三维视觉,点云,高精地图,自动驾驶,以及机器人等相关的领域。

分享及合作方式:微信“920177957”(需要按要求备注) 联系邮箱:[email protected],欢迎企业来联系公众号展开合作。

点一下“在看”你会更好看耶

更多相关:

  • 一、资料 参考原文: TensorFlow全新的数据读取方式:Dataset API入门教程 API接口简介: TensorFlow的数据集   二、背景 注意,在TensorFlow 1.3中,Dataset API是放在contrib包中的: tf.contrib.data 而在TensorFlow 1.4中,Dataset AP...

  • DataSet中的relation DataSet是ADO.Net中相当重要的数据访问模型。有一个很大的优点是可以记录多个表之间的关系。有点类似与数据库的外键。 在DataSet中也可以定义类似的关系。DataSet有一个属性Relation,是DataRelation对象的集合,要创建新的关系,可以使用Relation的Add...

  • 上篇笔记中梳理了一把 resolver 和 balancer,这里顺着前面的流程走一遍入口的 ClientConn 对象。ClientConn// ClientConn represents a virtual connection to a conceptual endpoint, to // perform RPCs. // //...

  • 我的实验是基于PSPNet模型实现二维图像的语义分割,下面的代码直接从得到的h5文件开始往下做。。。 也不知道是自己的检索能力出现了问题还是咋回事,搜遍全网都没有可以直接拿来用的语义分割代码,东拼西凑,算是搞成功了。 实验平台:Windows、VS2015、Tensorflow1.8 api、Python3.6 具体的流程为:...

  • Path Tracing 懒得翻译了,相信搞图形学的人都能看得懂,2333 Path Tracing is a rendering algorithm similar to ray tracing in which rays are cast from a virtual camera and traced through a s...

  • configure_file( [COPYONLY] [ESCAPE_QUOTES] [@ONLY][NEWLINE_STYLE [UNIX|DOS|WIN32|LF|CRLF] ]) 我遇到的是 configure_file(config/config.in ${CMAKE_SOURCE_DIR}/...

  •     直接复制以下代码创建一个名为settings.xml的文件,放到C:UsersAdministrator.m2下即可