关于CTPN论文实现cpu版本的编译问题

《Detecting Text in Natural Image with Connectionist Text Proposal Network》,发表在ECCV2016,算是一个使用比较多效果较好的较为经典的一个文字检查算法了。

本人目前也在阅读该论文tensorflow版本的代码,该代码的仓库名称为ext-detection-ctpn,github下载地址:https://github.com/eragonruan/text-detection-ctpn.git

作者本人喜欢在本地调试服务器端训练,本机是mac没有gpu,所以只能跑cpu版本,下面分享一下跑通cpu版本的流程。

  1. git clone https://github.com/eragonruan/text-detection-ctpn.git ,将代码下载到本地

  2. 将./ctpn/text.yml文件中的USE_GPU_NMS置为False

  3. 将./lib/fast_rcnn/nms_wrapper.py文件中的from lib.utils.gpu_nms import gpu_nms注释掉

  4. 利用./lib/utils/setup.py文件编译出cython_nms.so,方法如下:
    a). 修改setup.py文件,将原来的所有代码改为下面代码
    b). cd ./lib/utils
    c). 运行python setup.py build

from Cython.Build import cythonize
import numpy as np
from distutils.core import setup
from distutils.extension import Extension

try:
    numpy_include = np.get_include()
except AttributeError:
    numpy_include = np.get_numpy_include()

ext_modules = [
    Extension(
        'bbox',
        sources=['bbox.c'],
        include_dirs = [numpy_include]
    ),
    Extension(
        'cython_nms',
        sources=['cython_nms.c'],
        include_dirs = [numpy_include]
    )
]
setup(
    ext_modules=ext_modules
)
  1. 上述步骤会输出so在目录./lib/utils/build下,将里面所有的so都拷到./lib/utils/目录下

  2. 下载训练好的模型,地址:https://github.com/eragonruan/text-detection-ctpn/releases ,将下载好的checkpoints文件夹拷到cptn文件夹里,运行python demo.py查看是否能跑通。

注意:笔者本地用的是pycharm进行调试代码,tensorflow的安装参考tensorflow mac和Linux上的简便安装,上述过程中如果提示确实什么安装包直接使用tensorflow环境里的pip安装即可,遇到问题欢迎留言

参考
[1] https://github.com/eragonruan/text-detection-ctpn
[2] https://github.com/eragonruan/text-detection-ctpn/issues/43
[3] https://github.com/eragonruan/text-detection-ctpn/releases

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值