🚀 微軟表格變換器表格結構識別模型
本項目是基於Pubtables和Fintabnet數據集訓練的微軟表格變換器(Table Transformer)表格結構識別模型。該模型可用於精準識別表格的結構,為表格數據的處理和分析提供支持。
🚀 快速開始
模型註冊
如果你還沒有該模型的deepdoctection
配置文件,請添加以下代碼進行模型註冊:
import deepdoctection as dd
dd.ModelCatalog.register("deepdoctection/tatr_tab_struct_v2/pytorch_model.bin", dd.ModelProfile(
name="deepdoctection/tatr_tab_struct_v2/pytorch_model.bin",
description="Table Transformer (DETR) model trained on PubTables1M. It was introduced in the paper "
"Aligning benchmark datasets for table structure recognition by Smock et "
"al. This model is devoted to table structure recognition and assumes to receive a slightly cropped"
"table as input. It will predict rows, column and spanning cells. Use a padding of around 5 pixels",
size=[115511753],
tp_model=False,
config="deepdoctection/tatr_tab_struct_v2/config.json",
preprocessor_config="deepdoctection/tatr_tab_struct_v2/preprocessor_config.json",
hf_repo_id="deepdoctection/tatr_tab_struct_v2",
hf_model_name="pytorch_model.bin",
hf_config_file=["config.json", "preprocessor_config.json"],
categories={
"1": dd.LayoutType.table,
"2": dd.LayoutType.column,
"3": dd.LayoutType.row,
"4": dd.CellType.column_header,
"5": dd.CellType.projected_row_header,
"6": dd.CellType.spanning,
},
dl_library="PT",
model_wrapper="HFDetrDerivedDetector",
))
模型運行
在deepdoctection
分析器中運行該模型時,你可以調整分割參數以獲得更好的預測結果:
import deepdoctection as dd
analyzer = dd.get_dd_analyzer(reset_config_file=True, config_overwrite=["PT.ITEM.WEIGHTS=deepdoctection/tatr_tab_struct_v2/pytorch_model.bin",
"PT.ITEM.FILTER=['table']",
"PT.ITEM.PAD.TOP=5",
"PT.ITEM.PAD.RIGHT=5",
"PT.ITEM.PAD.BOTTOM=5",
"PT.ITEM.PAD.LEFT=5",
"SEGMENTATION.THRESHOLD_ROWS=0.9",
"SEGMENTATION.THRESHOLD_COLS=0.9",
"SEGMENTATION.REMOVE_IOU_THRESHOLD_ROWS=0.3",
"SEGMENTATION.REMOVE_IOU_THRESHOLD_COLS=0.3",
"WORD_MATCHING.MAX_PARENT_ONLY=True"])