Last active
January 23, 2019 10:38
-
-
Save adriaciurana/64b4e2504709cd155732ee009f92d622 to your computer and use it in GitHub Desktop.
Articulo Medium: Parte5d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
raw_results = model.predict(images) | |
results = {} | |
labels = {0: 'cat', 1: 'dog'} | |
text_to_show = {'cat': 'meowww', 'dog': 'bupp'} | |
def drawText(im, text, color): | |
text_size = cv2.getTextSize(text, cv2.FONT_HERSHEY_SIMPLEX, 1, 2)[0] | |
text_pos_x = (im.shape[1] - text_size[0]) // 2 | |
text_pos_y = (im.shape[0] + text_size[1]) // 2 | |
cv2.putText(im, text, (text_pos_x, text_pos_y), cv2.FONT_HERSHEY_SIMPLEX, 1, color, 2) | |
for i in range(raw_results.shape[0]): | |
if(raw_results[i] > 0.5): # Revisar en el Labels de training | |
drawText(real_images[i], text_to_show[labels[1]], (0, 255, 0)) | |
results[path_images[i]] = (labels[1], raw_results[i]) | |
else: | |
drawText(real_images[i], text_to_show[labels[0]], (0, 0, 255)) | |
results[path_images[i]] = (labels[0], 1 - raw_results[i]) | |
cv2.imshow('Image', real_images[i]) | |
cv2.waitKey(0) | |
cv2.destroyAllWindows() | |
for path_im, (name, confidence) in results.items(): | |
print('{0} = {1} ({2})'.format(path_im, name, confidence)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment