2
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?

【単眼深度推定】Depth Proよりも精度が高そうなDepth Anything AC試してみた

Posted at

はじめに

前回投稿した記事でAppleのDepth Proを使って遊んでいましたが、それを超える?高精度の単眼深度推定モデルが出てきたみたいなので試してみました。
ACはAny Conditionの略で、名前の通り普通のモデルでは推定が苦手そうなノイズがかった画像などに効果を発揮してそうです。

どうやらDepthAnything-V2をファインチューニングしたモデルとのこと。
image.png
引用:https://ghost233lism.github.io/depthanything-AC-page/

インストール

https://github.com/HVision-NKU/DepthAnythingAC
基本的に公式の手順通りです。
新たにconda環境を作てそこにインストール。

git clone https://github.com/your-repo/Depth-Anything-AC
cd Depth-Anything-AC
conda create -n depth_anything_ac python=3.9
conda activate depth_anything_ac
pip install -r requirements.txt

公式のrequirements.txtではなぜかtorchやcuda類のインストールが記述されてないので別途以下を実行する必要がありました(あとで修正されるかもね)。

conda install pytorch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 pytorch-cuda=12.1 -c pytorch -c nvidia

(わざわざPytorch公式サイトまで行って調べてきた)
https://pytorch.org/get-started/previous-versions/

お次はフォルダを作って推論モデルをダウンロードする。

mkdir checkpoints
cd checkpoints

# (Optional) Using huggingface mirrors
export HF_ENDPOINT=https://hf-mirror.com

# download DepthAnything-AC model from huggingface
huggingface-cli download --resume-download ghost233lism/DepthAnything-AC --local-dir ghost233lism/DepthAnything-AC

私はwindows環境なので手動でcheckpointsフォルダを作成し、huggingface-cliも使わずに公式が提供してくれているgoogle drieのリンクも使わずにわざわざhuggingfaceのサイトからモデルを直接ダウンロードしました。
google driveのリンクは以下。

We also provide the DepthAnything-AC model on Google Drive: Download


つまり、こんな感じになればOK。
image.png
image.png

実行

使いかたはここに書いてあります。見るかんじ結構いろんなオプションに対応してそうです。

推論したい画像を指定して以下を実行。

python tools/infer.py --input example.jpg --output out.jpg

結果

Depth Proのほうに入っていたこの画像を使って比較してみます。
example.jpg


out.jpg
これはDepth Anything AC。

depth_map_output.png

これはAppleのDepth Pro。

それぞれ色表現が違うのでわかりづらくて申し訳ないですが、繊細な部分はDepth Proに軍配が上がる気が。色表現の問題かな?

ではDepth Anything ACが得意としているノイズがかった画像ではどうでしょうか。

night_rgb_001750.png
推しアイドルのMVの1分12秒あたりから参照。

night_depth_001750.png
これがDepth Pro。

nigh_out.png
これがDepth Anything AC。

たしかにDepth Proより精度が良さそう。左手の部分が潰れずに深度が取れてるし、後ろの人物を綺麗に推定できてる。

感想

髪の毛1本1本のような繊細な部分はAppleのDepth Proが優れていそうですが、ブレなどのノイズがかった画像ではDepth Anything ACのほうが圧倒的に精度が良さそうです。

あと推論モデルをロードするまでの時間の差かもしれませんが、体感的にAppleのDepth Proよりも処理が速い気がします。

そしてこのDepth Anything ACは動画にもデフォルトで対応してます。なので動画を入力したら動画を出力します。

また動画まるごと深度推定してQuestで立体動画を見てそこも比較しようと思います。

2
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
2
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?