Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib.pyplot as plt
- import matplotlib.image as mpimg
- import numpy as np
- def rgb2gray(rgb):
- return np.dot(rgb[...,:3], [0.299, 0.587, 0.114])
- FILE = '0.png'
- source = rgb2gray(mpimg.imread(FILE))
- picture = np.zeros([1,784])
- for i in range(28):
- for j in range(28):
- picture[0][i*28 + j] = source[i][j]
- result = model.predict(picture)
- max_val, max_class = 0, 0
- for i in range(num_classes):
- if result[0][i] > max_val:
- max_val, max_class = result[0][i], i
- print(result[0])
- print('Result:', max_class, '\n')
- print('Picutre from source:')
- plt.imshow(mpimg.imread(FILE))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement