win10安装mmdetection(GPU)

前提:

1.安装了CUDA,本人安装的CUDA10.0(PS:只要显卡驱动版本满足,CUDA10.0和CUDA10.1没有差别,可以通过nvidia-smi查看:)

2.安装了anaconda或者miniconda

进入正题:

0.环境准备

conda create -n mmdet python=3.6 -y#创建名为mmdet的环境
activete mmdet#创建好激活环境

conda install pytorch==1.7.0 torchvision==0.8.0 torchaudio==0.7.0 cudatoolkit=10.1 -c pytorch #安装pytorch1.7.0 不要安装1.7.1,因为没有对应的mmcv版本
#其中,安装cudatoolkit=10.1则可以认为是为环境配置CUDA10.1,只要显卡驱动版本满足条件

1.安装mmcv-full

'''
从该网站下载对应版本的mmcv:https://download.openmmlab.com/mmcv/dist/{cu_version}/{torch_version}/index.html
cu_version:CUDA版本号
torch_version:pytorch版本号
因此:https://download.openmmlab.com/mmcv/dist/cu101/torch1.7.0/index.html从下载mmcv_full-1.4.4-cp36-cp36m-win_amd64.whl
'''
git clone https://github.com/open-mmlab/mmcv.git
cd mmcv
pip install -r requirements.txt
pip install mmcv_full-1.4.4-cp36-cp36m-win_amd64.whl


2.安装mmdet

git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
pip install -r requirements/build.txt
pip install mmdet==2.22.0

3.验证

模型权重下载:http://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth

from mmdet.apis import init_detector, inference_detector,show_result_pyplot
import mmcv
import os


absP='D:/mmdetection'#模型路径
config_file = os.path.join(absP,'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py')
# 从 model zoo 下载 checkpoint 并放在 `checkpoints/` 文件下
# 网址为: 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 = 'faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
device = 'cuda:0'
# 初始化检测器
model = init_detector(config_file, checkpoint_file, device=device)
# 推理演示图像
img=os.path.join(absP,'demo/demo.jpg')
result=inference_detector(model, img)
outImg=model.show_result(
img,
result)
#outImg1=show_result_pyplot(model,img,result)
mmcv.imshow(outImg,'a')
print(result)

检测结果:

同分布数据检测良好

其他场景的数据则泛化性不足

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值