mmdetection安装测试 | 您所在的位置:网站首页 › MMDetection新手安装使用教程无限踩坑 › mmdetection安装测试 |
mmdetection安装与测试
**MMDetection 是一个基于 PyTorch 的目标检测开源工具箱。它是 OpenMMLab 项目的一部分,支持了众多主流的和最新的检测算法,例如 Faster R-CNN,Mask R-CNN,RetinaNet 等。 mmdetection网址 环境安装mmdetection提供了详细的快速入门指南。 1.首先创建一个虚拟环境,并激活 conda create -n open-mmlab python=3.7 -y #创建名为open-mmlab的虚拟环境,Python 3.6+ conda activate open-mmlab #激活环境2.安装pytorch,要确保安装对应CUDA版本的pytorch 查看CUDA版本,打开终端,输入下面命令: >>cat /usr/local/cuda/version.txt CUDA Version 10.1.105 #我的CUDA版本是10.1故安装pytorch命令如下:该命令安装PyTorch =1.5 conda install pytorch cudatoolkit=10.1 torchvision -c pytorch3.安装mmcv-full pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/{cu_version}/{torch_version}/index.html{cu_version}/{torch_version}为对应的CUDA版本和Pytorch版本,如我的cuda=10.1,pytorch=1.5.0,命令如下: pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.5.0/index.html4.克隆MMDetection存储库 git clone https://github.com/open-mmlab/mmdetection.git cd mmdetection5.安装mmdetection要求的包 mmdetection将需要安装的其他工具包写进了requirements/build.txt pip install -r requirements/build.txt pip install -v -e . # or "python setup.py develop"到这里mmdetection就安装完成了,下面进行进一步的测试检验。 测试验证在demo文件夹下提供了测试图片和视频的.py文件。 1.首先在克隆到本地的mmdetection文件下新建checkpoints文件夹,用来存放训练好的模型。 2.下载训练好的模型。本文使用faster_rcnn模型,faster_rcnn模型下载其他模型下载如,yolo、mask_rcnn等,可在官方网站上已支持的算法中找到。将下载的模型放在checkpoints文件夹下。 3.测试图片。使用demo文件夹下的image_demo.py测试图片。在mmdetection目录下打开终端,进入安装好的open-mmlab虚拟环境下,输入一下命令 conda activate open-mmlab # 进入open-mmlab虚拟环境 python demo/image_demo.py demo/demo.jpg \ configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py \ checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth \ --device cpu如需使用其他模型,需要更改对应模型的 configs/ 和checkpoints/。mmdetection官网也提供了测试video的代码。 python demo/video_demo.py demo/demo.mp4 \ configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py \ checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth \ --out result.mp4到这里mmdetection环境以及安装测试完成。 4.使用标准数据集测试模型。 **在mmdetection目录下新建data目录,并将下载的PASCAL VOC数据集放在data目录下。在mmdetection目录下打开终端,进入安装的open-mmlab虚拟环境,输入一下命令。执行下面代码后在faster_rcnn_results文件夹下生成相应的测试数据文件。 python tools/test.py \ configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py \ checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth \ --show-dir faster_rcnn_results |
今日新闻 |
推荐新闻 |
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 |