mmdetection的安装

文档链接:链接
install核心:保证cuda、pytorch、mmcv和mmdetection的版本互相一致

步骤:

1、查看cuda版本

nvcc -V

2、创建新的虚拟环境,准备pytorch

conda create -n open-mmlab python=3.7 -y
conda activate open-mmlab
# 安装对应cuda版本的pytorch
# https://pytorch.org/get-started/previous-versions/
# conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=9.2 -c pytorch建议不要选择版本过高的
conda install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cudatoolkit=9.2 -c pytorch
# 删除虚拟环境:conda remove -n your_env_name(虚拟环境名称) --all

3、根据环境安装mmcv

# 查看cuda,pytorch版本
nvcc -V
python -c 'import torch; print(torch.__version__)'

# 方法一:pip安装mmcv
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/{cu_version}/{torch_version}/index.html
# eg:pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu110/torch1.7.0/index.html

# 方法二:本地编译安装mmcv(不推荐用)
git clone https://github.com/op-mmlab/mmcv.git
cd mmcv
# package mmcv-full will be installen after this step
MMCV_WITH_OPS=1 pip install -e.

4、安装mmdetection

git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
pip install -r requirements/build.txt
pip install -v -e. # or "python setup.py decelop"

5、测试安装是否成功

# 方法一for test_rnv
wget https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth

#方法二:以下test_env.py.
from mmdet.apis import init_detector, inference_detector, show_result_pyplot
config_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
# download the checkpoint from model zoo and put it in 'checkpoint/'
# url:https://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
img = 'demo/demo.jpg'
result = inference_detector(model, img)
show_result_pyplot(model, img, result)
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值