Rishavv
Rishavv

Reputation: 293

Unable to get channels of images in cnn

there is a dataset in this form

images                                              label
C:/Users/Drive/training/real/abs322b.png              0
C:/Users/Drive/training/fake/gd3fsdf.png              1
C:/Users/Drive/training/real/xcs2zxd.png              0
C:/Users/Drive/training/fake/mnm3222.png              1

There are 1500 rows.

So, i have randomly tried with some particular image to find its no. of channels

 x=Image.open(dataset['image'][1100])
 x.shape
 AttributeError: 'PngImageFile' object has no attribute 'shape'

 x.ndim
 AttributeError: 'PngImageFile' object has no attribute 'ndim'

I want to find the number of channels of first 100 images, how to do that ??

Upvotes: 0

Views: 70

Answers (1)

Mark Setchell
Mark Setchell

Reputation: 207415

Your x is a PIL Image, so you want Image.size:

print(x.size)

Or you can make it a Numpy array and use shape:

na = np.array(x)
print(na.shape)

Upvotes: 1

Related Questions