This commit is contained in:
2025-09-01 00:01:38 +08:00
parent 8eef0d9414
commit afba7af80b
4 changed files with 25 additions and 4 deletions

View File

@@ -22,7 +22,28 @@ def initialize_ocr_model():
return _processor
def ocr_predict(image_array):
return _processor.predict(image_array)
# 获取原始预测结果
raw_result = _processor.predict(image_array)
# 将结果合并为字符串(如果是列表的话)
if isinstance(raw_result, list):
result_str = ''.join(raw_result)
else:
result_str = str(raw_result)
# 过滤掉'·'字符
filtered_str = result_str.replace('·', '')
# 转换为字符列表
char_list = list(filtered_str)
# 确保返回长度为7的列表
if len(char_list) >= 7:
# 如果长度大于等于7取前7个字符
return char_list[:7]
else:
# 如果长度小于7用空字符串补齐到7位
return char_list + [''] * (7 - len(char_list))