Skip to content

Commit

Permalink
add keras text detect / add tf angle detect /fit errors
Browse files Browse the repository at this point in the history
wenlihaoyu committed Dec 22, 2018
1 parent 716ce95 commit 78aa6df
Showing 443 changed files with 48,732 additions and 10,197 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
*.egg-info
*.pth
*.pb
*.h5
*.pbtxt
*.weights
dist
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
## 本项目基于[yolo3](https://github.com/pjreddie/darknet.git)[crnn](https://github.com/meijieru/crnn.pytorch.git) 实现中文自然场景文字检测及识别

# 实现功能
- [x] 文字方向检测 0、90、180、270度检测(支持dnn/tensorflow)
- [x] 支持(darknet/opencv dnn /keras)文字检测,暂时公布(keras版本训练)
- [x] 不定长OCR训练(英文、中英文) crnn\dense ocr
- [x]


## 环境部署
python=3.6 pytorch==0.4.1
``` Bash
git clone https://github.com/chineseocr/chineseocr.git
cd chineseocr
sh setup.sh #(cpu sh setpu-cpu.sh)
```
GPU部署 参考:setup.md
GPU部署 参考:setup-cpu.md

下载编译darknet(如果直接运用opencv dnn 可忽略darknet的编译)

### 下载编译darknet(如果直接运用opencv dnn或者keras yolo3 可忽略darknet的编译)
```
git clone https://github.com/pjreddie/darknet.git
mv darknet chineseocr/
@@ -19,6 +23,7 @@ mv darknet chineseocr/
#OPENMP=0
make
```

修改 darknet/python/darknet.py line 48
root = '/root/'##chineseocr所在目录
lib = CDLL(root+"chineseocr/darknet/libdarknet.so", RTLD_GLOBAL)
@@ -30,10 +35,7 @@ lib = CDLL(root+"chineseocr/darknet/libdarknet.so", RTLD_GLOBAL)
* [google drive](https://drive.google.com/drive/folders/1XiT1FLFvokAdwfE9WSUSS1PnZA34WBzy?usp=sharing)

复制文件夹中的所有文件到models目录

也可将yolo3模型转换为keras版本,详细参考https://github.com/qqwweee/keras-yolo3.git

或者直接运用opencv>=3.4 dnn模块调用darknet模型(参考 opencv_dnn_detect.py)。


## web服务启动
``` Bash
@@ -64,5 +66,5 @@ http://127.0.0.1:8080/ocr
2. crnn https://github.com/meijieru/crnn.pytorch.git
3. ctpn https://github.com/eragonruan/text-detection-ctpn
4. CTPN https://github.com/tianzhi0549/CTPN
5. https://github.com/qqwweee/keras-yolo3.git
5. keras yolo3 https://github.com/qqwweee/keras-yolo3.git

18 changes: 6 additions & 12 deletions app.py
Original file line number Diff line number Diff line change
@@ -7,14 +7,9 @@
import json
import time
import uuid
import numpy as np
import sys
import base64

import web

web.config.debug = True
from apphelper.image import convert_image,read_url_img,string_to_array,array_to_string,base64_to_array
import model
render = web.template.render('templates', base='base')
from config import DETECTANGLE
@@ -46,10 +41,10 @@ def POST(self):
timeTake = time.time()
_,result,angle= model.model(img,
detectAngle=DETECTANGLE,##是否进行文字方向检测
config=dict(MAX_HORIZONTAL_GAP=80,##字符之间的最大间隔,用于文本行的合并
MIN_V_OVERLAPS=0.6,
MIN_SIZE_SIM=0.6,
TEXT_PROPOSALS_MIN_SCORE=0.2,
config=dict(MAX_HORIZONTAL_GAP=100,##字符之间的最大间隔,用于文本行的合并
MIN_V_OVERLAPS=0.7,
MIN_SIZE_SIM=0.7,
TEXT_PROPOSALS_MIN_SCORE=0.1,
TEXT_PROPOSALS_NMS_THRESH=0.3,
TEXT_LINE_NMS_THRESH = 0.99,##文本行之间测iou值
MIN_RATIO=1.0,
@@ -60,7 +55,7 @@ def POST(self):
leftAdjust=True,##对检测的文本行进行向左延伸
rightAdjust=True,##对检测的文本行进行向右延伸
alph=0.2,##对检测的文本行进行向右、左延伸的倍数
ifadjustDegree=True
ifadjustDegree=False##是否先小角度调整文字倾斜角度
)

timeTake = time.time()-timeTake
@@ -73,8 +68,7 @@ def POST(self):



urls = ('/ocr','OCR',
)
urls = ('/ocr','OCR',)

if __name__ == "__main__":

Loading

0 comments on commit 78aa6df

Please sign in to comment.