Last active
June 29, 2020 15:31
-
-
Save negedng/8cf2d8942457404a594dba9991522897 to your computer and use it in GitHub Desktop.
Image classification snippet with Keras
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
import tensorflow as tf | |
from tensorflow.keras.applications.imagenet_utils import decode_predictions | |
from skimage import io | |
from skimage.transform import resize | |
import numpy as np | |
image_url = 'https://upload.wikimedia.org/wikipedia/commons/b/bb/Kittyply_edit1.jpg' | |
img = io.imread(image_url) | |
img_resized = resize(img, (224,224,3)) | |
model = tf.keras.applications.DenseNet121(input_shape=(224,224,3), | |
weights="imagenet", | |
include_top=True) | |
pred = model.predict(np.expand_dims(img_resized,0)) | |
decode_predictions(pred) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment