For the complete documentation index, see llms.txt. This page is also available as Markdown.

Depth Anything V2

Dedicated Deployment または self-hosted Inference で単眼深度推定に Depth Anything V2 を使用します

Depth Anything V2 は単眼深度推定モデルです。任意の入力画像に対して、正規化された深度マップ(0 から 1 の値)を返します。

Depth Anything V2 は Serverless Hosted API では利用できません。a 上で実行してください。 Dedicated Deployment または self-hosted Inference.

コードサンプル

1

API Key を取得する

Roboflow アカウントを作成し、キーを次の場所で見つけます Roboflow API 設定ページ そしてシェルで利用できるようにします:

export ROBOFLOW_API_KEY="your-key-here"
2

依存関係をインストールする

次をインストールします: Inference SDK:

pip install inference-sdk opencv-python
3

モデルを実行する

設定する api_url を Dedicated Deployment URL またはローカルの Inference サーバーに指定します。スクリプトは深度マップに色を付け、入力との並列比較を保存します。

import os
import cv2
import numpy as np
import requests
from inference_sdk import InferenceHTTPClient

content = requests.get("https://media.roboflow.com/notebooks/examples/bicycle.png").content
image = cv2.imdecode(np.frombuffer(content, np.uint8), cv2.IMREAD_COLOR)
client = InferenceHTTPClient(
    api_url="https://your-deployment.roboflow.cloud",
    api_key=os.environ["ROBOFLOW_API_KEY"],
)
result = client.depth_estimation(image)

depth = np.array(result["normalized_depth"], dtype=np.float32)
depth = cv2.resize(depth, (image.shape[1], image.shape[0]))
depth_vis = (depth * 255).astype(np.uint8)
depth_color = cv2.applyColorMap(depth_vis, cv2.COLORMAP_INFERNO)

cv2.imwrite("depth_annotated.png", np.hstack([image, depth_color]))

推論速度

〜で測定されたレイテンシ Roboflow Inference 1x NVIDIA L4、バッチサイズ 1、ウォームアップ後の平均で測定。

モデル
レイテンシ (ms)

depth-anything-v2

40.1

Small checkpoint で計測しました。

設定する api_url をデプロイ先に合わせてください:

  • http://localhost:9001 ローカルの Inference サーバー用。

  • あなたの Dedicated Deployment プライベートエンドポイントの URL。

最終更新

役に立ちましたか?