Skip to content

Commit 1d5b3b0

Browse files
authored
Merge pull request #37 from RapidAI/optim_table_cls
Optim table cls & add online demo
2 parents 4db0b43 + a6c30a2 commit 1d5b3b0

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

.github/workflows/wired_table_rec.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ jobs:
3333
unzip wired_table_rec_models.zip
3434
mv wired_table_rec_models/*.onnx wired_table_rec/models/
3535
36-
wget https://github.com/RapidAI/TableStructureRec/releases/download/v0.0.0/wired_table_rec_modelsV2.zip
37-
unzip wired_table_rec_modelsV2.zip
38-
mv cycle_center_net_v2.onnx wired_table_rec/models/
39-
4036
pytest tests/test_wired_table_rec.py
4137
4238
GenerateWHL_PushPyPi:

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
- **2024.9.26**
1717
- 修正RapidTable默认英文模型导致的测评结果错误。
1818
- 补充测评数据集,补充开源社区更多模型的测评结果
19-
19+
- **2024.9.30**
20+
- 优化表格类型判断,增加在线演示
21+
2022
### 简介
2123
💖该仓库是用来对文档中表格做结构化识别的推理库,包括来自paddle的表格识别模型,
2224
阿里读光有线和无线表格识别模型,llaipython(微信)贡献的有线表格模型,网易Qanything内置表格分类模型等。
@@ -29,6 +31,9 @@
2931

3032
🛡️ ****: 不依赖任何第三方训练框架,只依赖必要基础库,避免包冲突
3133

34+
### 在线演示
35+
[modelscope魔塔](https://www.modelscope.cn/studios/jockerK/TableRec)
36+
[huggingface](https://huggingface.co/spaces/Joker1212/TableDetAndRec)
3237
### 效果展示
3338

3439
<div align="center">

table_cls/main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import time
22
from pathlib import Path
33

4+
import cv2
45
import numpy as np
56
import onnxruntime
67
from PIL import Image
@@ -39,8 +40,10 @@ def _preprocess(self, image):
3940
def __call__(self, content: InputType):
4041
ss = time.perf_counter()
4142
img = self.load_img(content)
42-
img = self._preprocess(img)
43-
output = self.table_cls.run(None, {"input": img})
43+
gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
44+
gray_img = np.stack((gray_img,) * 3, axis=-1)
45+
gray_img = self._preprocess(gray_img)
46+
output = self.table_cls.run(None, {"input": gray_img})
4447
predict = np.exp(output[0] - np.max(output[0], axis=1, keepdims=True))
4548
predict /= np.sum(predict, axis=1, keepdims=True)
4649
predict_cla = np.argmax(predict, axis=1)[0]

0 commit comments

Comments
 (0)