IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> Python知识库 -> 目标检测库MMDetection的配置(MMDetection: Open MMLab Detection Toolbox and Benchmark) -> 正文阅读

[Python知识库]目标检测库MMDetection的配置(MMDetection: Open MMLab Detection Toolbox and Benchmark)

1、论文下载地址:

MMDetection: Open MMLab Detection Toolbox and Benchmark. [paper]?

2、代码下载地址:

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

3、创建虚拟环境并激活

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

4、安装pytorch和torchvision

pip install torch===1.4.0 -f https://download.pytorch.org/whl/torch_stable.html
?
pip install torchvision===0.5.0 -f https://download.pytorch.org/whl/torch_stable.html

5、安装mmcv-full

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

我的CUDA版本是10.0,torch版本是1.4.0,大家针对性更改。安装编译需要很长一段时间,耐心等待。

6、安装MMDetection

进入第2步骤下载的工程路径运行:

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

可能遇到错误:

No local packages or working download links found for panopticapi@ git+https://github.com/cocodataset/panopticapi.git
error: Could not find suitable distribution for Requirement.parse('panopticapi@ git+https://github.com/cocodataset/panopticapi.git')

错误原因:

服务器上网络问题,连不上github,所以git库包panopticapi失败。

解决方法:

1)手动下载panopticapi包

https://github.com/cocodataset/panopticapi

2)放到工程路径解压

3)手动编译

 python panopticapi/setup.py develop

?4)打开runtime.txt,删除第三行的?@ git+https://github.com.cnpmjs.org/cocodataset/panopticapi.git

?5)重新运行python setup.py develop,编译成功。

7、下载预训练模型

下载地址:

https://github.com/open-mmlab/mmdetection/blob/master/docs/model_zoo.md

以faster R-CNN为例

1)

?2)

3)新建checkpoints路径,将下载的模型放入

8、新建demo.py文件,输入以下代码

from mmdet.apis import init_detector, inference_detector, show_result_pyplot
import cv2

config_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
# download the checkpoint from model zoo and put it in `checkpoints/`
# url: https://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'
# init a detector
model = init_detector(config_file, checkpoint_file, device=device)
# inference the demo image

image='demo/demo.jpg'

result = inference_detector(model, image)

show_result_pyplot(model, image, result, score_thr=0.3)

# image = model.show_result(image, result, score_thr=0.3)
#
# cv2.imshow('demo', image)
# cv2.waitKey()

9、运行得到结果

python demo.py

  Python知识库 最新文章
Python中String模块
【Python】 14-CVS文件操作
python的panda库读写文件
使用Nordic的nrf52840实现蓝牙DFU过程
【Python学习记录】numpy数组用法整理
Python学习笔记
python字符串和列表
python如何从txt文件中解析出有效的数据
Python编程从入门到实践自学/3.1-3.2
python变量
上一篇文章      下一篇文章      查看所有文章
加:2021-08-04 11:09:46  更:2021-08-04 11:10:56 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/12 8:05:45-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码