opencv - 无法在 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
是 a PIL Image
,所以你想要Image.size:
print(x.size)
或者您可以将其设为 Numpy 数组并使用shape
:
na = np.array(x)
print(na.shape)
推荐阅读
- html - 同一行的三个 div 之间有多余的空格
- java - Java Spring Sleuth Zipkin - X-Span-Export 未显示
- javascript - Django画布协调过滤的json对象的联合
- python - 如何避免新项目自动链接到主项目?
- c - C 在 fscanf 中使用 char* 导致错误 Segmentation fault: 11
- ios - 在 Swift (iOS) 中单击单元格内的按钮后替换 tableview 单元格
- python - 如何根据for循环中的if子句更改pandas DataFrame中的值
- javascript - Vanilla JS中具有4个值的按钮
- flutter - 当我不提供数据时,为什么我的 BLoC 不起作用?
- flutter - Flutter Null-Safety 问题:不匹配类型问题