Skip to content

Instantly share code, notes, and snippets.

@jruivo-dev
Last active March 10, 2018 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jruivo-dev/0decb79c832e267bb40521c8c15f6dfa to your computer and use it in GitHub Desktop.
Save jruivo-dev/0decb79c832e267bb40521c8c15f6dfa to your computer and use it in GitHub Desktop.
Upload images on Colab, resize and predict classification
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