Problem location: 在训练的图片集中,混入了几张4通道的图片,将这几张图片删除后问题解除。
使用cv2中img.shape列出非3通道图片的文件名:
import os
import numpy as np
import cv2
if __name__ == '__main__':
root_dir = r'D:\WData\Workspace\springdemo\images\table_images\1.0\all_table'
name = root_dir.split('\\')[-1]
file_names = sorted(os.listdir(root_dir))
for file in file_names:
if file.endswith('.png'):
img = cv2.imdecode(np.fromfile(os.path.join(root_dir, file), dtype=np.uint8), -1)
size = img.shape
if size[2] != 3:
print("通道"+ str(size[2]) + file)
# os.remove(file)
supplementary knowledge
CV2
cv2 is OpenCV-python implements.
Win10 + anaconda安装cv2
pip install opencv-python
Images and Channels
Images are often referred to as RGB images that use channels. Channels are a very simple idea that is easy to use.
RGB Explained
Much of how i

训练图片集中混入4通道图片导致问题,移除这些图片后问题解决。使用cv2检查非3通道图片,cv2是OpenCV-Python的实现,主要讨论了图片的通道概念,RGB图像由红绿蓝三个通道组成,每个像素由三个数值控制对应显示器的亮度,影响最终颜色。了解并处理不同通道数的图片对于计算机视觉和神经网络训练至关重要。
最低0.47元/天 解锁文章
3483

被折叠的 条评论
为什么被折叠?



