批量处理时加入 try catch
This commit is contained in:
parent
4645c39bfb
commit
dcba129694
@ -237,9 +237,12 @@ def ocr_image(image):
|
||||
def batch_ocr(files):
|
||||
results = []
|
||||
for file in files:
|
||||
image = Image.open(file)
|
||||
ocr_result = ocr_image(image)
|
||||
results.append(f"\n\n{ocr_result}\n\n")
|
||||
try:
|
||||
image = Image.open(file)
|
||||
ocr_result = ocr_image(image)
|
||||
results.append(f"\n\n{ocr_result}\n\n")
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
# 将结果写入 Markdown 文件
|
||||
output_file = "ocr_results.txt"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user