@@ -91,7 +91,7 @@ pip install rapidocr
9191``` python {linenos=table}
9292from pathlib import Path
9393
94- from demo_wired import viser
94+ from wired_table_rec.utils.utils import VisTable
9595from table_cls import TableCls
9696from wired_table_rec.main import WiredTableInput, WiredTableRecognition
9797from 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
0 commit comments