Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Prepare images for TensorFlow requirements
#Convert to expected type: float
img_laptop_tf = np.array(img_laptop).astype(np.float32)
# Setup expected input shape: [1,224,224,3]
img_laptop_tf = np.expand_dims(img_laptop_tf, axis = 0)
# Convert to expected values ranges: [0, 1]
img_laptop_tf = (1.0/255.0) * img_laptop_tf
print( 'Image shape:', img_laptop_tf.shape)
print( 'First few values: ', img_laptop_tf.flatten()[0:4], 'max value: ', np.amax(img_laptop_tf))
# >> Image shape: (1, 224, 224, 3)
# >> First few values: [0.8078432 0.78823537 0.7686275 0.7960785 ] max value: 1.0
# The same for golden retriever img
img_golden_tf = np.array(img_golden).astype(np.float32)
img_golden_tf = np.expand_dims(img_golden_tf, axis = 0)
img_golden_tf = (1.0/255.0) * img_golden_tf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.