text-detection-ctpn 圖片文字識別 mac環境 cpu版安裝
阿新 • • 發佈:2018-12-10
1.git上下載原始碼
2.因為預設是gpu版本的,修改為不用gpu有幾個坑
把需要註釋的幾個地方註釋掉
然後修改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下的圖片進行標註