From e3198ccdf6e6444c8d07c3f7d59a8761f9bdcb51 Mon Sep 17 00:00:00 2001 From: liuyebo <1515783401@qq.com> Date: Thu, 11 Jul 2024 12:59:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BC=82=E5=B8=B8=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- photo_mask.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/photo_mask.py b/photo_mask.py index 624b8e1..2454814 100644 --- a/photo_mask.py +++ b/photo_mask.py @@ -261,13 +261,12 @@ def get_mask_layout(image, contents): # 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) + except TypeError as te: + # 如果是类型错误,大概率是没识别到文字 layouts = [] + except Exception as e: + # 如果出现其他错误,抛出 + raise e if not layouts: # 无识别结果 return result