项目场景:
通过mindspore创建自定义训练数据集时,设置批处理数据,报错。
RuntimeError: Exception thrown from dataset pipeline. Refer to 'Dataset Pipeline Error Message'.
bug 详细:[ERROR] MD(,220c,?):2024-7-25 15:43:40 [mindspore\ccsrc\minddata\dataset\util\task_manager.cc:227] mindspore::dataset::TaskManager::InterruptMaster] MindSpore dataset is terminated with err msg: Exception thrown from dataset pipeline. Refer to 'Dataset Pipeline Error Message'. Inconsistent batch shapes, batch operation expects same shape for each data row, but got inconsistent shape in column 0, expected shape for this column is:<3,231,349>, got shape:<3,314,362>
解释:MindSpore数据集终止并显示错误消息:数据集管道抛出异常。请参阅“数据集管道错误消息”。
原因分析:批处理形状不一致,批处理操作期望每个数据行的形状相同,但在第 0 列中出现不一致的形状,此列的预期形状为:❤️,231,349>,得到的形状:❤️,314,362>。
总之,是因为自定义数据中图像尺寸不一致,没有缩放裁剪一致,才不能batch化。
解决方案:
-
调整数据中的图像为统一尺寸;需要在transform.Compose中增加回调函数:
mindspore.dataset.vision.Resize对输入图像使用给定的尺寸,默认是mindspore.dataset.vision.Inter 插值方式去调整为给定的尺寸大小。 -
如果为目标检测数据集,需要在transform.Compose中增加回调函数:
vision.ResizeWithBBox(100)(func_data, func_bboxes)
Resize the input image to the given size and adjust bounding boxes accordingly.
注意,如果你是目标检测,标签带框的这类数据,需要同步调整标签。
mindspore.dataset.vision.ResizeWithBBox将输入图像调整为给定的尺寸大小并相应地调整边界框的大小。
例如:

665

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



