金子邦彦研究室人工知能Windows でのインストールと動作確認(人工知能関係)CutLER のインストールと動作確認(教師なし学習によるセグメンテーションと,自己学習による物体検出)(Detectron2, PyTorch, Python を使用)(Windows 上)

CutLER のインストールと動作確認(教師なし学習によるセグメンテーションと,自己学習による物体検出)(Detectron2, PyTorch, Python を使用)(Windows 上)

CutLER のインストールと動作確認を行う.

MaskCut は,画像から,複数のセグメンテーション・マスク (segmentation mask)を得る.ViT を使用

CutLER は,MaskCut の結果に対して物体検出を実行.自己学習 (self-training) を使用.

目次

  1. 前準備
  2. Detectron2 のインストール(Windows 上)
  3. CutLER のインストール(Windows 上)

文献

Wang, Xudong and Girdhar, Rohit and Yu, Stella X and Misra, Ishan, Cut and Learn for Unsupervised Object Detection and Instance Segmentation, arXiv preprint arXiv:2301.11320, 2023.

関連する外部ページ

前準備

Git, cmake のインストール(Windows 上)

Git のインストール(Windows 上)

Windows での Git のインストール: 別ページ »で説明

関連する外部ページ

Git の公式ページ: https://git-scm.com/

cmake のインストール(Windows 上)

cmake のダウンロードのページ https://cmake.org/download/ からダウンロードしてインストール

cmake のインストールの詳細: 別ページ »で説明

Python のインストール(Windows 上)

Windows での Python 3.10,関連パッケージ,Python 開発環境のインストール: 別ページ »で説明

サイト内の関連ページ

Python のまとめ: 別ページ »にまとめ

関連する外部ページ

Python の公式ページ: https://www.python.org/

Build Tools for Visual Studio 2022,NVIDIA ドライバ,NVIDIA CUDA ツールキット,NVIDIA cuDNN のインストール(Windows 上)

Windows での Build Tools for Visual Studio 2022NVIDIA ドライバNVIDIA CUDA ツールキット 11.8,NVIDIA cuDNN v8.6 のインストールと動作確認: 別ページ »で説明

関連する外部ページ

PyTorch のインストール(Windows 上)

  1. Windows で,コマンドプロンプト管理者として実行

    コマンドプロンプトを管理者として実行: 別ページ »で説明

  2. PyTorch のページを確認

    PyTorch のページ: https://pytorch.org/index.html

  3. 次のようなコマンドを実行(実行するコマンドは,PyTorch のページの表示されるコマンドを使う).

    次のコマンドは, PyTorch 2.0 (NVIDIA CUDA 11.8 用) をインストールする. 事前に NVIDIA CUDA のバージョンを確認しておくこと(ここでは,NVIDIA CUDA ツールキット 11.8 が前もってインストール済みであるとする).

    python -m pip install -U pip
    python -m pip install -U torch torchvision torchaudio numpy numba --index-url https://download.pytorch.org/whl/cu118
    python -c "import torch; print(torch.__version__, torch.cuda.is_available())" 
    

    (途中省略)
    [image]

Python の opencv-python のインストール

  1. Windows で,コマンドプロンプト管理者として実行

    コマンドプロンプトを管理者として実行: 別ページ »で説明

  2. opencv-python のインストール

    ※ 「pip install ...」は,Python パッケージをインストールするための操作

    python -m pip install -U opencv-python opencv-contrib-python
    

Detectron2 のインストール(Windows 上)

次の記事に記載の手順による.

https://dgmaxime.medium.com/how-to-easily-install-detectron2-on-windows-10-39186139101c

  1. Windows で,コマンドプロンプト管理者として実行

    コマンドプロンプトを管理者として実行: 別ページ »で説明

  2. cython のインストール
    python -m pip install cython
    
  3. pycocotools のインストール
    python -m pip install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"
    
  4. Detectron2 のインストールと動作確認

    https://github.com/DGMaxime/detectron2-windows を使用している.

    python -m pip uninstall detectron2
    cd %HOMEPATH%
    rmdir /s /q detectron2-windows
    git clone --recursive https://github.com/DGMaxime/detectron2-windows.git
    cd detectron2-windows
    python -m pip install -e .
    python tests\test_windows_install.py
    
  5. 結果の確認

    [image]

    結果が,次のように表示される.

    [image]
  6. 引き続き,COCO 2018 Panoptic Segmentation Task API, The Cityscapes Dataset 用スクリプトのインストール
    pip install git+https://github.com/cocodataset/panopticapi.git
    pip install git+https://github.com/mcordts/cityscapesScripts.git
    

    [image]

CutLER のインストール(Windows 上)

  1. Windows で,コマンドプロンプト管理者として実行

    コマンドプロンプトを管理者として実行: 別ページ »で説明

  2. PyDenseCRF のインストール

    次のコマンドを実行.

    python -m pip install git+https://github.com/lucasb-eyer/pydensecrf.git
    
  3. CutLER のインストール

    次のコマンドを実行.

    cd %HOMEPATH%
    rmdir /s /q CutLER
    git clone --recursive https://github.com/facebookresearch/CutLER.git
    cd CutLER
    python -m pip install -U faiss_cpu
    python -m pip install -U opencv-python scikit-image scikit-learn shapely timm pyyaml colored fvcore gdown
    
  4. 動作確認のため MaskCut による教師なし学習のセグメンテーションを実行

    demo.jpg ができる.

    cd %HOMEPATH%
    cd CutLER
    cd maskcut
    python demo.py --img-path imgs/demo2.jpg --N 3 --tau 0.15 --vit-arch base --patch-size 8 --cpu --out-dir .
    

    [image]

    [image]