gpt4 book ai didi

opencv - 无法在 cnn 中获取图像 channel

转载 作者:行者123 更新时间:2023-12-02 17:17:37 25 4
gpt4 key购买 nike

这种形式有一个数据集

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 行。
所以,我随机尝试了一些特定的图像来找到它的编号。 channel 数
 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 张图像的 channel 数,该怎么做?

最佳答案

您的 xPIL Image , 所以你想要 Image.size :

print(x.size)
或者您可以将其设为 Numpy 数组并使用 shape :
na = np.array(x)
print(na.shape)

关于opencv - 无法在 cnn 中获取图像 channel ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63958272/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com