Skip to content

Commit 0bb5bb0

Browse files
committed
chore: update readme
1 parent 05d10ee commit 0bb5bb0

File tree

3 files changed

+33
-28
lines changed

3 files changed

+33
-28
lines changed

README.md

+9-5
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pip install rapidocr
9191
``` python {linenos=table}
9292
from pathlib import Path
9393

94-
from demo_wired import viser
94+
from wired_table_rec.utils.utils import VisTable
9595
from table_cls import TableCls
9696
from wired_table_rec.main import WiredTableInput, WiredTableRecognition
9797
from lineless_table_rec.main import LinelessTableInput, LinelessTableRecognition
@@ -104,6 +104,7 @@ if __name__ == "__main__":
104104
lineless_input = LinelessTableInput()
105105
wired_engine = WiredTableRecognition(wired_input)
106106
lineless_engine = LinelessTableRecognition(lineless_input)
107+
viser = VisTable()
107108
# 默认小yolo模型(0.1s),可切换为精度更高yolox(0.25s),更快的qanything(0.07s)模型或paddle模型(0.03s)
108109
table_cls = TableCls()
109110
img_path = f"tests/test_files/table.jpg"
@@ -117,12 +118,13 @@ if __name__ == "__main__":
117118
# 使用RapidOCR输入
118119
ocr_engine = RapidOCR()
119120
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+
)
121124
table_results = table_engine(
122-
img_path, ocr_result=ocr_result, enhance_box_line=False
125+
img_path, ocr_result=ocr_result
123126
)
124-
125-
127+
126128
# 使用单字识别
127129
# word_results = rapid_ocr_output.word_results
128130
# ocr_result = [
@@ -149,6 +151,8 @@ if __name__ == "__main__":
149151

150152

151153

154+
155+
152156
```
153157

154158
#### 单字ocr匹配

README_en.md

+21-19
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pip install rapidocr
9191
``` python {linenos=table}
9292
from pathlib import Path
9393

94-
from demo_wired import viser
94+
from wired_table_rec.utils.utils import VisTable
9595
from table_cls import TableCls
9696
from wired_table_rec.main import WiredTableInput, WiredTableRecognition
9797
from lineless_table_rec.main import LinelessTableInput, LinelessTableRecognition
@@ -104,7 +104,8 @@ if __name__ == "__main__":
104104
lineless_input = LinelessTableInput()
105105
wired_engine = WiredTableRecognition(wired_input)
106106
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)
108109
table_cls = TableCls()
109110
img_path = f"tests/test_files/table.jpg"
110111

@@ -114,16 +115,17 @@ if __name__ == "__main__":
114115
else:
115116
table_engine = lineless_engine
116117

117-
# use rapid ocr as input
118+
# 使用RapidOCR输入
118119
ocr_engine = RapidOCR()
119120
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+
)
121124
table_results = table_engine(
122-
img_path, ocr_result=ocr_result, enhance_box_line=False
125+
img_path, ocr_result=ocr_result
123126
)
124-
125-
126-
# use word rec ocr
127+
128+
# 使用单字识别
127129
# word_results = rapid_ocr_output.word_results
128130
# ocr_result = [
129131
# [word_result[2], word_result[0], word_result[1]] for word_result in word_results
@@ -133,19 +135,19 @@ if __name__ == "__main__":
133135
# )
134136

135137
# 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+
#)
144146

145147
# 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+
#)
149151

150152
```
151153
#### Single Character OCR Matching

demo_all.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1+
from wired_table_rec.utils.utils import VisTable
12
from table_cls import TableCls
23
from wired_table_rec.main import WiredTableInput, WiredTableRecognition
34
from lineless_table_rec.main import LinelessTableInput, LinelessTableRecognition
45
from rapidocr import RapidOCR
56

6-
77
if __name__ == "__main__":
88
# Init
99
wired_input = WiredTableInput()
1010
lineless_input = LinelessTableInput()
1111
wired_engine = WiredTableRecognition(wired_input)
1212
lineless_engine = LinelessTableRecognition(lineless_input)
13+
viser = VisTable()
1314
# 默认小yolo模型(0.1s),可切换为精度更高yolox(0.25s),更快的qanything(0.07s)模型或paddle模型(0.03s)
1415
table_cls = TableCls()
1516
img_path = f"tests/test_files/table.jpg"
@@ -26,9 +27,7 @@
2627
ocr_result = list(
2728
zip(rapid_ocr_output.boxes, rapid_ocr_output.txts, rapid_ocr_output.scores)
2829
)
29-
table_results = table_engine(
30-
img_path, ocr_result=ocr_result, enhance_box_line=False
31-
)
30+
table_results = table_engine(img_path, ocr_result=ocr_result)
3231

3332
# 使用单字识别
3433
# word_results = rapid_ocr_output.word_results

0 commit comments

Comments
 (0)