27 lines
707 B
Python
27 lines
707 B
Python
import numpy as np
|
||
from paddleocr import TextRecognition
|
||
import cv2
|
||
|
||
class OCRProcessor:
|
||
def __init__(self):
|
||
self.model = TextRecognition(model_name="PP-OCRv5_server_rec")
|
||
print("OCR模型初始化完成(占位)")
|
||
|
||
def predict(self, image_array):
|
||
# 保持原有模型调用方式
|
||
output = self.model.predict(input=image_array)
|
||
# 结构化输出结果
|
||
results = output[0]["rec_text"]
|
||
placeholder_result = results.split(',')
|
||
return placeholder_result
|
||
|
||
# 保留原有函数接口
|
||
_processor = OCRProcessor()
|
||
|
||
def initialize_ocr_model():
|
||
return _processor
|
||
|
||
def ocr_predict(image_array):
|
||
return _processor.predict(image_array)
|
||
|