Install mmdetection

Time:2021-3-4

Mmdetection is a deep learning and object detection code base based on python. It contains fast RCNN, Yolo, SSD and other mainstream object detection algorithm codes and trained models. It is convenient for us to study the object detection algorithm. The installation steps of mmdetection are as follows:

1. Create a CONDA environment and activate it. It’s very simple. I won’t talk about it in detail;

2. Install Python:

conda install pytorch=1.6.0 torchvision torchaudio cudatoolkit=10.1 -c pytorch

Be sure to choose the appropriate Python version according to CUDA version. For example, CUDA version is 10.1, and you can choose 1.6.0. If CUDA version is 10.0 or below, you need to upgrade to at least 10.1, otherwise mmdetection will report an error when running;

3. Using git to download mmcv and mmdetection, you can download them from GitHub, but the speed is relatively slow. It is recommended to download them from gitee

git clone https://gitee.com/cubone/mmdetection.git
git clone https://gitee.com/cubone/mmcv.git

4. Install mmcv or mmcv full, where mmcv is the CPU version and mmcv full is the GPU version. Select the appropriate mmcv full version according to the Python and CUDA versions

pip install mmcv-full==1.1.5+torch1.6.0+cu101 -f https://download.openmmlab.com/mmcv/dist/index.html

5. Check whether the installation is successful and run the following demo code:

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')

If no error is reported, the installation is successful!