Skip to content

Instantly share code, notes, and snippets.

@joeyism
Last active October 2, 2018 16:09
Show Gist options
  • Save joeyism/ff57b94997e41b8da7bb2f315662479d to your computer and use it in GitHub Desktop.
Save joeyism/ff57b94997e41b8da7bb2f315662479d to your computer and use it in GitHub Desktop.
import tensorflow as tf
import tensorflow_hub as hub
import urllib
import numpy as np
from skimage import data, transform
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()
cat = transform.resize(cat, (height, width))
images = module(np.array([cat]))
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
classes = sess.run(images)
np.argmax(classes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment