Views
No views yet
1import tensorflow as tf
2import numpy as np
3
4# Load the model
5model = tf.saved_model.load("path_to_saved_model")
6
7# Prepare input
8image = tf.keras.preprocessing.image.load_img("digit.png", target_size=(28, 28))
9image = tf.keras.preprocessing.image.img_to_array(image)
10image = image.astype('float32') / 255.0
11image = np.expand_dims(image, axis=0)
12
13# Make prediction
14predictions = model(image)
15predicted_digit = tf.argmax(predictions, axis=1).numpy()[0]