目标检测之Faster R-CNN ---- TensorFlow(CPU)

论文地址:Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks

项目地址:Faster_R-CNN_TensorFlow

硬件平台:

Ubuntu 18.04(VMware)

Python 3.6

TensorFlow 1.x

原始代码链接:tf-faster-rcnn

参数修改过程如下:

1、config.py文件修改:

# Use GPU implementation of non-maximum suppression
__C.USE_GPU_NMS = False

2、nms_wrapper.py文件修改:(注释掉gpu_nms)

#from nms.gpu_nms import gpu_nms
  #if cfg.USE_GPU_NMS and not force_cpu:
    #return gpu_nms(dets, thresh, device_id=0)

3、setup.py (注释掉GPU/CUDA部分)

#CUDA = locate_cuda()
...
def _compile(obj, src, ext, cc_args, extra_postargs, pp_opts):
        print(extra_postargs)
        if os.path.splitext(src)[1] == '.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']
...
#Extension('nms.gpu_nms',
    #    ['nms/nms_kernel.cu', 'nms/gpu_nms.pyx'],
    #    library_dirs=[CUDA['lib64']],
    #    libraries=['cudart'],
    #    language='c++',
    #    runtime_library_dirs=[CUDA['lib64']],
    #    # this syntax is specific to this build system
    #    # we're only going to use certain compiler args with nvcc and not with gcc
    #    # the implementation of this trick is in customize_compiler() below
    #    extra_compile_args={'gcc': ["-Wno-unused-function"],
    #                        'nvcc': ['-arch=sm_52',
    #                                 '--ptxas-options=-v',
    #                                 '-c',
    #                                 '--compiler-options',
    #                                 "'-fPIC'"]},
    #    include_dirs = [numpy_include, CUDA['include']]
    #)

4、进入lib/Makefile 执行

make

5、data目录下创建coco文件件

cd data
git clone https://github.com/pdollar/coco.git
cd coco/PythonAPI
make

6、下载预训练模型 voc_0712_80k-110k.tgz 百度网盘下载 提取码: 6dz8

NET=res101
TRAIN_IMDB=voc_2007_trainval+voc_2012_trainval
mkdir -p output/${NET}/${TRAIN_IMDB}
cd output/${NET}/${TRAIN_IMDB}
ln -s ../../../voc_2007_trainval+voc_2012_trainval ./default

7、运行demo.py:在data文件下运行:

python3 ../tools/demo.py

8、实验结果:

可以看到,没有GPU加速,识别速度至少在32s以上,识别效果见下图:

 

 

 practice makes perfect!

参考博客:

Faster R-CNN tensorflow版本,cpu下运行demo

如何运行Faster RCNN的tensorflow代码

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值