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)