-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark.py
More file actions
27 lines (23 loc) · 896 Bytes
/
Copy pathbenchmark.py
File metadata and controls
27 lines (23 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import pandas as pd
import os
import cv2
import time
from recognizer import Recognizer
recog = Recognizer()
res = recog.det_model.val(data="C:\\Users\\USER\\Downloads\\Car license plate detection.v1i.yolov5pytorch\\data.yaml")
print(res.results_dict)
metrics = [0, 0]
path = "C:\\Users\\USER\\Downloads\\ocr-test"
started_at = time.time()
tests_count = 0
for k, name in enumerate(os.listdir(path)):
for res in recog(cv2.imread(f'{path}\\{name}')):
## print(res[0], name[:-4], res[0]==name[:-4], res[-1])
if res[0]==name[:-4]:
metrics[0] += 1
metrics[1] += 1
## if k%100==0:
## print(metrics, f"round(metrics[0]*100/metrics[1], 2)%")
tests_count += 1
print(f'Totally correct are {metrics[0]}/{metrics[1]}', f"{round(metrics[0]*100/metrics[1], 2)}%")
print(f'Finished recognizing {tests_count} pics in {round(time.time()-started_at, 2)} s')