Skip to content

Instantly share code, notes, and snippets.

@frogermcs frogermcs/predict.py
Created May 27, 2019

Embed
What would you like to do?
# Get images and labels batch from validation dataset generator
val_image_batch, val_label_batch = next(iter(valid_generator))
true_label_ids = np.argmax(val_label_batch, axis=-1)
print("Validation batch shape:", val_image_batch.shape)
# >> Validation batch shape: (32, 224, 224, 3)
# Get predictions for images batch
tf_model_predictions = flowers_model.predict(val_image_batch)
print("Prediction results shape:", tf_model_predictions.shape)
# >> Prediction results shape: (32, 5)
# Convert prediction results to Pandas dataframe, for better visualization
tf_pred_dataframe = pd.DataFrame(tf_model_predictions)
tf_pred_dataframe.columns = dataset_labels
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.