Open3

2024年8月11日~2024年8月17日

tttttttttttttttttttt

8/11 SAHIについて

画像を分割してそれぞれに検出を行って、それぞれを最終的に結合を行う方法。

小さな物体を検出するためによく使われる。

mmdetectionやdetectron2にも対応している。

https://github.com/obss/sahi

  • どんなアルゴリズムで検出しているのか?
tttttttttttttttttttt

8/12 SAHIについて②

detectron2で行う場合以下のurlにチュートリアルが存在する。

https://colab.research.google.com/github/obss/sahi/blob/main/demo/inference_for_detectron2.ipynb

colabの場合、detectron2のインストール方法を以下の様に変更することで実行可能。

!pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cpu/torch1.10/index.html # for Detectron2-cpu
#!pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu111/torch1.10/index.html # for Detectron2-cuda11.1

!python -m pip install pyyaml==5.1
import sys, os, distutils.core

!git clone 'https://github.com/facebookresearch/detectron2'
dist = distutils.core.run_setup("./detectron2/setup.py")
!python -m pip install {' '.join([f"'{x}'" for x in dist.install_requires])}
sys.path.insert(0, os.path.abspath('./detectron2'))

kaggle kernelの場合、detectron2のインストール方法をcolabと同じにしたうえで、shapelyのライブラリのバージョンを以下の様に指定。(kernelの設定を確認すると、なぜか初期からshapely==1.8.5.post1shapely==2.0.5が入っているが、2.0.5のバージョンをimportできないので再インストールする必要がある。)

!pip uninstall shapely -y #kaggleのkernelはnotebook上でy,nの選択ができない
!pip install shapely==2.0.5

※kernelの設定を確認すると、なぜか初期からshapely==1.8.5.post1shapely==2.0.5が入っているが、2.0.5のバージョンをimportできないので再インストールする必要がある。(kaggleのkernelの仕様?)

tttttttttttttttttttt

8/13 標準出力と標準入力について

某書にて、以下の二つの出力が違う原因について分析をしていた。

  1. find /root -name "README.license" 1> /dev/null 2>&1
  2. find /root -name "README.license" 2>&1 1> /dev/null

※上記のコマンドは、rootファイル内の"README.licenseがあるパスを探索するコードである。

まず、find /root -name "README.license"はrootファイル内の"README.licenseがあるパスを探索するコマンド

1> /dev/nullは標準出力(ここでは見つかったパスを返す)をnull(出力無し)にする。

2>&1はエラー出力(ここでは権限不足で探索できないエラー)を標準出力に変換する。

1.はあらかじめ標準出力をnullと定義し、もともとの標準出力がnullになった後、エラー出力を標準出力にしているので、全ての出力がnullになり、何も出力されない。

2.は、2>&1のタイミングで「エラー出力を標準出力」にするだけなので、エラー出力のみが標準出力して出力される。その後、標準出力をnullにしているので、もともとの標準出力は何も示されない。

と説明すると以下の出力の説明がつかない...

よくわからない。

find /root -name "README.license" 1>&2 2> /dev/null
/root/Desktop/README.license
find /root -name "README.license" 2> /dev/null 2>&1
find: ‘/root/.cache’: 許可がありません
find: ‘/root/.config/chromium’: 許可がありません
find: ‘/root/.local/share/nvim’: 許可がありません
find: ‘/root/.ssh’: 許可がありません
/root/Desktop/README.license
find: ‘/root/.synaptic’: 許可がありません
find: ‘/root/.dbus’: 許可がありません
find: ‘/root/.john’: 許可がありません
find /root -name "README.license" 1>&2 1> /dev/null
find: ‘/root/.cache’: 許可がありません
find: ‘/root/.config/chromium’: 許可がありません
find: ‘/root/.local/share/nvim’: 許可がありません
find: ‘/root/.ssh’: 許可がありません
find: ‘/root/.synaptic’: 許可がありません
find: ‘/root/.dbus’: 許可がありません
find: ‘/root/.john’: 許可がありません
find /root -name "README.license" 2>&1 2> /dev/null
/root/Desktop/README.license