0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

open3dにpytorchとの連携があるだと

Last updated at Posted at 2024-08-14

初めに

ロボットの分野での画像認識は、空間として理解することが必要になる。
しかし、現状では機械学習の学習済みモデルは2次元の画像に対して推論するものになっている。
そのため、機械学習での推論結果を3Dとして解釈し直す仕組みが必要になる。

この文章で述べること

3Dのデータを処理するためのライブラリであるOpen3Dに機械学習のライブラリであるpytorchとの連携のための枠組みが用意されていることの紹介。

Open3D-ML

An extension of Open3D to address 3D Machine Learning tasks

Open3D-MLは、3D機械学習タスクのためのOpen3Dの拡張機能です。Open3Dコアライブラリの上に構築され、3Dデータ処理のための機械学習ツールで拡張されています。このレポは、セマンティック点群セグメンテーションのようなアプリケーションに焦点を当て、一般的なタスクに適用可能な事前学習済みモデルと、学習用パイプラインを提供します。
Open3D-MLはTensorFlowやPyTorchと連携し、既存のプロジェクトに簡単に統合できるほか、データの可視化などMLフレームワークに依存しない一般的な機能も提供します。
DeepL による翻訳

datasetの読み込み

dataset名前空間には、一般的なデータセットを読み込むためのクラスが含まれている。ここでは、SemanticKITTIデータセットを読み込んで可視化する。

設定ファイルの読み込み

モデル、データセット、パイプラインの設定はml3d/configsに格納されています。また、カスタマイズした設定を記録しておくために、ユーザー自身がyamlファイルを構築することもできます。以下は、設定ファイルを読み込み、そこからモジュールを構築する例です。

.py
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_202201071330utc.pth"
randlanet_url = "https://storage.googleapis.com/open3d-releases/model-zoo/randlanet_semantickitti_202201071330utc.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()
抜粋
pipeline = ml3d.pipelines.ObjectDetection(model, dataset=dataset, device="gpu", **cfg.pipeline)

pipeline.load_ckpt(ckpt_path=ckpt_path)

# run inference on a single example.
# returns dict with 'predict_labels' and 'predict_scores'.
result = pipeline.run_inference(data)

セマンティックセグメンテーション

セマンティックセグメンテーションの事前学習済みモデルの実行

先ほどの例に基づき、セマンティックセグメンテーションの事前学習済みモデルを持つパイプラインをインスタンス化し、データセットの点群に対して実行します。事前学習されたモデルの重みを取得するには、model zooを参照してください。

より多くの例については、examples/とscripts/ディレクトリを参照してください。また、設定ファイルでトレーニングサマリーの保存を有効にしたり、tensorboardでground truthや結果を可視化することもできます。詳しくはこのチュートリアルを参照してください。

個人的な感想

  • 標準化のメリット
    物体検出やセグメンテーションなどの推論と3Dの点群との処理を
    それぞれのライブラリを想定することで、インタフェースが標準化された実装が可能になる。
    機械学習の推論のモデルを差し替えても同じような処理が可能になるはずだ。

比較事例

StereoLabs ZED SDK の検出サンプル
https://www.stereolabs.com/docs/body-tracking

Using the Object Detection API with a Custom Detector
https://www.stereolabs.com/docs/object-detection/custom-od

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?