简体   繁体   English

Amazon SageMaker 不支持的媒体类型:图像/jpeg

[英]Amazon SageMaker Unsupported Media Type: image/jpeg

I trained my own model using Tensorflow and Keras for image classification and I'm trying to deploy and use it with Amazon's SageMaker.我使用 Tensorflow 和 Keras 训练了自己的 model 进行图像分类,我正在尝试将其与亚马逊的 SageMaker 一起部署和使用。 I went through the process of converting the mymodel.h5 file into a mymodel.tar.gz file and moving it to the SageMaker S3 bucket.我完成了将mymodel.h5文件转换为mymodel.tar.gz文件并将其移动到 SageMaker S3 存储桶的过程。 Then, following a tutorial I created the SageMaker model using:然后,按照教程,我使用以下方法创建了 SageMaker model:

from sagemaker.tensorflow.model import TensorFlowModel
sagemaker_model = TensorFlowModel(model_data = 's3://' + sagemaker_session.default_bucket() + '/model/model.tar.gz',
                                  role = role,
                                  framework_version = '1.12',
                                  entry_point = 'train.py')

And created the endpoint to access the model:并创建端点以访问 model:

predictor = sagemaker_model.deploy(initial_instance_count=1,
                                   instance_type='ml.m4.xlarge')

Now, since the point of creating this model was for image classification I'm trying to pass the image to my endpoint but have been getting a response of Received client error (415) from primary with message "{"error": "Unsupported Media Type: image/jpeg"}" .现在,由于创建此 model 的目的是为了图像分类,我正在尝试将图像传递到我的端点,但已经Received client error (415) from primary with message "{"error": "Unsupported Media Type: image/jpeg"}" After reading up I feel like I may need to do some more work to have access to the image/jpeg content type as it seems like the defaults are application/json , text/libsvm , and text/csv .读完之后,我觉得我可能需要做更多的工作才能访问image/jpeg内容类型,因为默认值似乎是application/jsontext/libsvmtext/csv

Assuming your model has been converted into TF Serving Format, you can confirm the input your model expects using the saved_model_cli .假设您的 model 已转换为 TF 服务格式,您可以使用saved_model_cli确认您的 model 期望的输入。 Please see this example which depicts how to use the saved_model_cli .请参阅描述如何使用saved_model_cli示例 Kindly note how a prediction is made by converting an image to a tensor .请注意如何通过将图像转换为张量来进行预测。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM