Last active
October 23, 2019 03:28
-
-
Save Tusharsharma118/6441b6dd5162acf9e8d170a6f03a14ab to your computer and use it in GitHub Desktop.
print a specified number of random images from the provided image list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_random_images(images, labels, number_of_images_to_display, color_map='hsv'): | |
if number_of_images_to_display % 4 == 0: | |
num_rows = number_of_images_to_display / 4 | |
else: | |
num_rows = int(number_of_images_to_display / 4) + 1 | |
random_indices = [np.random.randint(0, images.shape[0]) for n in range(number_of_images_to_display)] | |
# print(random_indices) | |
for counter in range(number_of_images_to_display): | |
index = random_indices[counter] | |
plt.subplot(num_rows, 4, counter + 1) | |
# plt.axis('off') | |
plt.imshow(images[index], cmap=color_map) | |
plt.title('Class :{0}, Class Count: {1} '.format(labels[index], list(labels).count(labels[index]))) # np.count_nonzero(labels == labels[index]))) | |
plt.show() | |
print('Image Dimensions: {0}, Min Pixel: {1}, Max Pixel: {2}'.format(images[index].shape, images[index].min(),images[index].max())) | |
plt.subplots_adjust(wspace=1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment