Skip to content

Instantly share code, notes, and snippets.

@AyishaR
Created January 5, 2021 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AyishaR/c014b95d92b14db3d153fc8b78fbbcfd to your computer and use it in GitHub Desktop.
Save AyishaR/c014b95d92b14db3d153fc8b78fbbcfd to your computer and use it in GitHub Desktop.
# pick random test data sample from one batch
x = random.randint(0, batch - 1)
for i in test_ds.as_numpy_iterator():
img, label = i
plt.axis('off') # remove axes
plt.imshow(img[x]) # shape from (32, 256, 256, 3) --> (256, 256, 3)
output = model.predict(np.expand_dims(img[x],0))[0][0] # getting output; input shape (256, 256, 3) --> (1, 256, 256, 3)
pred = (output > 0.5).astype('int')
print("Prdicted: ", class_names[pred], '(', output, '-->', pred, ')') # Picking the label from class_names base don the model output
print("True: ", class_names[label[x][0].astype('int')])
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment