ubuntu18.04,pytorch1.8.0,cuda111安装mmdetection步骤

ubuntu18.04,pytorch1.8.0,cuda111安装mmdetection步骤

1、创建虚拟环境

conda create -n openmmlab python=3.7 -y
conda activate openmmlab

2、安装pytorch,需要安装与显卡相适应的版本
这里以3080为例

conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=11.1 -c pytorch -c conda-forge

注意:pytorch版本不要太新,否则和后面mmcv版本不匹配

3、安装mmcv-full
https://github.com/open-mmlab/mmcv#install-with-pip其他版本参考官网

pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.8.0/index.html

有cuda的建议安装mmcv-full,千万不能mmcv和mmcv-full同时安装

4、安装MMDetection
从官网上下载https://github.com/open-mmlab/mmdetection

cd mmdetection
pip install -r requirements/build.txt
python setup.py develop

5、测试

from mmdet.apis import init_detector, inference_detector
import mmcv

# Specify the path to model config and checkpoint file
config_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
checkpoint_file = 'checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'

# build the model from a config file and a checkpoint file
model = init_detector(config_file, checkpoint_file, device='cuda:0')

# test a single image and show the results
img = 'test.jpg'  # or img = mmcv.imread(img), which will only load it once
result = inference_detector(model, img)
# visualize the results in a new window
model.show_result(img, result)
# or save the visualization results to image files
model.show_result(img, result, out_file='result.jpg')

其中checkpoint_file文件下载地址
https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth

6、测试结果
在这里插入图片描述

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值