Requirements
Linux (Windows is not officially supported)
Python 3.5+ (Python 2 is not supported)
PyTorch 1.1 or higher
CUDA 9.0 or higher
NCCL 2
GCC(G++) 4.9 or higher
mmcv
我们已经测试了以下版本的操作系统和软件:
OS: Ubuntu 16.04/18.04 and CentOS 7.2
CUDA: 9.0/9.2/10.0
NCCL: 2.1.15/2.2.13/2.3.7/2.4.2
GCC(G++): 4.9/5.3/5.4/7.3
重点说一下mmcv的安装
https://github.com/open-mmlab/mmcv/
我成功的是这个方法:
https://github.com/open-mmlab/mmcv/blob/master/README.md
我的版本是torch1.4+cuda10,我们不选择指定版本,默认安装最新的,所以:
Install mmdetection
a. Create a conda virtual environment and activate it.
conda create -n open-mmlab python=3.7 -y
conda activate open-mmlab
b. Install PyTorch stable or nightly and torchvision following the official instructions, e.g.,
conda install pytorch torchvision -c pytorch
c. Clone the mmdetection repository.
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
d. Install mmdetection (other dependencies will be installed automatically).
python setup.py develop
# or "pip install -v -e ."
注意:
- git commit id将在步骤d中写入版本号,例如0.6.0 +2e7045c。该版本还将保存在经过训练的模型中。建议您每次从github提取一些更新时都运行步骤d。如果修改了C ++ / CUDA代码,则此步骤为强制性的。
- 按照上述说明,mmdetection将安装在dev模式下,对代码进行的任何本地修改都将生效,而无需重新安装它(除非您提交了一些提交并希望更新版本号)。
- 如果要使用opencv-python-headless而不是opencv-python,可以在安装MMCV之前先安装它。
准备数据集
建议将数据集根符号链接到$ MMDETECTION / data
。 如果您的文件夹结构不同,则可能需要更改配置文件中的相应路径。
mmdetection
├── mmdet
├── tools
├── configs
├── data
│ ├── coco
│ │ ├── annotations
│ │ ├── train2017
│ │ ├── val2017
│ │ ├── test2017
│ ├── cityscapes
│ │ ├── annotations
│ │ ├── train
│ │ ├── val
│ ├── VOCdevkit
│ │ ├── VOC2007
│ │ ├── VOC2012
必须使用城市景观脚本工具箱将城市景观注释转换为COCO格式。我们计划提供一个易于使用的转换脚本。目前,我们建议您遵循maskrcnn-benchmark工具箱中提供的说明。使用此脚本时,所有图像都必须移到同一文件夹中。在linux系统上,例如,可以使用以下方法对训练图像进行处理:
cd data/cityscapes/
mv train/*/* train/
这是一个使用conda设置mmdetection的脚本。
使用多个MMDetection版本
如果您的机器上有多个mmdetection,并且您想交替使用它们,则建议的方法是创建多个conda环境并对不同版本使用不同的环境。
另一种方法是将以下代码插入主脚本(train.py,test.py或您运行的任何其他脚本)
import os.path as osp
import sys
sys.path.insert(0, osp.join(osp.dirname(osp.abspath(__file__)), '../'))
或在相应文件夹的终端中运行以下命令。
export PYTHONPATH=`pwd`:$PYTHONPATH