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 <path-to-config> --<extra args>
注意, 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 <path-to-dataset> --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 <path-to-dataset> --model.ckpt_path <path-to-checkpoint>要獲得進一步的幫助,可運行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”(需要按要求備注) 聯系郵箱:dianyunpcl@163.com,歡迎企業來聯系公眾號展開合作。
點一下“在看”你會更好看耶
總結
以上是生活随笔為你收集整理的Open3D面向机器学习的扩展库的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Fast ORB-SLAM
- 下一篇: Open3d学习计划—高级篇 4(多视角