### Install wired_table_rec Source: https://rapidai.github.io/TableStructureRec/docs/install_usage/wired_table_rec Install the library using pip. ```bash pip install wired_table_rec ``` -------------------------------- ### Install lineless_table_rec Source: https://rapidai.github.io/TableStructureRec/docs/install_usage/lineless_table_rec Use pip to install the library. ```bash pip install lineless_table_rec ``` -------------------------------- ### Example Recognition Output Source: https://rapidai.github.io/TableStructureRec/docs/install_usage/wired_table_rec The expected HTML output format for a recognized table. ```html
名称 产量(吨) 环比
增长量(吨) 增长率(%)
荔枝 11 10
芒果 -10
香蕉 20
``` -------------------------------- ### Perform Table Recognition in Python Source: https://rapidai.github.io/TableStructureRec/docs/install_usage/lineless_table_rec Initialize the recognition class, process an image, and save the resulting HTML and visualization files. ```python import os from lineless_table_rec import LinelessTableRecognition from lineless_table_rec.utils_table_recover import ( format_html, plot_rec_box, plot_rec_box_with_logic_info, ) output_dir = "outputs" img_path = "tests/test_files/lineless_table_recognition.jpg" table_rec = LinelessTableRecognition() html, elasp, polygons, logic_points, ocr_res = table_rec(img_path) print(f"cost: {elasp:.5f}") complete_html = format_html(html) os.makedirs(os.path.dirname(f"{output_dir}/table.html"), exist_ok=True) with open(f"{output_dir}/table.html", "w", encoding="utf-8") as file: file.write(complete_html) plot_rec_box_with_logic_info( img_path, f"{output_dir}/table_rec_box.jpg", logic_points, polygons ) plot_rec_box(img_path, f"{output_dir}/ocr_box.jpg", ocr_res) ``` -------------------------------- ### Run Recognition via Command Line Source: https://rapidai.github.io/TableStructureRec/docs/install_usage/wired_table_rec Execute the recognition process directly from the terminal. ```bash $ wired_table_rec -img tests/test_files/wired/table_recognition.jpg ``` -------------------------------- ### Run Table Recognition via Command Line Source: https://rapidai.github.io/TableStructureRec/docs/install_usage/lineless_table_rec Execute the recognition process directly from the terminal by specifying the image path. ```bash $ lineless_table_rec -img tests/test_files/lineless_table_recognition.jpg ``` -------------------------------- ### 安装表格识别推理库 Source: https://rapidai.github.io/TableStructureRec/docs/blog/table_rec_evaluate 安装用于表格识别的推理库。 ```bash pip install rapid_table pip install lineless_table_rec pip install wired_table_rec ``` -------------------------------- ### 安装评测依赖 Source: https://rapidai.github.io/TableStructureRec/docs/blog/table_rec_evaluate 安装评测所需的工具包和模型推理环境。 ```bash pip install table_recognition_metric pip install modelscope==1.5.2 pip install rapidocr_onnxruntime==1.3.8 ``` -------------------------------- ### 执行表格识别评测 Source: https://rapidai.github.io/TableStructureRec/docs/blog/table_rec_evaluate 加载测试数据集并使用指定的表格识别引擎计算TEDS指标。 ```python from modelscope.msdatasets import MsDataset from rapid_table import RapidTable from lineless_table_rec import LinelessTableRecognition from wired_table_rec import WiredTableRecognition from table_recognition_metric import TEDS test_data = MsDataset.load( "table_recognition", namespace="liekkas", subset_name="default", split="test", ) # 这里依次更换不同算法实例即可 table_engine = RapidTable() # table_engine = LinelessTableRecognition() # table_engine = WiredTableRecognition() teds = TEDS() content = [] for one_data in test_data: img_path = one_data.get("image:FILE") gt = one_data.get("label") pred_str, _ = table_engine(img_path) scores = teds(gt, pred_str) content.append(scores) print(f"{img_path}\t{scores:.5f}") avg = sum(content) / len(content) print(f'{avg:.5f}') ``` -------------------------------- ### Perform Table Recognition Source: https://rapidai.github.io/TableStructureRec/docs/install_usage/wired_table_rec Use the WiredTableRecognition class to process an image and retrieve the table structure. ```python from wired_table_rec import WiredTableRecognition table_rec = WiredTableRecognition() img_path = "tests/test_files/wired/table_recognition.jpg" table_str, elapse = table_rec(img_path) print(table_str) print(elapse) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.