gpt4 book ai didi

node.js - AWS SageMaker - 请求的图像格式无效

转载 作者:太空宇宙 更新时间:2023-11-03 22:22:39 25 4
gpt4 key购买 nike

我正在使用 NodeJS + AWS SDK 测试 Amazon SageMaker 服务,并在基于 this 创建新模型和终端 Node 之后例如(笔记本中一切正常,包括对端点的请求),我尝试从 Express 应用程序创建请求,但收到以下错误:

Error during recognition: { InvalidImageFormatException: Request has Invalid image format
at Request.extractError (/Users/pdonaire/Documents/workspaceNode/trsps-controller/node_modules/aws-sdk/lib/protocol/json.js:48:27)
at Request.callListeners (/Users/pdonaire/Documents/workspaceNode/trsps-controller/node_modules/aws-sdk/lib/sequential_executor.js:109:20)
at Request.emit (/Users/pdonaire/Documents/workspaceNode/trsps-controller/node_modules/aws-sdk/lib/sequential_executor.js:81:10)
at Request.emit (/Users/pdonaire/Documents/workspaceNode/trsps-controller/node_modules/aws-sdk/lib/request.js:683:14)
at Request.transition (/Users/pdonaire/Documents/workspaceNode/trsps-controller/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/Users/pdonaire/Documents/workspaceNode/trsps-controller/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /Users/pdonaire/Documents/workspaceNode/trsps-controller/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/Users/pdonaire/Documents/workspaceNode/trsps-controller/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/Users/pdonaire/Documents/workspaceNode/trsps-controller/node_modules/aws-sdk/lib/request.js:685:12)
at Request.callListeners (/Users/pdonaire/Documents/workspaceNode/trsps-controller/node_modules/aws-sdk/lib/sequential_executor.js:119:18)
at Request.emit (/Users/pdonaire/Documents/workspaceNode/trsps-controller/node_modules/aws-sdk/lib/sequential_executor.js:81:10)
at Request.emit (/Users/pdonaire/Documents/workspaceNode/trsps-controller/node_modules/aws-sdk/lib/request.js:683:14)
at Request.transition (/Users/pdonaire/Documents/workspaceNode/trsps-controller/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/Users/pdonaire/Documents/workspaceNode/trsps-controller/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /Users/pdonaire/Documents/workspaceNode/trsps-controller/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/Users/pdonaire/Documents/workspaceNode/trsps-controller/node_modules/aws-sdk/lib/request.js:38:9)

message: 'Request has Invalid image format',
code: 'InvalidImageFormatException',
time: 2018-09-10T04:42:07.530Z,
requestId: 'de3a04ff-b4b3-11e8-9bd8-8b88f803570c',
statusCode: 400,
retryable: false,
retryDelay: 55.860720412209794 }

我的代码如下:

export function sendRequestToSageMaker(base64image) {
const params = {
Body: new Buffer(base64image, 'base64') , /* Strings will be Base-64 encoded on your behalf */ /* required */
EndpointName: 'DEMO-imageclassification-ep--XXXX', /* required */
Accept: 'application/json',
ContentType: 'application/x-image'
};
sagemakerruntime.invokeEndpoint(params, function(err, data) {
if (err)
console.error(err, err.stack); // an error occurred
else
console.log(data); // successful response
});
return null;
}

base64image 是来 self 使用 Postman 使用 JSON 和单个 photo 属性执行的请求的 req.body.photo使用我用 base64-image.de 制作的 base64 字符串网站。

任何帮助都会有帮助!太感谢了! :-)

最佳答案

SageMaker 图像分类算法仅支持图像作为有效负载,不支持 base64 编码有效负载,这就是您看到 InvalidImageFormatException 的原因。

关于node.js - AWS SageMaker - 请求的图像格式无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52251328/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com