This program aims to detect wildlife from camera trap images using MegaDetector (Beery et al. 2019) and to extract images in which animals were detected. This document is a minimal description and will be updated as needed.
このプログラムは、MegaDetector (Beery et al. 2019)を利用してカメラトラップ映像から野生動物を検出し、動物が検出された画像を抽出することを目的として作成されました。このドキュメントは現時点では最低限の記述しかされていないため、今後随時更新していく予定です。
-
OS
The following code was tested on Windows 10 Pro.
During the test run, .jpg as the image file format.
以下のコードはWindows 10 Proで動作確認しています。
動作確認時、静止画ファイル形式は.jpgを用いました。 -
NVIDIA Driver(if you use gpu) NVIDAドライバーをインストールする
Please refer to NVIDIA Driver Version Check. *** is a placeholder. Please enter the recommended nvidia driver version.
NVIDIAドライババージョンチェックを参照し、***に推奨されるnvidiaドライババージョンを入力した上で実行してください。Check installation.
インストール状況の確認。nvidia-smi # NVIDIA Driver installation check
If nvidia-smi does not work, Try Rebooting.
nvidia-smiコマンドが動作しない場合は再起動してみてください。 -
Conda
miniconda(anaconda)をインストール https://docs.conda.io/projects/miniconda/en/latest/
condaのパスを通す システム環境変数の編集->環境変数->PATH->新規->condaのpathをコピペ(例 C:\Users{ユーザー名}\miniconda3\condabin)
-
Clone the Repository:リポジトリの複製
Run
git clone
,
git clone
を実行するor Download ZIP and Unzip in any directory of yours. The following codes are assumed that it was extracted to the user's home directory (
/home/${USER}/
).
もしくはZIPをダウンロードし、任意のディレクトリで解凍してください。なお、このページではユーザのホームディレクトリ(/home/${USER}/
)に解凍した前提でスクリプトを記載しています。 -
Move Project Directory:プロジェクトディレクトリへ移動
cd {ImageExtractWinのパス} 例 cd project\ImageExtractWin-master python make_batch.py
-
create conda environment:conda環境の構築
conda env create -f environment.yml
-
gpuを使う場合、以下のサイトを見てバージョンを合わせたものをインストールする CUDA Toolkit 12.3 Downloads https://developer.nvidia.com/cuda-downloads
cudnnのインストール(ログインが必要) https://developer.nvidia.com/rdp/cudnn-download
pip uninstall torch torchvision torchaudio pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
-
ディレクトリの移動
cd {ImageExtractWinのパス} 例 cd project\ImageExtractWin-master
-
conda環境のアクティベート
conda activate pwlife
-
gpuが使えるか確認
python gpu_check.py
-
Run MegaDetector
MegaDetectorの実行python exec_mdet.py session_root={カメラデータが入ったフォルダ} threshold={検出の閾値} checkpoint={途中で保存するファイル数}
thresholdは省略可(デフォルトは0.2)
checkpointに入れた数のファイルを処理し終えるごとに途中経過が保存される(省略可)。r + x(数字)で全体のx分の一経過で保存(例:ファイル数200 r10 で20ファイルごとに保存)
{カメラデータが入ったフォルダ}_outにjsonファイルとcsvファイルが保存される
1.プロジェクトディレクトリへ移動 ImageExtractWinのフォルダを開いてdetect.batをコピー
2.カメラ画像のフォルダへ移動 解析したい画像のフォルダを開いてdetect.batをペースト detect.batをダブルクリック