Skip to content

Instantly share code, notes, and snippets.

@hzitoun
Created May 18, 2020 16:56
Show Gist options
  • Save hzitoun/f12a9ada18394be271fa849d3a0c2568 to your computer and use it in GitHub Desktop.
Save hzitoun/f12a9ada18394be271fa849d3a0c2568 to your computer and use it in GitHub Desktop.
Source code for medium story šŸš€Serve a TensorFlow 2 Deep Learning Image Classifier as a REST API and Dockerize it! (with GPUĀ support)
test_image = read_image("../data/raw/test/82_automobile.png", image_size)
plt.imshow(test_image)
plt.title('test image')
plt.show()
pred_softmax = model.predict(test_image.reshape(1, image_size[0], image_size[1], 3))
pred_class_index = np.argmax(pred_softmax, axis=1)
target_names = ['airplane', 'automobile', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck']
print("CNN sees", target_names[pred_class_index.item()])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment