TypeError: Invalid shape (160, 160, 1) for image data

Viewed 6

I have (50, 160, 160, 1) array that I can iterate through. But while showing the image it is showing (160, 160, 1) error.

     14         else:
     15             ax.set_title('z_vec_key_pose = '+str(z[index]))
---> 16         plt.imshow(out[index][j,:,:,:],cmap='gray')
     17 
     18 

5 frames
/usr/local/lib/python3.7/dist-packages/matplotlib/image.py in set_data(self, A)
    697                 or self._A.ndim == 3 and self._A.shape[-1] in [3, 4]):
    698             raise TypeError("Invalid shape {} for image data"
--> 699                             .format(self._A.shape))
    700 
    701         if self._A.ndim == 3:

TypeError: Invalid shape (160, 160, 1) for image data

How to solve it.

0 Answers
Related