-
Notifications
You must be signed in to change notification settings - Fork 2
/
prediction.py
44 lines (33 loc) · 1.25 KB
/
prediction.py
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import cv2
import os
from model_dev import Predict_Model
def Result(select):
text = ''
for i in range(len(os.listdir('LETTERS'))):
string = ''
char_dict = {}
for j in range(len(os.listdir(f'LETTERS/{i}'))):
img = cv2.imread(f'LETTERS/{i}/{j+1}.png')
img = cv2.cvtColor(img,cv2.COLOR_BGR2RGB)
char = Predict_Model(img)
for l in range(len(select[i])):
if char == select[i][l]:
char_dict[select[i].index(char)] = char
else:
for k in range(len(select[i])):
if k != l:
if char == select[i][k]:
char_dict[k] = char
keys = list(char_dict.keys())
if char not in select[i]:
for val in range(len(select[i])):
if val not in keys:
char_dict[val] = char
keys = list(char_dict.keys())
keys.sort()
#print(keys)
for m in keys:
string += char_dict[m]
string += ' '
text += string
return text;