UniDet のインストールと動作確認を行う.
【目次】
【文献】
Simple multi-dataset detection, Zhou, Xingyi and Koltun, Vladlen and Kr{\"a}henb{\"u}hl, Philipp, CVPR, 2022.
【関連する外部ページ】
Gitは,バージョン管理システム.ソースコードの管理や複数人での共同に役立つ.
【サイト内の関連ページ】
Windows での Git のインストール: 別ページ »で説明している.
【関連する外部ページ】
Git の公式ページ: https://git-scm.com/
【サイト内の関連ページ】
【関連する外部ページ】
Python の公式ページ: https://www.python.org/
【サイト内の関連ページ】
NVIDIA グラフィックスボードを搭載しているパソコンの場合には, NVIDIA ドライバ, NVIDIA CUDA ツールキット, NVIDIA cuDNN のインストールを行う.
【関連する外部ページ】
コマンドプロンプトを管理者として実行: 別ページ »で説明
PyTorch のページ: https://pytorch.org/index.html
次のコマンドは, PyTorch 2.0 (NVIDIA CUDA 11.8 用) をインストールする. 但し,Anaconda3を使いたい場合には別手順になる.
事前に NVIDIA CUDA のバージョンを確認しておくこと(ここでは,NVIDIA CUDA ツールキット 11.8 が前もってインストール済みであるとする).
PyTorch で,GPU が動作している場合には,「torch.cuda.is_available()」により,True が表示される.
python -m pip install -U --ignore-installed pip python -m pip install -U torch torchvision torchaudio numpy --index-url https://download.pytorch.org/whl/cu118 python -c "import torch; print(torch.__version__, torch.cuda.is_available())"
Anaconda3を使いたい場合には, Anaconda プロンプト (Anaconda Prompt) を管理者として実行し, 次のコマンドを実行する. (PyTorch と NVIDIA CUDA との連携がうまくいかない可能性があるため,Anaconda3を使わないことも検討して欲しい).
conda install -y pytorch torchvision torchaudio pytorch-cuda=11.8 cudnn -c pytorch -c nvidia py -c "import torch; print(torch.__version__, torch.cuda.is_available())"
【サイト内の関連ページ】
【関連する外部ページ】
コマンドプロンプトを管理者として実行: 別ページ »で説明
※ 「pip install ...」は,Python パッケージをインストールするための操作
python -m pip install -U opencv-python opencv-contrib-python
pycocotools のインストールを行う.
コマンドプロンプトを管理者として実行: 別ページ »で説明
COCOデータセットをPythonで扱うためには,pycocotools を使う. pycocotools を使うことで,COCOデータセットのアノテーションを扱いやすくなる.
次のコマンドを実行
python -m pip install -U --ignore-installed pip python -m pip install -U cython wheel python -m pip install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI" python -m pip install git+https://github.com/cocodataset/panopticapi.git
Windows での Detectron2 のインストール: 別ページ »で説明している.
コマンドプロンプトを管理者として実行: 別ページ »で説明
cd %HOMEPATH% rmdir /s /q unidet git clone --recursive https://github.com/xingyizhou/UniDet cd UniDet mkdir models
公式ページ https://github.com/xingyizhou/UniDet を開き, このページの本文中の「MODEL ZOO」をクリック.
このページで,学習済みモデルをダウンロードできる. ここでは,Unified_learned_OCIM_R50_6x+2x.pth をダウンロードする.
ダウンロードしたファイルは %HOMEPATH%\UniDet\models の下に置く.
cd %HOMEPATH% cd UniDet python demo.py --config-file configs/Unified_learned_OCIM_R50_6x+2x.yaml --input images/*.jpg --opts MODEL.WEIGHTS models/Unified_learned_OCIM_R50_6x+2x.pth