Created
September 13, 2020 15:56
-
-
Save arjun921/7cc4891c481f50f4733bdf65d6359ff7 to your computer and use it in GitHub Desktop.
Tensorflow 2.0 predict from image URL
This file contains 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
import numpy as np | |
from tensorflow.keras.preprocessing import image | |
from tensorflow.keras.utils import get_file | |
img_url = 'paste-url-here' | |
random_string_for_file_name = 'test_image' | |
img = image.load_img(get_file(random_string_for_file_name,img_url),target_size=(150,150)) | |
img_arr = image.img_to_array(img) | |
img_arr = np.expand_dims(img_arr, axis=0) | |
images = np.vstack([img_arr]) | |
classes = model.predict(images, batch_size=10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment