基于yolo3 与crnn 实现中文自然场景文字检测及识别
基于yolo3 与crnn 实现中文自然场景文字检测及识别
github地址:基于yolo3 与crnn 实现中文自然场景文字检测及识别
实现功能:
- 文字方向检测 0、90、180、270度检测(支持dnn/tensorflow)
- 支持(darknet/opencv dnn /keras)文字检测,暂时公布(keras版本训练)
- 不定长OCR训练(英文、中英文) crnn\dense ocr
环境部署:
GPU部署:参考setup.md
GPU环境部署:
conda create -n chineseocr python=3.6 pip scipy numpy jupyter ipython ##运用conda 创建python环境
source activate chineseocr
git submodule init && git submodule update
pip install easydict opencv-contrib-python==3.4.2.16 Cython h5py lmdb mahotas pandas requests bs4 matplotlib lxml -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip install -U pillow -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip install keras==2.1.5 tensorflow==1.8 tensorflow-gpu==1.8
pip install web.py==0.40.dev0
conda install pytorch torchvision -c pytorch
pip install torch torchvision
pushd text/detector/utils && sh make.sh && popd
CPU环境部署:
##CPU 环境配置,支持linux\macOs conda create -n chineseocr python=3.6 pip scipy numpy jupyter ipython ##运用conda 创建python环境 source activate chineseocr git submodule init && git submodule update cd darknet/ && make && cd .. pip install easydict opencv-contrib-python==3.4.2.16 Cython h5py lmdb mahotas pandas requests bs4 matplotlib lxml -i https://pypi.tuna.tsinghua.edu.cn/simple/ pip install -U pillow -i https://pypi.tuna.tsinghua.edu.cn/simple/ pip install web.py==0.40.dev0 pip install keras==2.1.5 tensorflow==1.8
mac
conda install pytorch torchvision -c pytorch
linux
conda install pytorch-cpu torchvision-cpu -c pytorch
pushd text/detector/utils && sh make-for-cpu.sh && popd
下载编译darknet(如果直接运用opencv dnn或者keras yolo3 可忽略darknet的编译)
git clone https://github.com/pjreddie/darknet.git
mv darknet chineseocr/
##编译对GPU、cudnn的支持 修改 Makefile
#GPU=1
#CUDNN=1
#OPENCV=0
#OPENMP=0
make
修改 darknet/python/darknet.py line 48
root = '/root/'##chineseocr所在目录
lib = CDLL(root+"chineseocr/darknet/libdarknet.so", RTLD_GLOBAL)
下载训练模型:
复制文件夹中的所有文件到models目录
web服务启动
cd chineseocr## 进入chineseocr目录 ipython app.py 8080 ##8080端口号,可以设置任意端口
识别结果展示
Play with Docker Container
docker pull zergmk2/chineseocr docker run -d -p 8080:8080 zergmk2/chineseocr
访问服务
参考
- yolo3 https://github.com/pjreddie/darknet.git
- crnn https://github.com/meijieru/crnn.pytorch.git
- ctpn https://github.com/eragonruan/text-detection-ctpn
- CTPN https://github.com/tianzhi0549/CTPN
- keras yolo3 https://github.com/qqwweee/keras-yolo3.git