pytorch環境でmmdectionターゲット検出ライブラリをインストールするすべての手順


商湯科技(2018 COCO目標検出挑戦試合チャンピオン)と香港中国語大学は最近、Pytorchに基づいて実現された深い学習目標検出ツールボックスmmdetectionをオープンし、Faster-CNN、Mask-CNN、Fast-CNNなどの主流の目標検出フレームワークをサポートし、現在はCascade-CNN、SSD、その他の一連の目標検出フレームワークを追加している.現在yoloの計画hhhはありません.
FacebookのオープンソースのDetectronフレームワークに比べて、著者はmmdetectionに3つの利点があると主張している:performanceはやや高く、訓練速度はやや速く、必要なディスプレイはやや小さい.
プロジェクトには、このプロジェクトのオープンソースの時間が短く、関連チュートリアルが少ないので、自分が踏んだ穴を記録して他の人に道を舗装しましょう.
本人のシステム環境:
Ubuntu 16.04 Cuda 9.0+Cudnn 7.4.2 Python 3.5(mmdetectionはPythonバージョン3.4+)
Anaconda 3 (  )
        Anaconda,         Python    ,     Python       。

mmdetectionをインストールする前に、PyTorch 1.0.0とtorchvision Cython mmcvのいくつかの依存ライブラリをインストールする必要があります.
リファレンス作成者
作者:张正昊今日も努力しますアヒルの出所:CSDN原文:https://blog.csdn.net/qq_36302589/article/details/85798060著作権声明:本文はブロガーのオリジナル文章で、転載はブログのリンクを添付してください!
本文はオフラインでpytorch 1.0.0をダウンロードしてpip 3をアップグレードしてtorchvisionをダウンロードします
その中の経歴も波乱万丈で、pip 3をダウンロードするのは理にかなっている.
sudo apt install pip3

しかし途中で問題が発生したためpython 2.7はpipをダウンロードせず、python 3では以下の方法でpip 3をアップグレードした.
インストール
Install mmdetection
  • Install PyTorch 1.0 and torchvision following the official instructions.

  • pytorchを検出し、torchvisionがダウンロードに成功したかどうかを検出します.
    import torch
    import torchvision
    

    2.cythonのインストール
    pip install  cython
    

    3.mmcvのインストール
        git clone https://github.com/open-mmlab/mmcv.git
        cd mmcv
        pip install .
    

    4.Clone the mmdetection repository.本明細書はgithubと手動でダウンロードしたことがある
    git clone https://github.com/open-mmlab/mmdetection.git
    

    c. Compile cuda extensions.
    cd mmdetection
    pip install cython  # or "conda install cython" if you prefer conda
    ./compile.sh  # or "PYTHON=python3 ./compile.sh" if you use system python3 without virtual environments
    
    	   python3,       python——python3 
    

    d. Install mmdetection (other dependencies will be installed automatically).
    python(3) setup.py install  # add --user if you want to install it locally
    # or "pip install ."
    

    Note: You need to run the last step each time you pull updates from github. The git commit id will be written to the version number and also saved in trained models.
    これで、mmdetectionとその依存ライブラリのインストールを完了しました.
    7.テストdemo
    下のコードをpyファイルに書き込み、mmdetectionフォルダディレクトリに保存して実行します.このコードの機能は画像の中の目標を検出することであり、テストモデルは公式に与えられたFaster-CNN-fpn-resnet 50のモデルであり、コードを実行すると自動的にモデルがダウンロードされる.モデルはアマゾンクラウドサーバに格納されているため、速度がやや遅くなる可能性があります.
    import mmcv
    from mmcv.runner import load_checkpoint
    from mmdet.models import build_detector
    from mmdet.apis import inference_detector, show_result
     
    cfg = mmcv.Config.fromfile('configs/faster_rcnn_r50_fpn_1x.py')
    cfg.model.pretrained = None
     
    #     ,    
    model = build_detector(cfg.model, test_cfg=cfg.test_cfg)
     
    _ = load_checkpoint(model, 'https://s3.ap-northeast-2.amazonaws.com/open-mmlab/mmdetection/models/faster_rcnn_r50_fpn_1x_20181010-3d1b3351.pth')
     
    #       
    img = mmcv.imread('test.jpg')
    result = inference_detector(model, img, cfg)
    show_result(img, result)