@@ -91,7 +91,7 @@ pip install rapidocr
91
91
``` python {linenos=table}
92
92
from pathlib import Path
93
93
94
- from demo_wired import viser
94
+ from wired_table_rec.utils.utils import VisTable
95
95
from table_cls import TableCls
96
96
from wired_table_rec.main import WiredTableInput, WiredTableRecognition
97
97
from lineless_table_rec.main import LinelessTableInput, LinelessTableRecognition
@@ -104,7 +104,8 @@ if __name__ == "__main__":
104
104
lineless_input = LinelessTableInput()
105
105
wired_engine = WiredTableRecognition(wired_input)
106
106
lineless_engine = LinelessTableRecognition(lineless_input)
107
- # yolo(0.1s),yolox(0.25s),qanything(0.07s) paddle(0.03s)
107
+ viser = VisTable()
108
+ # 默认小yolo模型(0.1s),可切换为精度更高yolox(0.25s),更快的qanything(0.07s)模型或paddle模型(0.03s)
108
109
table_cls = TableCls()
109
110
img_path = f " tests/test_files/table.jpg "
110
111
@@ -114,16 +115,17 @@ if __name__ == "__main__":
114
115
else :
115
116
table_engine = lineless_engine
116
117
117
- # use rapid ocr as input
118
+ # 使用RapidOCR输入
118
119
ocr_engine = RapidOCR()
119
120
rapid_ocr_output = ocr_engine(img_path, return_word_box = True )
120
- ocr_result = list (zip (rapid_ocr_output.boxes, rapid_ocr_output.txts, rapid_ocr_output.scores))
121
+ ocr_result = list (
122
+ zip (rapid_ocr_output.boxes, rapid_ocr_output.txts, rapid_ocr_output.scores)
123
+ )
121
124
table_results = table_engine(
122
- img_path, ocr_result = ocr_result, enhance_box_line = False
125
+ img_path, ocr_result = ocr_result
123
126
)
124
-
125
-
126
- # use word rec ocr
127
+
128
+ # 使用单字识别
127
129
# word_results = rapid_ocr_output.word_results
128
130
# ocr_result = [
129
131
# [word_result[2], word_result[0], word_result[1]] for word_result in word_results
@@ -133,19 +135,19 @@ if __name__ == "__main__":
133
135
# )
134
136
135
137
# Save
136
- # save_dir = Path("outputs")
137
- # save_dir.mkdir(parents=True, exist_ok=True)
138
- #
139
- # save_html_path = f"outputs/{Path(img_path).stem}.html"
140
- # save_drawed_path = f"outputs/{Path(img_path).stem}_table_vis{Path(img_path).suffix}"
141
- # save_logic_path = (
142
- # f"outputs/{Path(img_path).stem}_table_vis_logic{Path(img_path).suffix}"
143
- # )
138
+ # save_dir = Path("outputs")
139
+ # save_dir.mkdir(parents=True, exist_ok=True)
140
+
141
+ # save_html_path = f"outputs/{Path(img_path).stem}.html"
142
+ # save_drawed_path = f"outputs/{Path(img_path).stem}_table_vis{Path(img_path).suffix}"
143
+ # save_logic_path = (
144
+ # f"outputs/{Path(img_path).stem}_table_vis_logic{Path(img_path).suffix}"
145
+ # )
144
146
145
147
# Visualize table rec result
146
- # vis_imged = viser(
147
- # img_path, table_results, save_html_path, save_drawed_path, save_logic_path
148
- # )
148
+ # vis_imged = viser(
149
+ # img_path, table_results, save_html_path, save_drawed_path, save_logic_path
150
+ # )
149
151
150
152
```
151
153
#### Single Character OCR Matching
0 commit comments