Windows下面安裝MMDetection圖文教程

  1. https://github.com/open-mmlab/mmdetection/blob/master/docs/get_started.md
  2. 注意事項
    • 在安裝MMDetection之前需要先將環(huán)境中的MMCV卸載掉
      • 注意:如果你安裝了mmcv,你需要先運行 pip uninstall mmcv將其卸載掉。如果 mmcv 和 mmcv-full 都安裝了,就會有ModuleNotFoundError.
    • MMCV的版本需要和PyTorch以及cuda的版本匹配才行
      • https://github.com/open-mmlab/mmcv#installation
    • 不用安裝最新版的MMCV
      • 最新版的MMCV,MMDetection不支持
  3. 安裝要求
    • Linux or macOS (Windows is in experimental support)
    • Python 3.6+
    • PyTorch 1.3+
    • CUDA 9.2+ (If you build PyTorch from source, CUDA 9.0 is also compatible)
    • GCC 5+
    • MMCV
    • MMDetection和MMCV對應(yīng)的版本要求如下

      • MMDetection_version MMCV_version master mmcv-full>=1.3.14, <1.4.0 2.18.0 mmcv-full>=1.3.14, <1.4.0 2.17.0 mmcv-full>=1.3.14, <1.4.0 2.16.0 mmcv-full>=1.3.8, <1.4.0 2.15.1 mmcv-full>=1.3.8, <1.4.0 2.15.0 mmcv-full>=1.3.8, <1.4.0 2.14.0 mmcv-full>=1.3.8, <1.4.0 2.13.0 mmcv-full>=1.3.3, <1.4.0 2.12.0 mmcv-full>=1.3.3, <1.4.0 2.11.0 mmcv-full>=1.2.4, <1.4.0 2.10.0 mmcv-full>=1.2.4, <1.4.0 2.9.0 mmcv-full>=1.2.4, <1.4.0 2.8.0 mmcv-full>=1.2.4, <1.4.0 2.7.0 mmcv-full>=1.1.5, <1.4.0 2.6.0 mmcv-full>=1.1.5, <1.4.0 2.5.0 mmcv-full>=1.1.5, <1.4.0 2.4.0 mmcv-full>=1.1.1, <1.4.0 2.3.0 mmcv-full==1.0.5 2.3.0rc0 mmcv-full>=1.0.2 2.2.1 mmcv==0.6.2 2.2.0 mmcv==0.6.2 2.1.0 mmcv>=0.5.9, =0.5.1,
  4. 準(zhǔn)備環(huán)境
    • conda create -n MMDetection python=3.7 -y
    • conda activate MMDetection
  5. 安裝PyTorch
    • MMDetection 是以PyTorch為底層框架的,所以需要首先安裝PyTorch才行
    • 這個自己直接就是安裝的最新的穩(wěn)定版,我感覺應(yīng)該會有很多特性支持
    • conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch
    • 如果conda走不通的話,可以考慮使用pip安裝
    • pip install torch==1.8.2+cu111 torchvision==0.9.2+cu111 torchaudio===0.8.2 -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html
  6. 安裝MMCV
  7. 安裝MMDetection
    • 一行代碼的事
    • pip install mmdet
  8. 安裝額外的依賴項
    • 這個其實安不安裝,對于一般問題而言區(qū)別不大,不過最好還是安裝上去,省心
    • # for instaboost pip install instaboostfast # for panoptic segmentation pip install git+https://github.com/cocodataset/panopticapi.git # for LVIS dataset pip install git+https://github.com/lvis-dataset/lvis-api.git # for albumentations pip install albumentations>=0.3.2 --no-binary imgaug,albumentations
  9. 驗證安裝
    • from mmdet.apis import init_detector, inference_detector config_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py' # download the checkpoint from model zoo and put it in `checkpoints/` # url: https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth checkpoint_file = 'checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth' device = 'cuda:0' # init a detector model = init_detector(config_file, checkpoint_file, device=device) # inference the demo image inference_detector(model, 'demo/demo.jpg')
    • 若是運行出下面的界面就可以了
  10. 報錯
    • ModuleNotFoundError: No module named 'mmcv._ext'
      • ModuleNotFoundError: No module named ‘mmcv._ext‘_一千零一夜的博客-CSDN博客
      • 使用whl安裝
        • 不過Win平臺的模塊比較少,而且Python都是1.6版本的
        • https://download.openmmlab.com/mmcv/dist/index.html
      • 不過需要注意的是,找到對應(yīng)的平臺版本,否則會報下面的問題
        • 這個就是自己安裝了Linux平臺的代碼報的錯誤
      • 簡單來說就是MMCV沒有安裝好,按照上面的教程步驟再走一遍吧。


?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容