import os import sys sys.path.append('PaddleOCR') os.environ["FLAGS_allocator_strategy"] = 'auto_growth' from PaddleOCR.tools.infer.predict_rec import TextRecognizer class OCR: def __init__(self, *args): self.ocr_model = TextRecognizer(*args) def __call__(self, img): [rec_res], _ = self.ocr_model([img]) return rec_res[0], rec_res[1]