Skip to content

Instantly share code, notes, and snippets.

@Mainvooid
Created October 31, 2018 06:56
Show Gist options
  • Select an option

  • Save Mainvooid/2f925b27e9cb9fa8bed5da3067c67293 to your computer and use it in GitHub Desktop.

Select an option

Save Mainvooid/2f925b27e9cb9fa8bed5da3067c67293 to your computer and use it in GitHub Desktop.
xception test #TensorFlow #Python
import numpy as np
import tensorflow as tf
model=tf.keras.applications.xception.Xception(include_top=True,
weights='imagenet',
input_tensor=None,
input_shape=None,
pooling=None,
classes=1000)
image_path="../test_data/bee.jpg"
image = tf.keras.preprocessing.image.load_img(image_path, target_size=(299, 299))
x = tf.keras.preprocessing.image.img_to_array(image)
x = np.expand_dims(x, axis=0)
x = tf.keras.applications.xception.preprocess_input(x)
preds = model.predict(x)
print('Predicted:', tf.keras.applications.xception.decode_predictions(preds, top=3))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment