Commit 52156eae authored by myhloli's avatar myhloli

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

If 'table-config' is not present in the configuration file, the table recognition
feature will default to being disabled to ensure consistent behavior. This change
adds a warning log and sets a default configuration for table recognition when the
expected config is missing.
parent 0998d22a
...@@ -76,10 +76,15 @@ def get_device(): ...@@ -76,10 +76,15 @@ def get_device():
else: else:
return device return device
def get_table_recog_config(): def get_table_recog_config():
config = read_config() config = read_config()
table_config = config.get("table-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__": if __name__ == "__main__":
......
from loguru import logger from loguru import logger
import os import os
import time import time
from pypandoc import convert_text
os.environ['NO_ALBUMENTATIONS_UPDATE'] = '1' # 禁止albumentations检查更新 os.environ['NO_ALBUMENTATIONS_UPDATE'] = '1' # 禁止albumentations检查更新
try: try:
...@@ -107,8 +107,8 @@ class CustomPEKModel: ...@@ -107,8 +107,8 @@ class CustomPEKModel:
self.apply_table = self.table_config.get("is_table_recog_enable", False) self.apply_table = self.table_config.get("is_table_recog_enable", False)
self.apply_ocr = ocr self.apply_ocr = ocr
logger.info( logger.info(
"DocAnalysis init, this may take some times. apply_layout: {}, apply_formula: {}, apply_ocr: {}".format( "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_layout, self.apply_formula, self.apply_ocr, self.apply_table
) )
) )
assert self.apply_layout, "DocAnalysis must contain layout model." assert self.apply_layout, "DocAnalysis must contain layout model."
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment