文章目录[隐藏]
安装
-
Create a conda virtual environment and activate it.
conda create -n open-mmlab python=3.7 -y conda activate open-mmlab
-
Install PyTorch and torchvision following the official instructions, e.g.,
这里建议加上 -c 减少因安装源的问题导致的错误
conda install pytorch cudatoolkit=11.0 torchvision -c pytorch
-
Install mmcv-full, we recommend you to install the pre-build package as below.
git clone https://github.com/open-mmlab/mmcv.git cd mmcv MMCV_CUDA_ARGS='-gencode=arch=compute_80,code=sm_80' MMCV_WITH_OPS=1 pip install . cd ..
第三步和官方教程略有不同,为了解决算力的问题 for RTX30系列
-
Clone the MMDetection repository.
git clone https://github.com/open-mmlab/mmdetection.git cd mmdetection
-
Install build requirements and then install MMDetection.
pip install -r requirements/build.txt pip install -v -e . # or "python setup.py develop"
验证代码: 如果跑通证明mmdet 安装成功
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: http://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')
官方还提供了mmdet的docker版本,docker是非常好用的工具,建议使用docker进行配置 会减少大量的环境配置时间, 具体使用方法可以去百度上搜
docker search mmdetection
版权声明:本文为CSDN博主「JianqiuChen」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/JianqiuChen/article/details/115118169
暂无评论