Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run predictions on saved images/drawings ? #19

Open
shubhank008 opened this issue Jun 6, 2019 · 4 comments
Open

How to run predictions on saved images/drawings ? #19

shubhank008 opened this issue Jun 6, 2019 · 4 comments

Comments

@shubhank008
Copy link

Tried to make a prediction on a .jpg/.png saved image of random drawings (from quick draw data set, directly saved the image).
However, the prediction came off quite wrong and can't seem to get it working and my guess is on due to the image processing before feeding to the model.

This is what I am using

from PIL import Image
import cv2
import matplotlib.pyplot as plt
from random import randint
%matplotlib inline  

clock = qd.get_drawing("clock")
apple = clock

img = apple.image.convert("L")
img = img.resize((28,28),Image.BILINEAR)
img = np.array(img)
img = cv2.bitwise_not(img)


img = img.reshape(28,28,1)
img = img.astype('float32')
img /= 255.0

print(img.shape)
plt.imshow(img.squeeze()) 
print(img)

Yellowish image is the original one in npy format, the other is processed using above code.

chrome_2019-06-06_10-01-14

chrome_2019-06-06_10-01-27

@zaidalyafeai
Copy link
Owner

@shubhank008, can you explain more ? which model are you using ? Are you using this notebook ?

@shubhank008
Copy link
Author

@shubhank008, can you explain more ? which model are you using ? Are you using this notebook ?

Yes, exactly that. Initially I tried to re-write how you were doing inference on drawings in web app (tensorflowjs) to python (using saved drawing images .jpg .png) but that did not work, then I started trying various image pre-processing alternatives as I am pretty sure its the whole image reading, processing and feeding part that I am messing up.

@shubhank008
Copy link
Author

@zaidalyafeai anything ?

@zyqq
Copy link

zyqq commented Jul 12, 2022

Did you find a solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants