Skip to content

Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.

fix(pdf-extract): ensure table recognition config defaults to disabled

myhloli52156eaee96a
diff --git a/magic_pdf/libs/config_reader.py b/magic_pdf/libs/config_reader.py
index 76c64042..eb282903 100644
--- a/magic_pdf/libs/config_reader.py
+++ b/magic_pdf/libs/config_reader.py
@@ -76,10 +76,15 @@ def get_device():
else:
return device
+
def get_table_recog_config():
config = read_config()
table_config = config.get("table-config")
- return table_config
+ if table_config is None:
+ logger.warning(f"'table-config' not found in {CONFIG_FILE_NAME}, use 'False' as default")
+ return json.loads('{"is_table_recog_enable": false, "max_time": 400}')
+ else:
+ return table_config
if __name__ == "__main__":
diff --git a/magic_pdf/model/pdf_extract_kit.py b/magic_pdf/model/pdf_extract_kit.py
index f4e6f9cd..56b90b38 100644
--- a/magic_pdf/model/pdf_extract_kit.py
+++ b/magic_pdf/model/pdf_extract_kit.py
@@ -1,7 +1,7 @@
from loguru import logger
import os
import time
-from pypandoc import convert_text
+
os.environ['NO_ALBUMENTATIONS_UPDATE'] = '1' # 禁止albumentations检查更新
try:
@@ -107,8 +107,8 @@ class CustomPEKModel:
self.apply_table = self.table_config.get("is_table_recog_enable", False)
self.apply_ocr = ocr
logger.info(
- "DocAnalysis init, this may take some times. apply_layout: {}, apply_formula: {}, apply_ocr: {}".format(
- self.apply_layout, self.apply_formula, self.apply_ocr
+ "DocAnalysis init, this may take some times. apply_layout: {}, apply_formula: {}, apply_ocr: {}, apply_table: {}".format(
+ self.apply_layout, self.apply_formula, self.apply_ocr, self.apply_table
)
)
assert self.apply_layout, "DocAnalysis must contain layout model."