使用SageMaker和AugmentedManifestFile创建MxNet目标检测训练任务遇阻
SageMaker MxNet目标检测训练任务解析错误排查
我用SageMaker预构建的**Vision - Object Detection (MxNet)**模型,结合标注任务生成的AugmentedManifestFile创建训练任务。相关PNG图像存储在S3中,已将标注生成的output.manifest拆分为training.manifest(含147张带标注图像)和validation.manifest。配置时指定S3数据类型为AugmentedManifestFile,对应属性为source-ref和labelling-job-name,但始终报错,最新错误信息:
ClientError: Unable to parse record. Please make sure input data is in correct recordio format. , exit code: 2
已尝试的操作:
- 修改文件输入模式为
file和pipe - 添加
training_annotation与validation_annotation通道 - 将PNG文件转换为recordio格式
- 参考GitHub示例调整配置
标注示例(单条JSON记录):
{ "source-ref":"s3://bucket/image.png", "labelling-job-name":{ "image_size":[{ "width":256, "height":256, "depth":3 }], "annotations":[ { "class_id":0, "top":42, "left":52, "height":35, "width":20 }, { "class_id":0, "top":155, "left":174, "height":17, "width":33 }, { "class_id":0, "top":189, "left":111, "height":12, "width":29 }, { "class_id":0, "top":189, "left":58, "height":15, "width":32 }, { "class_id":0, "top":183, "left":0, "height":14, "width":31 } ] }, "labelling-job-name-metadata":{ "objects":[ {"confidence":0}, {"confidence":0}, {"confidence":0}, {"confidence":0}, {"confidence":0} ], "class-map":{"0":"label1"}, "type":"groundtruth/object-detection", "human-annotated":"yes", "creation-date":"2024-08-20T12:51:06.418286", "job-name":"labeling-job/labelling-job-name" } }
可能的解决方向
- 校验Manifest文件格式:确保
training.manifest和validation.manifest是JSON Lines格式——每一行是一个独立的JSON对象,不能用数组包裹所有记录,行尾也不能有多余逗号。这是最常见的解析错误原因。 - 匹配模型字段映射:在配置AugmentedManifestFile时,需明确指定
attribute_names为["source-ref", "labelling-job-name"],确保模型能正确识别标注字段。同时检查模型是否要求标注字段的结构完全匹配预期,比如image_size的格式、annotations中的字段名是否符合MxNet目标检测模型的要求。 - 调整通道配置:预构建模型的训练通道需使用标准名称,训练通道应为
train,验证通道应为validation,而非自定义的training_annotation。通道类型设置为AugmentedManifestFile时,无需额外提供标注通道,模型会自动从manifest中读取标注。 - 放弃手动转换RecordIO:使用AugmentedManifestFile模式时,SageMaker会自动处理PNG图像和标注的加载,无需手动将图片转为recordio格式,该操作可能导致数据格式冲突。
- 验证S3权限:确保训练执行角色拥有访问manifest文件和图像所在S3桶的
s3:GetObject权限,权限不足可能导致数据读取异常,表现为解析错误。
内容的提问来源于stack exchange,提问作者champagnearden
相关产品推荐
相关产品推荐

