Opt: Set rec_batch_num=1 for faster ocr

This commit is contained in:
LmeSzinc 2023-09-08 23:00:56 +08:00
parent 16f4f061c1
commit f7bc6980f9
2 changed files with 8 additions and 3 deletions

View File

@ -1,4 +1,4 @@
from pponnxcr import TextSystem
from pponnxcr import TextSystem as TextSystem_
from module.base.decorator import cached_property
from module.exception import ScriptError
@ -36,6 +36,12 @@ def model2lang(model: str) -> str:
return model
class TextSystem(TextSystem_):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.text_recognizer.rec_batch_num = 1
class OcrModel:
def get_by_model(self, model: str) -> TextSystem:
try:

View File

@ -4,7 +4,6 @@ from datetime import timedelta
import cv2
from ppocronnx.predict_system import BoxedResult
from pponnxcr import TextSystem
import module.config.server as server
from module.base.button import ButtonWrapper
@ -12,7 +11,7 @@ from module.base.decorator import cached_property
from module.base.utils import area_pad, corner2area, crop, float2str
from module.exception import ScriptError
from module.logger import logger
from module.ocr.models import OCR_MODEL
from module.ocr.models import OCR_MODEL, TextSystem
from module.ocr.utils import merge_buttons