Created
October 2, 2018 16:35
-
-
Save joeyism/ed603e16ee658a896fb1383c485bd890 to your computer and use it in GitHub Desktop.
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 | |
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)) | |
outputs = sess.run(module(images, signature="image_feature_vector", as_dict=True)) | |
vector = outputs["default"] | |
vector.shape |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment