添加识别的try语句

This commit is contained in:
2024-07-10 17:22:10 +08:00
parent f89f68abd1
commit 7fce862a94

View File

@@ -259,7 +259,15 @@ def get_mask_layout(image, content):
result = []
try:
# layouts = get_ocr_layout(OCR, temp_file.name)
try:
layouts = DOC_PARSER.parse({"doc": temp_file.name})["layout"]
except MemoryError as me:
# 如果是显存溢出问题,则抛出
raise me
except Exception as e:
# 如果是没有识别到文字等问题,则继续
logging.warning("识别失败", exc_info=e)
layouts = []
if not layouts:
# 无识别结果
return result