RapidTable release v1.0.3

77 阅读1分钟

引言

经过几日来的不懈努力,RapidTable 库终于迎来了 1.0 系列。

RapidTable 库是专门用来文档类图像的表格结构还原,表格结构模型均属于序列预测方法,结合 RapidOCR,将给定图像中的表格转化对应的 HTML 格式。

效果展示

preview.gif

模型列表

model_type模型名称推理框架模型大小推理耗时(单图 60KB)
ppstructure_enen_ppstructure_mobile_v2_SLANet.onnxonnxruntime7.3M0.15s
ppstructure_zhch_ppstructure_mobile_v2_SLANet.onnxonnxruntime7.4M0.15s
slanet_plusslanet-plus.onnxonnxruntime6.8M0.15s
unitableunitable(encoder.pth,decoder.pth)pytorch500Mcpu(6s) gpu-4090(1.5s)

模型来源
PaddleOCR 表格识别
PaddleX-SlaNetPlus 表格识别
Unitable

模型下载地址:link

主要更新

⚠️ 注意:本次更新版本为v1.x,不兼容v0.x版本,请谨慎更新,避免导致接口调用有误。

  1. RapidTable 的输入输出做了更新,采用dataclasses来封装,简化参数传递,便于后续使用,更新和维护。示例如下:

    # 输入
    @dataclass
    class RapidTableInput:
       model_type: Optional[str] = ModelType.SLANETPLUS.value
       model_path: Union[str, Path, None, Dict[str, str]] = None
       use_cuda: bool = False
       device: str = "cpu"
    
    # 输出
    @dataclass
    class RapidTableOutput:
       pred_html: Optional[str] = None
       cell_bboxes: Optional[np.ndarray] = None
       logic_points: Optional[np.ndarray] = None
       elapse: Optional[float] = None
    
    # 使用示例
    input_args = RapidTableInput(model_type="unitable")
    table_engine = RapidTable(input_args)
    
    img_path = 'test_images/table.jpg'
    table_results = table_engine(img_path)
    
    print(table_results.pred_html)
    
  2. 集成了 Unitable 项目最新表格识别算法,推理引擎为 torch,提升了 RapidTable 的上限。

  3. 优化了模型下载和托管问题,模型托管在 modelscope 上。在使用时,只需要指定对应的model_type,即可自动下载对应模型。当然,也可以通过model_path来具体指定模型路径。