README.md 2.2 KB
Newer Older
L
lywen 已提交
1 2 3
## 本项目基于[yolo3](https://github.com/pjreddie/darknet.git) 与[crnn](https://github.com/meijieru/crnn.pytorch.git)  实现中文自然场景文字检测及识别

## 环境部署
L
lywen 已提交
4
python=3.6 pytorch==0.4.1
L
lywen 已提交
5 6 7
``` Bash
git clone https://github.com/chineseocr/chineseocr.git
cd chineseocr
L
lywen 已提交
8
sh setup.sh #(cpu sh setpu-cpu.sh)
L
lywen 已提交
9 10
```

L
lywen 已提交
11 12 13 14 15 16 17 18 19 20 21
下载编译darknet(如果直接运用opencv dnn 可忽略darknet的编译)
```
git clone https://github.com/pjreddie/darknet.git 
mv darknet chineseocr/
##编译对GPU、cudnn的支持 修改 Makefile
#GPU=1
#CUDNN=1
#OPENCV=0
#OPENMP=0
make 
```
22 23 24
修改 darknet/python/darknet.py line 48    
root = '/root/'##chineseocr所在目录     
lib = CDLL(root+"chineseocr/darknet/libdarknet.so", RTLD_GLOBAL)    
L
lywen 已提交
25 26


L
lywen 已提交
27
## 下载模型文件   
L
Lu Cao 已提交
28
模型文件地址:
L
lywen 已提交
29
* [baidu pan](https://pan.baidu.com/s/1gTW9gwJR6hlwTuyB6nCkzQ)
L
lu_cao 已提交
30
* [google drive](https://drive.google.com/drive/folders/1XiT1FLFvokAdwfE9WSUSS1PnZA34WBzy?usp=sharing)
L
lywen 已提交
31

L
lywen 已提交
32
复制文件夹中的所有文件到models目录
L
Lu Cao 已提交
33

L
lywen 已提交
34
也可将yolo3模型转换为keras版本,详细参考https://github.com/qqwweee/keras-yolo3.git    
35

L
lywen 已提交
36
或者直接运用opencv>=3.4  dnn模块调用darknet模型(参考 opencv_dnn_detect.py)。   
L
lywen 已提交
37

L
Lu Cao 已提交
38
## web服务启动
L
lywen 已提交
39 40 41 42 43 44
``` Bash
cd chineseocr## 进入chineseocr目录
ipython app.py 8080 ##8080端口号,可以设置任意端口
```

## 识别结果展示
L
lywen 已提交
45 46 47

<img width="500" height="300" src="https://github.com/chineseocr/chineseocr/blob/master/test/img1.png"/>
<img width="500" height="300" src="https://github.com/chineseocr/chineseocr/blob/master/test/4.png"/>
L
lywen 已提交
48
<img width="500" height="300" src="https://github.com/chineseocr/chineseocr/blob/master/test/card1.png"/>
L
lywen 已提交
49

L
Lu Cao 已提交
50 51 52 53 54 55
## Play with Docker Container
``` Bash
docker pull zergmk2/chineseocr
docker run -d -p 8080:8080 zergmk2/chineseocr
```

L
lywen 已提交
56 57 58
## 访问服务
http://127.0.0.1:8080/ocr

L
lywen 已提交
59
<img width="500" height="300" src="https://github.com/chineseocr/chineseocr/blob/master/test/demo.png"/>
L
lywen 已提交
60 61 62 63 64 65


## 参考
1. yolo3 https://github.com/pjreddie/darknet.git   
2. crnn  https://github.com/meijieru/crnn.pytorch.git              
3. ctpn  https://github.com/eragonruan/text-detection-ctpn    
66 67
4. CTPN  https://github.com/tianzhi0549/CTPN       
5. https://github.com/qqwweee/keras-yolo3.git 
L
lywen 已提交
68