LoginSignup
0
0

動画セグメンテーションソフトウェア XMem でのtroubleshooting

Last updated at Posted at 2024-05-10

XMem は今時点でSota のvideo segmentation のライブラリである。
https://github.com/hkchengrex/XMem/

この記事で述べること

  • 動画へのセグメンテーションを実行してくれるライブラリであるXMemのインストール手順

以下の内容は無保証です。

ソフトウェアはリリース後に、依存ライブラリのバージョンが変更になるのはいつものことです。
そのために、公式のリリースの手順に従ってもエラーがでるのはありがちなことです。

実行時のライブラリの不足対策

from 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load the Qt xcb platform plugin

sudo add-apt-repository universe
sudo apt-get update
sudo apt-get install libxcb-cursor-dev
sudo apt-get install libxcb-cursor0

DEIVISION_BY_ZERO 対策

~/github/XMem$ git diff inference/interact/gui.py
diff --git a/inference/interact/gui.py b/inference/interact/gui.py
index 9c52214..5ea047a 100644
--- a/inference/interact/gui.py
+++ b/inference/interact/gui.py
@@ -875,11 +875,11 @@ class App(QWidget):
         global_used = global_total - global_free
 
         self.gpu_mem_gauge.setFormat(f'{global_used:.01f} GB / {global_total:.01f} GB')
-        self.gpu_mem_gauge.setValue(round(global_used/global_total*100))
+        self.gpu_mem_gauge.setValue(round(global_used/(global_total + 1e-6)*100))
 
         used_by_torch = torch.cuda.max_memory_allocated() / (2**20)
         self.torch_mem_gauge.setFormat(f'{used_by_torch:.0f} MB / {global_total:.01f} GB')
-        self.torch_mem_gauge.setValue(round(used_by_torch/global_total*100/1024))
+        self.torch_mem_gauge.setValue(round(used_by_torch/(global_total + 1e-6)*100/1024))
 
     def on_gpu_timer(self):
         self.update_gpu_usage()

使い方

python3 interactive_demo.py --video [path to the video] --num_objects 4
  • 動画が再生できることを確認する
  • 動画の冒頭で、対象物1つにセグメンテーションする。
    • Scribble, click, free のどれかを選ぶ。
    • click を選ぶと、クリックした点を中心に領域をセグメンテーションする。
  • "Forward Propagation"を選ぶ。

Q: GPUが使われていないのをどうしたらいいですか?

A: PyTorch の環境がGPU(=CUDA)を使う設定になっていないのが原因です。

  • Jetsonでは該当のJetPackに対応するバージョンのPytorchのディスクイメージが公開されています。
  • それを用いてDocker環境で動作させるのがよい。
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