簡體   English   中英

無法獲取 cnn 中的圖像通道

[英]Unable to get channels of images in cnn

有這種形式的數據集

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

有 1500 行。

所以,我隨機嘗試了一些特定的圖像來找到它的編號。 頻道數

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

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

我想找到前 100 張圖像的通道數,該怎么做??

你的x是一個PIL Image ,所以你想要Image.size

print(x.size)

或者您可以將其設為 Numpy 數組並使用shape

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM