Skip to content

Commit adda5dd

Browse files
committed
fix bug
1 parent d1b31bf commit adda5dd

12 files changed

+41
-60
lines changed

doc/doc_ch/algorithm_overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,4 @@
107107

108108
|模型|骨干网络|配置文件|acc|下载链接|
109109
|---|---|---|---|---|
110-
|TableMaster|TableResNetExtra|[configs/table/table_master.yml](../../configs/table/table_master.yml)|77.47%|[训练模型]|[训练模型](https://paddleocr.bj.bcebos.com/ppstructure/models/tablemaster/table_structure_tablemaster_train.tar)/[推理模型](https://paddleocr.bj.bcebos.com/ppstructure/models/tablemaster/table_structure_tablemaster_infer.tar)|
110+
|TableMaster|TableResNetExtra|[configs/table/table_master.yml](../../configs/table/table_master.yml)|77.47%|[训练模型](https://paddleocr.bj.bcebos.com/ppstructure/models/tablemaster/table_structure_tablemaster_train.tar) / [推理模型](https://paddleocr.bj.bcebos.com/ppstructure/models/tablemaster/table_structure_tablemaster_infer.tar)|

doc/doc_ch/algorithm_table_master.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ python3 tools/export_model.py -c configs/table/table_master.yml -o Global.pretra
5555

5656
转换成功后,在目录下有三个文件:
5757
```
58-
/inference/table_master/
58+
./inference/table_master/
5959
├── inference.pdiparams # 识别inference模型的参数文件
6060
├── inference.pdiparams.info # 识别inference模型的参数信息,可忽略
6161
└── inference.pdmodel # 识别inference模型的program文件

doc/doc_en/algorithm_overview_en.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# OCR Algorithms
22

3-
- [1. Two-stage Algorithms](#1)
4-
* [1.1 Text Detection Algorithms](#11)
5-
* [1.2 Text Recognition Algorithms](#12)
6-
- [2. End-to-end Algorithms](#2)
7-
- [3. Table Recognition Algorithms](#3)
3+
- [1. Two-stage Algorithms](#1-two-stage-algorithms)
4+
- [1.1 Text Detection Algorithms](#11-text-detection-algorithms)
5+
- [1.2 Text Recognition Algorithms](#12-text-recognition-algorithms)
6+
- [2. End-to-end Algorithms](#2-end-to-end-algorithms)
7+
- [3. Table Recognition Algorithms](#3-table-recognition-algorithms)
88

99

1010
This tutorial lists the OCR algorithms supported by PaddleOCR, as well as the models and metrics of each algorithm on **English public datasets**. It is mainly used for algorithm introduction and algorithm performance comparison. For more models on other datasets including Chinese, please refer to [PP-OCR v2.0 models list](./models_list_en.md).
@@ -107,4 +107,4 @@ On the PubTabNet dataset, the algorithm result is as follows:
107107

108108
|Model|Backbone|Config|Acc|Download link|
109109
|---|---|---|---|---|
110-
|TableMaster|TableResNetExtra|[configs/table/table_master.yml](../../configs/table/table_master.yml)|77.47%|[训练模型]|[训练模型](https://paddleocr.bj.bcebos.com/ppstructure/models/tablemaster/table_structure_tablemaster_train.tar)/[推理模型](https://paddleocr.bj.bcebos.com/ppstructure/models/tablemaster/table_structure_tablemaster_infer.tar)|
110+
|TableMaster|TableResNetExtra|[configs/table/table_master.yml](../../configs/table/table_master.yml)|77.47%|[trained](https://paddleocr.bj.bcebos.com/ppstructure/models/tablemaster/table_structure_tablemaster_train.tar) / [inference model](https://paddleocr.bj.bcebos.com/ppstructure/models/tablemaster/table_structure_tablemaster_infer.tar)|

doc/doc_en/algorithm_table_master_en.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Torm Recognition Algorithm-TableMASTER
1+
# Table Recognition Algorithm-TableMASTER
22

33
- [1. Introduction](#1-introduction)
44
- [2. Environment](#2-environment)
@@ -24,7 +24,7 @@ On the PubTabNet table recognition public data set, the algorithm reproduction a
2424

2525
|Model|Backbone|Cnnfig|Acc|Download link|
2626
| --- | --- | --- | --- | --- |
27-
|TableMaster|TableResNetExtra|[configs/table/table_master.yml](../../configs/table/table_master.yml)|77.47%|[train model](https://paddleocr.bj.bcebos.com/ppstructure/models/tablemaster/table_structure_tablemaster_train.tar)/[inference model](https://paddleocr.bj.bcebos.com/ppstructure/models/tablemaster/table_structure_tablemaster_infer.tar)|
27+
|TableMaster|TableResNetExtra|[configs/table/table_master.yml](../../configs/table/table_master.yml)|77.47%|[trained model](https://paddleocr.bj.bcebos.com/ppstructure/models/tablemaster/table_structure_tablemaster_train.tar)/[inference model](https://paddleocr.bj.bcebos.com/ppstructure/models/tablemaster/table_structure_tablemaster_infer.tar)|
2828

2929

3030
<a name="2"></a>

ppocr/data/imaug/label_ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ def __call__(self, data):
671671

672672
def _merge_no_span_structure(self, structure):
673673
"""
674-
This fun code is refer from:
674+
This code is refer from:
675675
https://github.com/JiaquanYe/TableMASTER-mmocr/blob/master/table_recognition/data_preprocess.py
676676
"""
677677
new_structure = []

ppocr/losses/table_master_loss.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
"""
15-
This fun code is refer from:
15+
This code is refer from:
1616
https://github.com/JiaquanYe/TableMASTER-mmocr/tree/master/mmocr/models/textrecog/losses
1717
"""
1818

ppocr/metrics/table_metric.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ def __call__(self, pred_label, batch=None, *args, **kwargs):
3131
gt_structure_batch_list):
3232
pred_str = ''.join(pred)
3333
target_str = ''.join(target)
34-
# pred_str = pred_str.replace('<thead>','').replace('</thead>','').replace('<tbody>','').replace('</tbody>','')
35-
# target_str = target_str.replace('<thead>','').replace('</thead>','').replace('<tbody>','').replace('</tbody>','')
3634
if pred_str == target_str:
3735
correct_num += 1
3836
all_num += 1
@@ -55,8 +53,6 @@ def reset(self):
5553
self.len_acc_num = 0
5654
self.token_nums = 0
5755
self.anys_dict = dict()
58-
from collections import defaultdict
59-
self.error_num_dict = defaultdict(int)
6056

6157

6258
class TableMetric(object):

ppocr/modeling/backbones/table_master_resnet.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
"""
15-
This fun code is refer from:
15+
This code is refer from:
1616
https://github.com/JiaquanYe/TableMASTER-mmocr/blob/master/mmocr/models/textrecog/backbones/table_resnet_extra.py
1717
"""
1818

@@ -193,47 +193,43 @@ def _make_layer(self, block, planes, blocks, stride=1, gcb_config=None):
193193

194194
def forward(self, x):
195195
f = []
196-
x = self.conv1(x) # 1,64,480,480
196+
x = self.conv1(x)
197197

198198
x = self.bn1(x)
199199
x = self.relu1(x)
200200

201-
x = self.conv2(x) # 1,128,480,480
201+
x = self.conv2(x)
202202
x = self.bn2(x)
203203
x = self.relu2(x)
204-
# (48, 160)
205204

206-
x = self.maxpool1(x) # 1,64,240,240
205+
x = self.maxpool1(x)
207206
x = self.layer1(x)
208207

209-
x = self.conv3(x) # 1,256,240,240
208+
x = self.conv3(x)
210209
x = self.bn3(x)
211210
x = self.relu3(x)
212211
f.append(x)
213-
# (24, 80)
214212

215-
x = self.maxpool2(x) # 1,256,120,120
213+
x = self.maxpool2(x)
216214
x = self.layer2(x)
217215

218-
x = self.conv4(x) # 1,256,120,120
216+
x = self.conv4(x)
219217
x = self.bn4(x)
220218
x = self.relu4(x)
221219
f.append(x)
222-
# (12, 40)
223220

224-
x = self.maxpool3(x) # 1,256,60,60
221+
x = self.maxpool3(x)
225222

226-
x = self.layer3(x) # 1,512,60,60
227-
x = self.conv5(x) # 1,512,60,60
223+
x = self.layer3(x)
224+
x = self.conv5(x)
228225
x = self.bn5(x)
229226
x = self.relu5(x)
230227

231-
x = self.layer4(x) # 1,512,60,60
232-
x = self.conv6(x) # 1,512,60,60
228+
x = self.layer4(x)
229+
x = self.conv6(x)
233230
x = self.bn6(x)
234231
x = self.relu6(x)
235232
f.append(x)
236-
# (6, 40)
237233
return f
238234

239235

ppocr/modeling/heads/table_master_head.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
"""
15-
This fun code is refer from:
15+
This code is refer from:
1616
https://github.com/JiaquanYe/TableMASTER-mmocr/blob/master/mmocr/models/textrecog/decoders/master_decoder.py
1717
"""
1818

@@ -135,7 +135,7 @@ def forward_test(self, out_enc):
135135
batch_size = out_enc.shape[0]
136136
SOS = paddle.zeros([batch_size, 1], dtype='int64') + self.SOS
137137
output, bbox_output = self.greedy_forward(SOS, out_enc)
138-
# output = F.softmax(output)
138+
output = F.softmax(output)
139139
return {'structure_probs': output, 'loc_preds': bbox_output}
140140

141141
def forward(self, feat, targets=None):

ppocr/utils/visual.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,16 @@ def draw_re_results(image,
110110

111111
img_new = Image.blend(image, img_new, 0.5)
112112
return np.array(img_new)
113+
114+
115+
def draw_rectangle(img_path, boxes, use_xywh=False):
116+
img = cv2.imread(img_path)
117+
img_show = img.copy()
118+
for box in boxes.astype(int):
119+
if use_xywh:
120+
x, y, w, h = box
121+
x1, y1, x2, y2 = x - w // 2, y - h // 2, x + w // 2, y + h // 2
122+
else:
123+
x1, y1, x2, y2 = box
124+
cv2.rectangle(img_show, (x1, y1), (x2, y2), (255, 0, 0), 2)
125+
return img_show

ppstructure/table/predict_structure.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from ppocr.postprocess import build_post_process
3131
from ppocr.utils.logging import get_logger
3232
from ppocr.utils.utility import get_image_file_list, check_and_read_gif
33+
from ppocr.utils.visual import draw_rectangle
3334
from ppstructure.utility import parse_args
3435

3536
logger = get_logger()
@@ -120,19 +121,6 @@ def __call__(self, img):
120121
return structure_str_list, bbox_list, elapse
121122

122123

123-
def draw_rectangle(img_path, boxes, use_xywh=False):
124-
img = cv2.imread(img_path)
125-
img_show = img.copy()
126-
for box in boxes.astype(int):
127-
if use_xywh:
128-
x, y, w, h = box
129-
x1, y1, x2, y2 = x - w // 2, y - h // 2, x + w // 2, y + h // 2
130-
else:
131-
x1, y1, x2, y2 = box
132-
cv2.rectangle(img_show, (x1, y1), (x2, y2), (255, 0, 0), 2)
133-
return img_show
134-
135-
136124
def main(args):
137125
image_file_list = get_image_file_list(args.image_dir)
138126
table_structurer = TableStructurer(args)

tools/infer_table.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
from ppocr.postprocess import build_post_process
3737
from ppocr.utils.save_load import load_model
3838
from ppocr.utils.utility import get_image_file_list
39+
from ppocr.utils.visual import draw_rectangle
3940
import tools.program as program
4041
import cv2
4142

@@ -111,19 +112,6 @@ def main(config, device, logger, vdl_writer):
111112
logger.info("success!")
112113

113114

114-
def draw_rectangle(img_path, boxes, use_xywh=False):
115-
img = cv2.imread(img_path)
116-
img_show = img.copy()
117-
for box in boxes.astype(int):
118-
if use_xywh:
119-
x, y, w, h = box
120-
x1, y1, x2, y2 = x - w // 2, y - h // 2, x + w // 2, y + h // 2
121-
else:
122-
x1, y1, x2, y2 = box
123-
cv2.rectangle(img_show, (x1, y1), (x2, y2), (255, 0, 0), 2)
124-
return img_show
125-
126-
127115
if __name__ == '__main__':
128116
config, device, logger, vdl_writer = program.preprocess()
129117
main(config, device, logger, vdl_writer)

0 commit comments

Comments
 (0)