在centos 服务器上安装并完成了mmdetection的demo演示。
mmdetection是香港中文大学-商汤联合实验室开源的基于 PyTorch 的检测库。
商汤称,这个开源库提供了已公开发表的多种视觉检测核心模块。通过这些模块的组合,可以迅速搭建出各种著名的检测框架,比如 Faster RCNN,Mask RCNN,和 R-FCN 等,以及各种新型框架,从而大大加快检测技术研究的效率。
我主要是想实验最近SOTA的HTC实例分割模型。。。
按照INSTALL.md执行安装流程。
We have tested the following versions of OS and softwares:
1. 升级gcc
编译mmdetection需要gcc 4.9以上的版本(需要支持c++11),但是Centos 6默认的gcc版本为4.4,可以先到这里下载gcc安装包,这里我下载的是6.4.0,能用。
# 解压
tar zxvf gcc-6.4.0.tar.gz
cd gcc-6.4.0
#下载gmp mpfr mpc 很慢
./contrib/download_prerequisites
# 执行配置
./configure --prefix=/usr/local/gcc --enable-bootstrap --enable-checking=release --enable-languages=c,c++ --disable-multilib
# 编译,根据CPU核数调整N
make -j N
# 安装
make install
安装完就可以在/usr/local/gcc
目录下看到一些库文件了。接下来配置环境变量
#查看当前gcc版本
gcc -v
# 将gcc6.4导入环境
echo -e '\nexport PATH=/usr/local/gcc/bin:$PATH\n' >> /etc/profile.d/gcc.sh && source /etc/profile.d/gcc.sh
#导出头文件
ln -sv /usr/local/gcc/include/ /usr/include/gcc
#导出库文件
vim /etc/ld.so.conf.d/gcc.conf
# 64位系统,在打开的文件中加入下面的内容
/usr/local/gcc/lib64
#配置生效
ldconfig -v
#导出验证
ldconfig -p |grep gcc
再次使用gcc --version
应该就可以看到gcc版本已经更新了。
可以使用下面的小程序进行验证
/*
* test.cpp
*/
#include
#include
using namespace std;
int main()
{
shared_ptr<int> p = make_shared<int>(42);
cout<<"p = "<<*p<<endl;
return 0;
}
编译
g++ -std=c++11 -o lol test.cpp
执行./lol
可以看到打印出值p=42即可。
2. 安装mmdetection
a. 创建conda虚拟环境并激活,然后安装cpython
conda create -n open-mmlab python=3.7 -y
conda activate open-mmlab
conda install cython
b. 按照 官方教程安装pytorch(>=1.0)
c. 克隆mmdetection仓库
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
d. 编译cuda
./compile.sh
e. 安装mmdetection (其他依赖将自动安装).
python setup.py develop
# or "pip install -e ."
不出意外那就是安装好了,接下来可以测试一些功能。
根据GETTING_STARTED使用预训练的模型进行推理测试。
这里先从MODEL_ZOO下载一个目标检测模型,我下载的是Faster RNN模型faster_rcnn_r50_fpn_1x_20181010-3d1b3351.pth ,放到根目录下的checkpoints目录下。
R-50-FPN | pytorch | 1x | 3.8 | 0.353 | 13.6 | 36.4 | model |
---|
我是这样测试的
from mmdet.apis import init_detector, inference_detector, show_result
config_file = 'configs/faster_rcnn_r50_fpn_1x.py'
checkpoint_file = 'checkpoints/faster_rcnn_r50_fpn_1x_20181010-3d1b3351.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 and show the results
img = 'test.jpg' # or img = mmcv.imread(img), which will only load it once
output = 'output.png'
result = inference_detector(model, img)
show_result(img, result, model.CLASSES,, score_thr=0.8, out_file=output)
这个教程里也提供了其他的测试方法,以及训练流程,自行查看。
待完成…
love SenceTime 6 times
c++
1. 结构体怎么动态增长
2. 介绍几种cast方法
3. 介绍一下线程池
4. 怎么让函数能够接受不固定参数
5. 基类A的派生类B,怎么让B类的函数不可继承
6. class Base. Base A, Base B, A=B,重载=
Python
7. 怎么快速初始化列表
8. 什么时候=是赋值,什么时候是引用