Добавил скрипты для валидации.

This commit is contained in:
2025-07-21 19:03:10 +03:00
parent 7c0ed23362
commit 206c2a6877
2 changed files with 54 additions and 0 deletions

27
scripts/rec_validation.py Normal file
View File

@@ -0,0 +1,27 @@
import os
from paddleocr import TextRecognition
ocr = TextRecognition(
model_name="PP-OCRv5_server_rec"
# model_dir="output/PP-OCRv5_server_rec_vin"
)
with open("train_data/val.txt", "r") as label_file:
lines = label_file.readlines()
total = len(lines)
matches, mismatches = 0, 0
for idx, line in enumerate(lines, start=1):
file_name, label = line.split("\t")
label = label.strip()
path = os.path.join("train_data", os.path.join("images", file_name))
result = ocr.predict(path)
print(f"{idx}/{total} ", end="")
if result[0]["rec_text"] and result[0]["rec_text"] == label:
print(f"match {label}")
matches += 1
else:
print(f"mismatch {label}")
mismatches += 1
print(f"{matches} matches of {total}")
print(f"{mismatches} mismatches of {total}")