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

View File

@ -2,7 +2,7 @@
<module type="PYTHON_MODULE" version="4"> <module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager"> <component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" /> <content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="D:\conda_envs\RLP" jdkType="Python SDK" /> <orderEntry type="jdk" jdkName="cnm" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
<component name="PyDocumentationSettings"> <component name="PyDocumentationSettings">

2
.idea/misc.xml generated
View File

@ -3,5 +3,5 @@
<component name="Black"> <component name="Black">
<option name="sdkName" value="pytorh" /> <option name="sdkName" value="pytorh" />
</component> </component>
<component name="ProjectRootManager" version="2" project-jdk-name="D:\conda_envs\RLP" project-jdk-type="Python SDK" /> <component name="ProjectRootManager" version="2" project-jdk-name="cnm" project-jdk-type="Python SDK" />
</project> </project>

2
.idea/vcs.xml generated
View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" /> <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
<mapping directory="$PROJECT_DIR$" vcs="Git" /> <mapping directory="$PROJECT_DIR$" vcs="Git" />
</component> </component>
</project> </project>

View File

@ -22,7 +22,28 @@ def initialize_ocr_model():
return _processor return _processor
def ocr_predict(image_array): 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))