1.git上下載源碼
2.因爲默認是gpu版本的,修改爲不用gpu有幾個坑
先參考 https://github.com/eragonruan/text-detection-ctpn/issues/43
把需要註釋的幾個地方註釋掉
然後修改setup.py, 用下面這段代碼整個替換掉
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
)
運行:
python setup.py build_ext --include-dirs=/anaconda2/envs/chinese-ocr/lib/python2.7/site-packages/numpy/core/include
include-dirs 換成自己的numpy地址,將build完之後的.so文件copy到utils文件夾下
運行demo需要下載 https://github.com/eragonruan/text-detection-ctpn/releases checkpoint文件,就是用已經訓練好的模型,解壓 到text-detection-ctpn的主目錄,然後到主目錄運行python ./ctpn/demo.py,即可將demo下的圖片進行標註