Last active
March 10, 2018 22:46
-
-
Save jruivo-dev/0decb79c832e267bb40521c8c15f6dfa to your computer and use it in GitHub Desktop.
Upload images on Colab, resize and predict classification
This file contains hidden or 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
from google.colab import files | |
uploaded = files.upload() | |
for fn in uploaded.keys(): | |
print('User uploaded file "{name}" with length {length} bytes'.format( | |
name=fn, length=len(uploaded[fn]))) | |
dog = uploaded['dog.jpg'] | |
img = cv2.imdecode(np.frombuffer(dog, np.uint8), cv2.IMREAD_COLOR) | |
from scipy.misc import imresize | |
newImg = imresize(img,(140,140)) | |
plt.imshow(newImg) | |
plt.show() | |
# Add one extra dimension due to the input shape restriction | |
newImg = np.expand_dims(newImg, axis=0) | |
model2.predict(newImg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment