13
13
</div >
14
14
15
15
### 最近更新
16
- - ** 2024.9.30**
17
- - 优化表格类型判断,增加在线演示
18
16
- ** 2024.10.13**
19
17
- 补充最新paddlex-SLANet-plus 测评结果(已集成模型到[ RapidTable] ( https://github.com/RapidAI/RapidTable ) 仓库)
20
18
- ** 2024.10.17**
21
- - 补充最新surya 表格识别测评结果
19
+ - 补充最新surya 表格识别测评结果
20
+ - ** 2024.10.22**
21
+ - 补充复杂背景多表格检测提取方案[ RapidTableDet] ( https://github.com/RapidAI/RapidTableDetection )
22
22
### 简介
23
23
💖该仓库是用来对文档中表格做结构化识别的推理库,包括来自paddle的表格识别模型,
24
24
阿里读光有线和无线表格识别模型,llaipython(微信)贡献的有线表格模型,网易Qanything内置表格分类模型等。
@@ -117,26 +117,35 @@ print(f"elasp: {elasp}")
117
117
# plot_rec_box(img_path, f"{output_dir}/ocr_box.jpg", ocr_res)
118
118
```
119
119
120
- #### 偏移修正
121
-
120
+ #### 表格旋转及透视修正
121
+ 需要gpu或更高精度场景,请参考项目[ RapidTableDet] ( https://github.com/RapidAI/RapidTableDetection )
122
+ ``` python
123
+ pip install rapid- table- det
124
+ ```
122
125
``` python
126
+ import os
123
127
import cv2
124
-
125
- img_path = f ' tests/test_files/wired/squeeze_error.jpeg '
126
- from wired_table_rec.utils import ImageOrientationCorrector
127
-
128
- img_orientation_corrector = ImageOrientationCorrector()
129
- img = cv2.imread(img_path)
130
- img = img_orientation_corrector(img)
131
- cv2.imwrite(f ' img_rotated.jpg ' , img)
128
+ from rapid_table_det.utils import img_loader, visuallize, extract_table_img
129
+ from rapid_table_det.inference import TableDetector
130
+ table_det = TableDetector()
131
+ img_path = f " tests/test_files/chip.jpg "
132
+ result, elapse = table_det(img_path)
133
+ img = img_loader(img_path)
134
+ extract_img = img.copy()
135
+ # 可能有多表格
136
+ for i, res in enumerate (result):
137
+ box = res[" box" ]
138
+ lt, rt, rb, lb = res[" lt" ], res[" rt" ], res[" rb" ], res[" lb" ]
139
+ # 带识别框和左上角方向位置
140
+ img = visuallize(img, box, lt, rt, rb, lb)
141
+ # 透视变换提取表格图片
142
+ wrapped_img = extract_table_img(extract_img.copy(), lt, rt, rb, lb)
143
+ # cv2.imwrite(f"{out_dir}/{file_name}-extract-{i}.jpg", wrapped_img)
144
+ # cv2.imwrite(f"{out_dir}/{file_name}-visualize.jpg", img)
132
145
```
133
146
134
147
## FAQ (Frequently Asked Questions)
135
-
136
- 1 . ** 问:偏移的图片能够处理吗?**
137
- - 答:该项目暂时不支持偏移图片识别,请先修正图片,也欢迎提pr来解决这个问题。
138
-
139
- 2 . ** 问:识别框丢失了内部文字信息**
148
+ 1 . ** 问:识别框丢失了内部文字信息**
140
149
- 答:默认使用的rapidocr小模型,如果需要更高精度的效果,可以从 [ 模型列表] ( https://rapidai.github.io/RapidOCRDocs/model_list/#_1 )
141
150
下载更高精度的ocr模型,在执行时传入ocr_result即可
142
151
@@ -149,8 +158,8 @@ cv2.imwrite(f'img_rotated.jpg', img)
149
158
150
159
- [x] 图片小角度偏移修正方法补充
151
160
- [x] 增加数据集数量,增加更多评测对比
152
- - [ ] 补充复杂场景表格检测和提取,解决旋转和透视导致的低识别率
153
- - [ ] 优化无线表格模型
161
+ - [x ] 补充复杂场景表格检测和提取,解决旋转和透视导致的低识别率
162
+ - [ ] 优化表格分类器, 优化无线表格模型
154
163
155
164
### 处理流程
156
165
0 commit comments