Issue
I try to plot Images with 100,100,1 but got an error like this
TypeError: Invalid shape (100, 100, 1) for image data
here is the code
sample_training_images, _ = next(traindata)
def plotImages(images_arr):
fig, axes = plt.subplots(1, 5, figsize=(20,20))
axes = axes.flatten()
for img, ax in zip( images_arr, axes):
ax.imshow(img)
ax.axis('off')
plt.tight_layout()
plt.plot(images_arr)
plt.show()
plotImages(sample_training_images[:5])
Solution
Replace img
with img[:,:,0]
:
ax.imshow(img[:,:,0], cmap='gray')
And probably remove the plt.plot(images_arr)
Answered By - Quang Hoang
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.