Skip to content

Commit

Permalink
Merge pull request #37 from RapidAI/optim_table_cls
Browse files Browse the repository at this point in the history
Optim table cls & add online demo
  • Loading branch information
SWHL authored Sep 30, 2024
2 parents 4db0b43 + a6c30a2 commit 1d5b3b0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/wired_table_rec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ jobs:
unzip wired_table_rec_models.zip
mv wired_table_rec_models/*.onnx wired_table_rec/models/
wget https://github.com/RapidAI/TableStructureRec/releases/download/v0.0.0/wired_table_rec_modelsV2.zip
unzip wired_table_rec_modelsV2.zip
mv cycle_center_net_v2.onnx wired_table_rec/models/
pytest tests/test_wired_table_rec.py
GenerateWHL_PushPyPi:
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
- **2024.9.26**
- 修正RapidTable默认英文模型导致的测评结果错误。
- 补充测评数据集,补充开源社区更多模型的测评结果

- **2024.9.30**
- 优化表格类型判断,增加在线演示

### 简介
💖该仓库是用来对文档中表格做结构化识别的推理库,包括来自paddle的表格识别模型,
阿里读光有线和无线表格识别模型,llaipython(微信)贡献的有线表格模型,网易Qanything内置表格分类模型等。
Expand All @@ -29,6 +31,9 @@

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

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

<div align="center">
Expand Down
7 changes: 5 additions & 2 deletions table_cls/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import time
from pathlib import Path

import cv2
import numpy as np
import onnxruntime
from PIL import Image
Expand Down Expand Up @@ -39,8 +40,10 @@ def _preprocess(self, image):
def __call__(self, content: InputType):
ss = time.perf_counter()
img = self.load_img(content)
img = self._preprocess(img)
output = self.table_cls.run(None, {"input": img})
gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
gray_img = np.stack((gray_img,) * 3, axis=-1)
gray_img = self._preprocess(gray_img)
output = self.table_cls.run(None, {"input": gray_img})
predict = np.exp(output[0] - np.max(output[0], axis=1, keepdims=True))
predict /= np.sum(predict, axis=1, keepdims=True)
predict_cla = np.argmax(predict, axis=1)[0]
Expand Down

0 comments on commit 1d5b3b0

Please sign in to comment.