1、进入mmdetection源码地址https://github.com/open-mmlab/mmdetection
2、按照文件中的get_started.md的步骤安装:
-
创建虚拟环境open-mmlab并激活
Create a conda virtual environment and activate it.conda create -n open-mmlab python=3.7 -y conda activate open-mmlab
-
安装PyTorch和torchvision
Install PyTorch and torchvision following the official instructions, e.g.,conda install pytorch torchvision -c pytorch
Note: Make sure that your compilation CUDA version and runtime CUDA version match.
You can check the supported CUDA version for precompiled packages on the PyTorch website.E.g.1
CUDA10.1,PyTorch1.5版本
If you have CUDA 10.1 installed under/usr/local/cuda
and would like to install
PyTorch 1.5, you need to install the prebuilt PyTorch with CUDA 10.1.conda install pytorch cudatoolkit=10.1 torchvision -c pytorch
E.g. 2
CUDA9.2,PyTorch1.3.1版本
If you have CUDA 9.2 installed under/usr/local/cuda
and would like to install
PyTorch 1.3.1., you need to install the prebuilt PyTorch with CUDA 9.2.conda install pytorch=1.3.1 cudatoolkit=9.2 torchvision=0.4.2 -c pytorch
If you build PyTorch from source instead of installing the prebuilt pacakge,
you can use more CUDA versions such as 9.0. -
安装mmcv-full,把
{cu_version}
and{torch_version}
替换为对应版本
Install mmcv-full, we recommend you to install the pre-build package as below.pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/{cu_version}/{torch_version}/index.html
Please replace
{cu_version}
and{torch_version}
in the url to your desired one. For example, to install the latestmmcv-full
withCUDA 11
andPyTorch 1.7.0
, use the following command:pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu110/torch1.7.0/index.html
See here for different versions of MMCV compatible to different PyTorch and CUDA versions.
Optionally you can choose to compile mmcv from source by the following command
下载github源码git clone https://github.com/open-mmlab/mmcv.git cd mmcv MMCV_WITH_OPS=1 pip install -e . # package mmcv-full will be installed after this step cd ..
Or directly run
pip install mmcv-full
-
Clone the MMDetection repository.
git clone https://github.com/open-mmlab/mmdetection.git cd mmdetection
-
安装requirements
Install build requirements and then install MMDetection.pip install -r requirements/build.txt pip install -v -e . # or "python setup.py develop"
6.快速开始,进入demo文件夹下的inference_demo.ipynb,安装所需模型的预训练模型,运行测试。