# Prediction
samples2 = detector.sliding_window(detection2)
samples_tf2 = samples2.reshape(samples2.shape[0], 40, 30, 1)
samples_tf2 = samples_tf2.astype('float32')

print('Start detection example image: ', detection2)
predictions2 = model.predict(samples_tf2)
detection_num = helpers.char_to_num(detection_label)

print('*****************************************************')
print('Overall Prediction', predictions2)
print('-----------------------------------------------------')
print('Accuracy for character', detection_label, ' is ',
      predictions2[0][detection_num] * 100, '%')
print('*****************************************************')

value_list2 = []
for pred in predictions2:
    i = 0
    for value in pred:
        if value > 0.5:
            value_list2.append(helpers.num_to_char(i))
        i += 1

predictCount = Counter(value_list2)
print('\nPrediction result', predictCount)
print('\nResults in Probability\n')
for k, v in predictCount.items():
    print(k.upper(), ':', v / len(predictions2))
Exemplo n.º 2
0
cax = ax.matshow(cm)
pl.title('Confusion matrix of the classifier')
fig.colorbar(cax)
ax.set_xticklabels([''] + labels)
ax.set_yticklabels([''] + labels)
pl.xlabel('Predicted')
pl.ylabel('True')
pl.show()

samples2 = detector.sliding_window(detection2)
samples_tf2 = samples2.astype('float32')
print('\nStart detection on example image: ', detection2)
predictions2 = clf.predict(samples_tf2)
value_list2 = []

print('*****************************************************')
print('Overall Prediction', predictions2)
print('*****************************************************')

for pred2 in predictions2:
	value_list2.append(helpers.num_to_char(pred2))
    
predictCount = Counter(value_list2)
print('\nPrediction result', predictCount)

print('\nResults in Probability\n')
for k, v in predictCount.items():
	print(k.upper(), ':', v/len(predictions2))

out = max(value_list2,key=value_list2.count)
print('\nMost Predicted Character is', out)