安装mmvc、mmdet并测试

目录

基本信息

服务器信息

版本选择

CUDA、Pytorch对应关系

mmvc、cuda、pytorch对应关系

MMDetection 和 MMCV 版本兼容性

安装

安装mmcv

安装 MMDetection


基本信息

服务器信息

(不知道为什么本地就是按不上)

镜像

PyTorch  1.8.1

Python  3.8

Cuda  11.1

GPU

RTX 3060 * 1

显存:12GB

CPU

7核 Intel(R) Xeon(R) CPU E5-2680 v4 @ 2.40GHz

内存:20GB

版本选择

CUDA、Pytorch对应关系

Previous PyTorch Versions | PyTorch

mmvc、cuda、pytorch对应关系

https://github.com/open-mmlab/mmcv#install-with-pip

 Previous PyTorch Versions | PyTorch

 本人选择cuda11.1+pytorch1.8(采用服务器可以选择不用安装)

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

MMDetection 和 MMCV 版本兼容性

mmdetection/get_started.md at master · open-mmlab/mmdetection · GitHub

**注意:**如果已经安装了 mmcv,首先需要使用 pip uninstall mmcv 卸载已安装的 mmcv,如果同时安装了 mmcv 和 mmcv-full,将会报 ModuleNotFoundError 错误。

安装

此时电脑应该已经具备

PyTorch  1.8.1

Python  3.8

Cuda  11.1

安装mmcv

 本人选择mmcv-full==1.4.0

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

安装 MMDetection

pip install mmdet

出现警告:
UserWarning: “ImageToTensor” pipeline is replaced by “DefaultFormatBundle” for batch inference. It is recommended to manually replace it in the test data pipeline in your config file. ‘data pipeline in your config file.’, UserWarning)
 

修改mmdetection/configs/_base_/datasets/coco_detection.py中的代码

官方文档:

1: Inference and train with existing models and standard datasets — MMDetection 2.25.1 documentation

# use ImageToTensor (deprecated)
pipelines = [
   dict(type='LoadImageFromFile'),
   dict(
       type='MultiScaleFlipAug',
       img_scale=(1333, 800),
       flip=False,
       transforms=[
           dict(type='Resize', keep_ratio=True),
           dict(type='RandomFlip'),
           dict(type='Normalize', mean=[0, 0, 0], std=[1, 1, 1]),
           dict(type='Pad', size_divisor=32),
           dict(type='ImageToTensor', keys=['img']),
           dict(type='Collect', keys=['img']),
       ])
   ]

# manually replace ImageToTensor to DefaultFormatBundle (recommended)
pipelines = [
   dict(type='LoadImageFromFile'),
   dict(
       type='MultiScaleFlipAug',
       img_scale=(1333, 800),
       flip=False,
       transforms=[
           dict(type='Resize', keep_ratio=True),
           dict(type='RandomFlip'),
           dict(type='Normalize', mean=[0, 0, 0], std=[1, 1, 1]),
           dict(type='Pad', size_divisor=32),
           dict(type='DefaultFormatBundle'),
           dict(type='Collect', keys=['img']),
       ])
   ]

验证展示:

需创建指定文档下载权重

from mmdet.apis import init_detector, inference_detector, show_result_pyplot
import mmcv
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'
# 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
img = 'demo/demo.jpg'
result = inference_detector(model, img)
# show the results
show_result_pyplot(model, img, result)

结果为: 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值