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}")