发布于2019-08-07 12:38 阅读(808) 评论(0) 点赞(1) 收藏(3)
因为github上开源的代码都是两三年前的,所以我们复现起来会遇到各种各样奇怪的问题。
在我查阅了很多的CSDN博客和github上的问题后终于解决了问题
代码实现过程如下(我是按照我自己遇到的问题来写的,仅供参考)
https://github.com/endernewton/tf-faster-rcnn
在集群(centos)上用anaconda配置的环境,
所需要的环境有:python2.7,tensorflow-gup=1.6,cython,opencv-python, matplotlib,easydict=1.6,cuda, cudnn(注意这个是7.1.2版本的)此处不仔细讲了,github上和其他博客上讲的很详细。
http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtrainval_06-Nov-2007.tar
http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtest_06-Nov-2007.tar
http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCdevkit_08-Jun-2007.tar
解压后直接把VOCdevkit文件夹拷贝到tf-fater-rcnn/data路径下,并重命名为VOCdevkit2007
预训练的模型:https://pan.baidu.com/s/1F8VfDKjlq9x42ZDrrvfx2A 密码:8ahl
COCOAPI:https://github.com/cocodataset/cocoapi
最后把VOCdevkit、coco、voc_2007_trainval+voc_2012_trainval都放在data文件夹下
简述我更改的地方,以供大家参考:
1.tf-faster-rcnn-master\lib\setup.py
# 注释掉这几段代码
# CUDA = locate_cuda()
# self.set_executable('compiler_so', CUDA['nvcc'])
# 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']]
# )
2.tf-faster-rcnn-master\lib\model\config.py
# 把原来的True改为False
# Use GPU implementation of non-maximum suppression
__C.USE_GPU_NMS = False
3.tf-faster-rcnn-master\lib\model\nms_wrapper.py
# 注释掉这段代码
# from nms.gpu_nms import gpu_nms
4.tf-faster-rcnn-master\tools\demo.py
# 添加这几段代码(注意import matplotlib.pyplot as plt要放到最后)
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
# 把最后的 plt.show()注释掉改为plt.savefig
plt.savefig("pic.png")
# plt.show()
5.cudnn的版本不匹配问题:
参考:https://blog.csdn.net/htt789/article/details/79627015
最后运行:
GPU_ID=0
CUDA_VISIBLE_DEVICES=${GPU_ID} python ./tools/demo.py
在tf-faster-rcnn-master的目录下就可以看到pic.png图片
作者:爸爸去挣钱我去幼儿园
链接:https://www.pythonheidong.com/blog/article/10897/994184ded822c9b64244/
来源:python黑洞网
任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任
昵称:
评论内容:(最多支持255个字符)
---无人问津也好,技不如人也罢,你都要试着安静下来,去做自己该做的事,而不是让内心的烦躁、焦虑,坏掉你本来就不多的热情和定力
Copyright © 2018-2021 python黑洞网 All Rights Reserved 版权所有,并保留所有权利。 京ICP备18063182号-1
投诉与举报,广告合作请联系vgs_info@163.com或QQ3083709327
免责声明:网站文章均由用户上传,仅供读者学习交流使用,禁止用做商业用途。若文章涉及色情,反动,侵权等违法信息,请向我们举报,一经核实我们会立即删除!