1.问题描述:
用自己标注的数据集训练模型时报错
RuntimeError: Caught RuntimeError in DataLoader worker process 0
RuntimeError: Trying to resize storage that is not resizable
2.解决方案:
设置num_work,default = 0,默认值改为0。
随后出现新的错误RuntimeError: stack expects each tensor to be equal size, but got [3, 224, 224] at entry 0 and [1, 224, 224] at entry 1。
报错路径在torch的collate.py,于是尝试在该文件中return torch.stack之前,把batch中的所有的通道不为3的数据改为通道数为3,如下图注释部分所示。随后报错ValueError: Found input variables with inconsistent numbers of samples: [14450688, 4816896]。切换思路,输出batch内容,发现batch中训练集tensor的通道均是3,然后核对所有数据集发现通道均是3。仔细核对patchcore官方数据集要求,发现ground_truth路径下的图片必须是黑白即通道数为1的图片,我该路径下的图片全是通道为3的图片,解决。