Microsoft Cognitive Services Emotion API. Error: 'Image size is too small or too big.'
Microsoft Cognitive Services Emotion API. Error: 'Image size is too small or too big.'
我注意到认知服务套件中的情感 API 有一个相当奇怪的错误。
只要我发送URL就一切正常。发送图像附件时。我收到此 JSON 错误:
{ error: { code: 'InvalidImageSize', message: 'Image size is too small or too big.' } }
发送较小或较大的版本都无济于事。
发送一张URL同一张图片,突然又好了。
我将附件传输到 API 服务的方式与我为另一个认知服务 API 所做的方式完全相同,即计算机视觉。这对流式附件非常有效。
代码在 GitHub: https://github.com/sebsylvester/botbuilder-mcs
我知道 API 仍在预览中,但这仍然是一个奇怪的问题。
不幸的是,Emotion 和 Face API 不支持分块传输,正如该项目here. The 'workaround' is to load the image bits synchronously prior to making the web request. The code snippet所述:
function _postImageSync(url, image, options) {
return new _Promise(function (resolve, reject) {
request.post({
uri: host + rootPath + url,
headers: {
'Ocp-Apim-Subscription-Key': key,
'Content-Type': 'application/octet-stream'
},
qs: options,
body: fs.readFileSync(image)
}, (error, response) => {
response.body = JSON.parse(response.body);
_return(error, response, resolve, reject);
});
});
}
我注意到认知服务套件中的情感 API 有一个相当奇怪的错误。
只要我发送URL就一切正常。发送图像附件时。我收到此 JSON 错误:
{ error: { code: 'InvalidImageSize', message: 'Image size is too small or too big.' } }
发送较小或较大的版本都无济于事。 发送一张URL同一张图片,突然又好了。
我将附件传输到 API 服务的方式与我为另一个认知服务 API 所做的方式完全相同,即计算机视觉。这对流式附件非常有效。
代码在 GitHub: https://github.com/sebsylvester/botbuilder-mcs
我知道 API 仍在预览中,但这仍然是一个奇怪的问题。
不幸的是,Emotion 和 Face API 不支持分块传输,正如该项目here. The 'workaround' is to load the image bits synchronously prior to making the web request. The code snippet所述:
function _postImageSync(url, image, options) {
return new _Promise(function (resolve, reject) {
request.post({
uri: host + rootPath + url,
headers: {
'Ocp-Apim-Subscription-Key': key,
'Content-Type': 'application/octet-stream'
},
qs: options,
body: fs.readFileSync(image)
}, (error, response) => {
response.body = JSON.parse(response.body);
_return(error, response, resolve, reject);
});
});
}