添加识别的try语句
This commit is contained in:
@@ -259,7 +259,15 @@ def get_mask_layout(image, content):
|
|||||||
result = []
|
result = []
|
||||||
try:
|
try:
|
||||||
# layouts = get_ocr_layout(OCR, temp_file.name)
|
# layouts = get_ocr_layout(OCR, temp_file.name)
|
||||||
layouts = DOC_PARSER.parse({"doc": temp_file.name})["layout"]
|
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:
|
if not layouts:
|
||||||
# 无识别结果
|
# 无识别结果
|
||||||
return result
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user