def draw_images(root_dir):
"""Draw sample images for each class"""
assert len(root_dir) == num_classes # A to J
num_cols = 10
pos = 1
for i in range(num_classes):
target_dir = root_dir[i]
for j in range(num_cols):
plt.subplot(num_classes, num_cols, pos)
random_file = random.choice(os.listdir(target_dir))
image = misc.imread(os.path.join(target_dir, random_file))
plt.imshow(image, cmap=plt.get_cmap('gray'))
plt.axis('off')
pos += 1
plt.show()
评论列表
文章目录