From 94eca0ebeb8e76b481b259d76fa865fefe20c382 Mon Sep 17 00:00:00 2001 From: Zhao Zuohong Date: Sun, 13 Aug 2023 20:18:55 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8run=5Fin=5Fexecutor=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E8=AF=86=E5=88=AB=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/riic_report_analysis.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/riic_report_analysis.py b/apps/riic_report_analysis.py index 9132dca..d97bc4f 100644 --- a/apps/riic_report_analysis.py +++ b/apps/riic_report_analysis.py @@ -1,6 +1,8 @@ from pepperbot.core.message.chain import MessageChain, Image, Text from paddleocr import PaddleOCR import os +import asyncio +import functools ocr = PaddleOCR(use_angle_cls=False, use_gpu=False) @@ -14,7 +16,11 @@ class RIICReportAnalysis: img_path = await img_seg.download() print(f"Image saved to {img_path}") - ocr_text = ocr.ocr(img_path, cls=False) + loop = asyncio.get_running_loop() + + ocr_text = await loop.run_in_executor( + None, functools.partial(ocr.ocr, img_path, cls=False) + ) print(ocr_text) os.remove(img_path)