Skip to content

Commit

Permalink
reads digits from canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhallinan88 committed Apr 16, 2020
1 parent 4ea5d91 commit 26e0f63
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,10 @@ def mnist():

img = Image.open(data)
img_arr = np.array(img, dtype='float32')
#with open('shapes.log','w') as fh:
# fh.write("Shape: {}\n".format(img_arr.shape))
# rgb_weights = [0.2989, 0.5870, 0.1140]
# grayscale_image = np.dot(img_arr[...,:3], rgb_weights)
# fh.write("Gray Shape: {}".format(grayscale_image.shape))
img_arr_sh = img_arr.reshape(1, 28, 28, 1)
res = cv2.resize(img_arr, dsize=(28,28), interpolation=cv2.INTER_CUBIC)
gray = cv2.cvtColor(res, cv2.COLOR_BGR2GRAY)
img_arr_sh = gray.reshape(1, 28, 28, 1)

prediction = model.predict(img_arr_sh)
result = np.argmax(prediction)

Expand Down

0 comments on commit 26e0f63

Please sign in to comment.