ValueError: cannot reshape array of size 571428 into shape (3,351,407)
在训练CTPN的时候,数据集处理的 cv2.dnn.blobFromImage 之后的reshape报的这个错。原因是有一张图像它的通道数乘以宽和高等于571428,不等于3 * 351 * 407,因此不能reshape到(3,351,407)。
算了一下 571428 = 4 * 351 * 407 ,说明这个图莫名其妙地是个4通道的图像。然后断点找了一下这张图,发现它竟然是一个png格式的后缀名jpg的假jpg,多了一个通道。因为png是RGBA,jpg是RGB。
解决:进行图像转换,把它转换为RGB的三通道图。在这
def __getitem__(self, idx, scale=600, maxScale=900):
img_name = self.img_names[idx]
img_path = os.path.join(self.datadir, img_name)
img = Image.open(img_path)
img, rate = resize_img(img