Faster R-CNN在Window环境的目标检测
来源:互联网 发布:吾爱破解软件 编辑:程序博客网 时间:2024/04/27 18:59
Faster R-CNN在Linux环境下面的训练和检测相信很多感兴趣的人都可以根据下面
https://github.com/rbgirshick/py-faster-rcnn
获得python版本的环境搭建指导。
但是Faster R-CNN工作在Windows却很少看到有人能够成功搭建训练和检测环境。
本文,主要介绍使用Linux环境下自定义训练模型在Windows环境下Faster R-CNN的python版本的目标检测移植。
采用pascal_voc格式制作自己的数据集,模型使用中等网络模型,使用的端到端的训练方法,测试的使用CPU进行测试。
Faster R-CNN移植需要分两部分:
1、Faster R-CNN Caffe移植:
第一步:安装caffe的python依赖环境,可以依据faster rcnn caffe目录下面python的requirements.txt文件下载对应的python模块:
Cython>=0.19.2numpy>=1.7.1scipy>=0.13.2scikit-image>=0.9.3matplotlib>=1.3.1ipython>=3.0.0h5py>=2.2.0leveldb>=0.191networkx>=1.8.1nose>=1.3.0pandas>=0.12.0python-dateutil>=1.4,<2protobuf>=2.5.0python-gflags>=2.0pyyaml>=3.10Pillow>=2.3.0six>=1.1.0
也可以安装Anaconda 来更快速获得相应的科学计算工具库。由于该网站下载速度极慢,我采用 了python2.7的版本安装。
一般通过pip和wheel两种方式即可完成所有包的安装;
第二步:移植faster rcnn caffe,默认从https://github.com/rbgirshick/caffe-fast-rcnn/tree/faster-rcnn
下面的faster rcnn caffe本身不支持Windows的,需要基于该源码进行移植。
可以根据官方caffe-window版本进行对比移植。请使用VS2013工程进行编译。
官方caffe-window版本:https://github.com/BVLC/caffe/tree/windows
基本上移植难度很小。
第三步:生成pycaffe:
编译libcaffe,pycaffe。
检查Build\x64\Release\pycaffe\caffe目录下是否拷贝了pycaffe依赖库。若没有,则需要采用下面bat脚本生成:
进入当前caffe-windows\windows\scripts\\目录下执行下面命令:
ProtoCompile.cmd D:\\Faster_RCNN\\caffe-windows\\windows\\ D:\\Faster_RCNN\\caffe-windows\\windows\\scripts\\PythonPreBuild D:\\Faster_RCNN\\caffe-windows\\windows\\ D:\\Faster_RCNN\\caffe-windows\\windows\\scripts\\PythonPostBuild D:\\Faster_RCNN\\caffe-windows\\windows\\ D:\\Faster_RCNN\\caffe-windows\\Build\\x64\\Release\\
2、Faster R-CNN目标检测移植:
第一步:
#from nms.gpu_nms import gpu_nms
def nms(dets, thresh, force_cpu=True):
ext_modules = [ # unix _compile: obj, src, ext, cc_args, extra_postargs, pp_opts Extension( "utils.cython_bbox", sources=["utils\\bbox.pyx"], extra_compile_args={'gcc': []}, include_dirs = [numpy_include] ), Extension( "nms.cpu_nms", sources=["nms\\cpu_nms.pyx"], extra_compile_args={'gcc': []}, include_dirs = [numpy_include], )]
def compile(sources, output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None, depends=None): postfix=os.path.splitext(sources[0])[1] if postfix == '.cu': # use the cuda for .cu files #self.set_executable('compiler_so', CUDA['nvcc']) # use only a subset of the extra_postargs, which are 1-1 translated # from the extra_compile_args in the Extension class postargs = extra_postargs['nvcc'] else: postargs = extra_postargs['gcc'] return super(sources, output_dir, macros, include_dirs, debug, extra_preargs, postargs, depends)
cdef np.ndarray[np.int64_t, ndim=1] order = scores.argsort()[::-1]
第二步:修改demo
CLASSES = ('__background__', 'aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor')
CLASSES = ('__background__', 'flags')
NETS = {'vgg16': ('VGG16', 'vgg16_fast_rcnn_iter_40000.caffemodel'), 'vgg_cnn_m_1024': ('VGG_CNN_M_1024', 'vgg_cnn_m_1024_faster_rcnn_iter_40000.caffemodel'), 'zf': ('ZF', 'ZF_faster_rcnn_final.caffemodel')}
第三步:修改测试模型
In the train.prototxt and test.prototxt files that you're using,
you'll need to change num_output from 21 to 3 in the cls_score layer and from 84 to 12 in the bbox_pred layer.
You'll also need to change num_classes from 21 to 3 in the Python layer that provides data to the net (the very first layer).
在使用训练的模型测试的时候没有任何输出时就需要考虑Linux环境和Windows环境的差别了,此处我遇到过这种情况之一是由于模型加载不完整导致的该问题,具体修改可以参考如下:
http://blog.csdn.net/seasermy/article/details/51509571
修改内容:在io.cpp中增加windows的支持:
#ifdef _MSC_VER int fd = open(filename, O_RDONLY|O_BINARY);#else int fd = open(filename, O_RDONLY);#endif
- Faster R-CNN在Window环境的目标检测
- 目标检测:Faster R-CNN
- 目标检测--Faster R-CNN
- 基于深度学习的目标检测技术演进:R-CNN、Fast R-CNN、Faster R-CNN
- 基于深度学习的目标检测技术演进:R-CNN、Fast R-CNN、Faster R-CNN
- 基于深度学习的目标检测技术演进:R-CNN、Fast R-CNN、Faster R-CNN
- 基于深度学习的目标检测技术演进:R-CNN、Fast R-CNN、Faster R-CNN
- 基于深度学习的目标检测技术演进:R-CNN、Fast R-CNN、Faster R-CNN
- 基于深度学习的目标检测技术演进:R-CNN、Fast R-CNN、Faster R-CNN
- 基于深度学习的目标检测技术演进:R-CNN、Fast R-CNN、Faster R-CNN
- 基于深度学习的目标检测技术演进:R-CNN、Fast R-CNN、Faster R-CNN
- 基于深度学习的目标检测技术演进:R-CNN、Fast R-CNN、Faster R-CNN
- 基于深度学习的目标检测技术演进:R-CNN、Fast R-CNN、Faster R-CNN
- 基于深度学习的目标检测算法:Faster R-CNN
- 目标检测 Faster R-CNN 论文笔记
- 目标检测4 Faster R-CNN
- 1:基于深度学习的目标检测技术:RCNN、Fast R-CNN、Faster R-CNN
- 基于深度学习的目标检测技术演进:R-CNN、Fast R-CNN、Faster R-CNN【转】
- 3.保护模式8-页式存储(启动分页机制)
- 广播接收器
- 后大学时代(晚上溜达听好妹妹乐队不说再见有感)
- Macbook系统下python入门
- VS2015使用小技巧 用VS运行写好得到代码的时候,通过双击快速关闭控制台
- Faster R-CNN在Window环境的目标检测
- 【Qt开发】【VS开发】【Linux开发】OpenCV、Qt-MinGw、Qt-msvc、VS2010、VS2015、Ubuntu Linux、ARM Linux中几个特别容易混淆的内容
- preStateDemo
- dot 语法全介绍
- Redis系列(二)-Hredis客户端设计及开源
- [leetcode]59. Spiral Matrix II
- 拖拽+碰撞+重力下的运动damp.html
- Photoshop文字特效——带有积雪效果的玻璃质感文字
- Java代码获取classpath路径方法和资源文件的读取方法