Closed saurabhbidwai closed 6 years ago
Following code will help you to check custom images
import numpy as np from PIL import Image
img = Image.open('dd.png').convert('L')
new_width = 28 new_height = 28 img = img.resize((new_width, new_height), Image.ANTIALIAS)
arr = np.array(img, np.float32)
flat_arr = arr.ravel()
flat_arr = flat_arr.reshape((1,784))
prob, idx = predict(flat_arr)
print('Predicted: ', characters[idx], ' with probability = ', prob, '%') print('-' * 10)
I want to check whether the model is working fine or not for the image beside this dataset for this I'm using below code but I'm getting a very bad prediction, Am I doing anything wrong?
import numpy as np from PIL import Image
img = Image.open('d.png').convert('RGBA')
new_width = 14 new_height = 14 img = img.resize((new_width, new_height), Image.ANTIALIAS)
arr = np.array(img)
flat_arr = arr.ravel()
type(flat_arr)
prob, idx = predict(flat_arr)
print('Predicted: ', characters[idx], ' with probability = ', prob, '%') print('-' * 10)