我是靠谱客的博主 傻傻石头,最近开发中收集的这篇文章主要介绍安装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)

结果为: 

最后

以上就是傻傻石头为你收集整理的安装mmvc、mmdet并测试基本信息版本选择安装的全部内容,希望文章能够帮你解决安装mmvc、mmdet并测试基本信息版本选择安装所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(64)

评论列表共有 0 条评论

立即
投稿
返回
顶部