Skip to content

Commit

Permalink
更新样例图像和Readme说明
Browse files Browse the repository at this point in the history
  • Loading branch information
mick.yi committed Mar 24, 2019
1 parent 713e936 commit 95cb60e
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 12 deletions.
71 changes: 59 additions & 12 deletions README.md
Expand Up @@ -5,8 +5,15 @@
1. [说明](#说明)
2. [预测](#预测)
3. [训练](#训练)
4. [例子](#例子)
4. [例子](#例子)<br>
4.1 [ICDAR2015](#ICDAR2015)<br>
4.1.1 [带侧边改善](#带侧边改善)<br>
4.1.2 [不带带侧边改善](#不带侧边改善)<br>
4.1.3 [做数据增广-水平翻转](#做数据增广-水平翻转)<br>
4.2 [ICDAR2017](#ICDAR2017)<br>
4.3 [其它数据集](#其它数据集)
5. [toDoList](#toDoList)
6. [总结](#总结)

## 说明

Expand All @@ -16,21 +23,29 @@

​ cptn论文翻译:[CTPN.md](https://github.com/yizt/cv-papers/blob/master/CTPN.md)

效果:

​ 使用ICDAR2015的1000张图像训练在500张测试集上结果为:Recall: 37.07 % Precision: 42.94 % Hmean: 39.79 %;
原文中的F值为61%;使用了额外的3000张图像训练。

关键点说明:

a.骨干网络使用的是resnet50

b.训练输入图像大小为608*608; 将图像的长边缩放到608,保持长宽比,短边padding
b.训练输入图像大小为720*720; 将图像的长边缩放到720,保持长宽比,短边padding;原文是短边600;预测时使用1024*1024

c.batch_size 为4, 每张图像训练256个anchor,正负样本比为1:1
c.batch_size为4, 每张图像训练128个anchor,正负样本比为1:1;

d.分类、边框回归以及侧边改善的损失函数权重为1:1:1;原论文中是1:1:2

e.侧边改善与边框回归选择一样的正样本anchor;原文中应该是分开选择的

f. 侧边改善还是有效果的(注:网上很多人说没有啥效果)
f.侧边改善还是有效果的(注:网上很多人说没有啥效果)

g.由于有双向GRU,水平翻转会影响效果(见样例[做数据增广-水平翻转](#做数据增广-水平翻转))

h.随机裁剪做数据增广,网络不收敛




Expand All @@ -46,9 +61,7 @@ git clone https://github.com/yizt/keras-ctpn

b. 预训练模型下载

​ ICDAR2015训练集上训练好的模型下载地址:[ctpn.h5](https://pan.baidu.com/s/10LAyfh2pvE_ljXMYLe9gFw) 提取码:7vr8

​ ICDAR2017训练集上训练好的模型下载地址:[ctpn.050.h5](https://pan.baidu.com/s/1Wn0MY8DJqEwQyVcw0MH7Uw) 提取码:oy15
​ ICDAR2015训练集上训练好的模型下载地址:[ctpn.h5](https://pan.baidu.com/s/1XeQN0H1_FdTPBwH1GDlW_w) 提取码:k7yu

c.修改配置类config.py中如下属性

Expand All @@ -64,15 +77,30 @@ python predict.py --image_path image_3.jpg

## 评估

a. 执行如下命令,并将输出的txt压缩为zip包
```shell
python evaluate.py --weight_path /tmp/ctpn.140.h5 --image_dir /opt/dataset/OCR/ICDAR_2015/test_images/ --output_dir /tmp/output_2015/
```

b. 提交在线评估
将压缩的zip包提交评估,评估地址:http://rrc.cvc.uab.es/?ch=4&com=mymethods&task=1

## 训练

a. 训练数据下载
```shell
#icdar2013
wget http://rrc.cvc.uab.es/downloads/Challenge2_Training_Task12_Images.zip
wget http://rrc.cvc.uab.es/downloads/Challenge2_Training_Task1_GT.zip
wget http://rrc.cvc.uab.es/downloads/Challenge2_Test_Task12_Images.zip
```

icdar2015下载地址(官网打开太慢): https://download.csdn.net/download/moonshapedpool/10645292
```shell
#icdar2015
wget http://rrc.cvc.uab.es/downloads/ch4_training_images.zip
wget http://rrc.cvc.uab.es/downloads/ch4_training_localization_transcription_gt.zip
wget http://rrc.cvc.uab.es/downloads/ch4_test_images.zip
```

```shell
#icdar2017
Expand Down Expand Up @@ -127,6 +155,9 @@ python train.py --epochs 50

![](image_examples/icdar2015/img_200.0.jpg)

#### 做数据增广-水平翻转
![](image_examples/flip1.png)
![](image_examples/flip2.png)

### ICDAR2017

Expand All @@ -135,11 +166,27 @@ python train.py --epochs 50

![](image_examples/icdar2017/ts_img_01001.1.jpg)


### 其它数据集
![](image_examples/bkgd_1_0_generated_0.1.jpg)
![](image_examples/a2.png)
![](image_examples/a1.png)
![](image_examples/a3.png)
![](image_examples/a0.png)

## toDoList

1. 侧边改善(已完成)
2. ICDAR2017数据集训练
3. 检测文本行坐标映射到原图
4. 精度评估
2. ICDAR2017数据集训练(已完成)
3. 检测文本行坐标映射到原图(已完成)
4. 精度评估(已完成)
5. 侧边回归,限制在边框内(已完成)
6. 增加水平翻转(已完成)
7. 增加随机裁剪(已完成)



### 总结

1. ctpn对水平文字检测效果不错
2. 整个网络对于数据集很敏感;在2017上训练的模型到2015上测试效果很不好;同样2015训练的在2013上测试效果也很差
3. 推测由于双向GRU,网络有存储记忆的缘故?在使用随机裁剪作数据增广时网络不收敛,使用水平翻转时预测结果也水平对称出现
Binary file added image_examples/a0.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image_examples/a1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image_examples/a2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image_examples/a3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image_examples/bkgd_1_0_generated_0.1.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image_examples/flip1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image_examples/flip2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions predict.py
Expand Up @@ -25,6 +25,7 @@ def main(args):
if args.weight_path is not None:
config.WEIGHT_PATH = args.weight_path
config.IMAGES_PER_GPU = 1
config.IMAGE_SHAPE = (1024, 1024, 3)
# 加载图片
image, image_meta, _, _ = image_utils.load_image_gt(np.random.randint(10),
args.image_path,
Expand Down

0 comments on commit 95cb60e

Please sign in to comment.