mmdetection2.6的安装

mmdetection的安装

mmdetection的github链接://github.com/open-mmlab/mmdetection
mmdetection的官方文档://mmdetection.readthedocs.io/en/latest/

1. mmdetection的安装

  1. 创建conda环境
conda create -n mmdetection python=3.7 -y
source activate mmdetection
  1. 安装pytorch及torchvision
conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.2 -c pytorch
#也可以上官网选择特定的版本
# //pytorch.org/ 
  1. 安装mmcv
    可以在这个网址//github.com/open-mmlab/mmcv#install-with-pip, 查找自己的环境所需的mmcv包。
pip install mmcv-full==latest+torch1.6.0+cu102 -f //download.openmmlab.com/mmcv/dist/index.html

  1. clone mmdetection的代码库
git clone //github.com/open-mmlab/mmdetection.git
cd mmdetection培养桃红
  1. 安装mmdetection
pip install -r requirements/build.txt
pip install -v -e . # 这里有个点不能忘了

这里采用pip install -v -e .安装的是最小运行依赖, 如果想要使用可选择的依赖,例如albumentations imagecorruptions可以直接运行下边的代码

pip install -v -e .[optional]

2. 验证mmdetection是否安装成功

demo文件夹下创建demo.py,输入以下的内容:

from mmdet.apis import init_detector, inference_detector

config_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
device = 'cuda:0'
# init a detector
model = init_detector(config_file, device=device)
# inference the demo image
inference_detector(model, 'demo/demo.jpg')

然后运行:

python demo/demo.py