Skip to content

Instantly share code, notes, and snippets.

@joeyism
Last active October 2, 2018 16:34
Show Gist options
  • Save joeyism/1d18fc99a716dbccee77d1f6664f6c3c to your computer and use it in GitHub Desktop.
Save joeyism/1d18fc99a716dbccee77d1f6664f6c3c to your computer and use it in GitHub Desktop.
import tensorflow as tf
import tensorflow_hub as hub
import numpy as np
from skimage import data
module = hub.Module("https://tfhub.dev/google/imagenet/mobilenet_v2_140_224/classification/2")
height, width = hub.get_expected_image_size(module)
cat = data.chelsea()
images = np.array([cat])
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
images = tf.cast(images, tf.float32)
images = images/255
images = tf.image.resize_images(images, (height, width))
classes = sess.run(module(images))
np.argmax(classes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment