pytorch环境下mmdection目标检测库安装所有步骤
商汤科技(2018 COCO 目标检测挑战赛冠军)和香港中文大学最近开源了一个基于Pytorch实现的深度学习目标检测工具箱mmdetection,支持Faster-RCNN,Mask-RCNN,Fast-RCNN等主流的目标检测框架,现在又加入Cascade-RCNN、SSD以及其他一系列目标检测框架。目前没有yolo的计划hhh。
相比于Facebook开源的Detectron框架,作者声称mmdetection有三点优势:performance稍高、训练速度稍快、所需显存稍小。
项目需要,这个项目开源的时间又比较短,相关教程比较少啦,就记录下自己踩的坑给别人铺路吧。
本人的系统环境:
Ubuntu 16.04
Cuda 9.0 + Cudnn 7.4.2
Python 3.5 (mmdetection要求Python版本需要3.4+)
Anaconda 3 (可选) 这里推荐大家使用Anaconda,可以比较方便的创建Python虚拟环境,避免不同的Python库之间产生冲突。
在安装mmdetection之前,需要安装以下几个依赖库:
PyTorch1.0.0 和 torchvision
Cython
mmcv
参考作者
作者:张正昊今天也要努力鸭
来源:CSDN
原文:https://blog.csdn.net/qq_36302589/article/details/85798060
版权声明:本文为博主原创文章,转载请附上博文链接!
本文离线下载pytorch 1.0.0 升级pip3下载 torchvision
其中的经历也很波折,下载pip3按理是
sudo apt install pip3
但是中间出现了问题,因此python2.7没有下载pip,在python3里用了如下方法
升级pip3
安装
Install mmdetection
- Install PyTorch 1.0 and torchvision following the official instructions.
检测pytorch,torchvision是否下载成功
import torch import torchvision
2.安装cython
pip install cython
3.安装mmcv
git clone https://github.com/open-mmlab/mmcv.git cd mmcv pip install .
4. Clone the mmdetection repository.
本文同过github手动下载
git clone https://github.com/open-mmlab/mmdetection.git
c. Compile cuda extensions.
cd mmdetection pip install cython # or "conda install cython" if you prefer conda ./compile.sh # or "PYTHON=python3 ./compile.sh" if you use system python3 without virtual environments
如果为python3,则在文档里改正python——python3
d. Install mmdetection (other dependencies will be installed automatically).
python(3) setup.py install # add --user if you want to install it locally # or "pip install ."
Note: You need to run the last step each time you pull updates from github.
The git commit id will be written to the version number and also saved in trained models.
到此,我们就完成了mmdetection及其依赖库的安装
7.测试demo
将下方的代码写入py文件,并存放到mmdetection文件夹目录下,然后运行。该代码的功能是检测图片中的目标,测试模型是官方给出的Faster-RCNN-fpn-resnet50的模型,运行代码会自动下载模型。由于模型是存储在亚马逊云服务器上,速度可能会稍慢。
import mmcv from mmcv.runner import load_checkpoint from mmdet.models import build_detector from mmdet.apis import inference_detector, show_result cfg = mmcv.Config.fromfile('configs/faster_rcnn_r50_fpn_1x.py') cfg.model.pretrained = None # 构建网络,载入模型 model = build_detector(cfg.model, test_cfg=cfg.test_cfg) _ = load_checkpoint(model, 'https://s3.ap-northeast-2.amazonaws.com/open-mmlab/mmdetection/models/faster_rcnn_r50_fpn_1x_20181010-3d1b3351.pth') # 测试一张图片 img = mmcv.imread('test.jpg') result = inference_detector(model, img, cfg) show_result(img, result)
- 基于ubuntu16.04下anaconda中tensorflow环境的目标检测API安装
- Linux搭建aspx.net环境之:CentOs 7 安装 Mono 和 Jexus 步骤记录
- Linux系统(Centos)下安装Java环境配置步骤详述
- hadoop环境安装步骤
- windows环境下安装nvm、node.js、npm步骤
- ubuntu18.04 深度学习GPU环境配置(步骤很简单,特别是tf的安装)
- 【开发环境】Source_Insight3.5安装步骤
- Linux下PHP环境安装具体步骤
- 语音识别工具kaldi在linux环境下的安装步骤
- ubuntun一些软件的安装,环境配置的基本步骤
- Linux下安装Java环境配置步骤详述
- 安装程序自动检测安装.Net Framework运行环境(使用InnoSetup)
- virtualbox安装centos6.4开发环境搭建步骤教程
- WAMP环境搭建步骤(含phpmyadmin程序安装)
- Java环境安装步骤快速入门简要
- 安装程序自动检测安装.Net Framework运行环境(使用InnoSetup)
- Linux下安装oracle 10g 时环境检测 DHCP错误的处理
- Windows环境下的NodeJS+NPM+Bower安装配置步骤
- 在CentOS6.4中安装配置LAMP环境的详细步骤
- linux环境下安装jdk详细步骤以及删除jdk详细步骤