点击上方“3D视觉工坊”,选择“星标”
干货第一时间送达
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 ml3d cfg_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中的脚本。
本文仅做学术分享,如有侵权,请联系删文。
下载1
在「3D视觉工坊」公众号后台回复:3D视觉,即可下载 3D视觉相关资料干货,涉及相机标定、三维重建、立体视觉、SLAM、深度学习、点云后处理、多视图几何等方向。
下载2
在「3D视觉工坊」公众号后台回复:3D视觉github资源汇总,即可下载包括结构光、标定源码、缺陷检测源码、深度估计与深度补全源码、点云处理相关源码、立体匹配源码、单目、双目3D检测、基于点云的3D检测、6D姿态估计源码汇总等。
下载3
在「3D视觉工坊」公众号后台回复:相机标定,即可下载独家相机标定学习课件与视频网址;后台回复:立体匹配,即可下载独家立体匹配学习课件与视频网址。
重磅!3DCVer-学术论文写作投稿 交流群已成立
扫码添加小助手微信,可申请加入3D视觉工坊-学术论文写作与投稿 微信交流群,旨在交流顶会、顶刊、SCI、EI等写作与投稿事宜。
同时也可申请加入我们的细分方向交流群,目前主要有3D视觉、CV&深度学习、SLAM、三维重建、点云后处理、自动驾驶、CV入门、三维测量、VR/AR、3D人脸识别、医疗影像、缺陷检测、行人重识别、目标跟踪、视觉产品落地、视觉竞赛、车牌识别、硬件选型、学术交流、求职交流、ORB-SLAM系列源码交流、深度估计等微信群。
一定要备注:研究方向+学校/公司+昵称,例如:”3D视觉 + 上海交大 + 静静“。请按照格式备注,可快速被通过且邀请进群。原创投稿也请联系。
▲长按加微信群或投稿
▲长按关注公众号
3D视觉从入门到精通知识星球:针对3D视觉领域的知识点汇总、入门进阶学习路线、最新paper分享、疑问解答四个方面进行深耕,更有各类大厂的算法工程人员进行技术指导。与此同时,星球将联合知名企业发布3D视觉相关算法开发岗位以及项目对接信息,打造成集技术与就业为一体的铁杆粉丝聚集区,近2000星球成员为创造更好的AI世界共同进步,知识星球入口:
学习3D视觉核心技术,扫描查看介绍,3天内无条件退款
圈里有高质量教程资料、可答疑解惑、助你高效解决问题
觉得有用,麻烦给个赞和在看~