Let's apply our model on the withheld testing set to see how well it does. Remember, our model has never seen the images and subjects from the testing set, so this is a good measurement of its real-world performance.
First, we pick two images from the same subject, plot them out side by side, and apply the model to this pair of images:
idx1, idx2 = 21, 29img1 = np.expand_dims(X_test[idx1], axis=0)img2 = np.expand_dims(X_test[idx2], axis=0)fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(10,7))ax1.imshow(np.squeeze(img1), cmap='gray')ax2.imshow(np.squeeze(img2), cmap='gray')for ax in [ax1, ax2]: ax.grid(False) ax.set_xticks([]) ax.set_yticks([])dissimilarity = model.predict([img1, img2])[0][0]fig.suptitle("Dissimilarity ...