avatar

【环境配置】:mmdetection安装

MMdetection安装

https://mmdetection.readthedocs.io/zh_CN/latest/

https://github.com/open-mmlab/mmdetection

1、创建虚拟环境

2、激活虚拟环境

1
conda activate open-mmlab

3、安装cython

4、基于Pytorch官网安装 PyTorch 和 torchvision

5、根据cuda与torch版本安装mmcv

6、安装mmdet

7、各包版本

8、测试

在demo文件夹下新建test.py文件

1
2
3
4
5
6
7
8
9
10
11
from mmdet.apis import init_detector, inference_detector

config_file = '../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 = '../checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
device = 'cuda:0'
# 初始化检测器
model = init_detector(config_file, checkpoint_file, device=device)
# 推理演示图像
inference_detector(model, 'demo.jpg')

出现报错

打开configs/base/models

打开faster_rcnn_r50_fpn.py

如上修改后运行成功

文章作者: 折花入酒
文章链接: https://nortona.github.io/2022/03/23/%E3%80%90%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE%E3%80%91%EF%BC%9Ammdetection%E5%AE%89%E8%A3%85/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 折花入酒blog