Microsoft认知服务情感API.错误:“图像尺寸太小或太大". [英] Microsoft Cognitive Services Emotion API. Error: 'Image size is too small or too big.'

查看:64
本文介绍了Microsoft认知服务情感API.错误:“图像尺寸太小或太大".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到Cognitive Services套件中的Emotion API出现了一个非常奇怪的错误.

I have noticed a rather strange error with the Emotion API from the Cognitive Services suite.

一切正常,只要我发送URL即可.发送图像附件时.我收到此JSON错误: { error: { code: 'InvalidImageSize', message: 'Image size is too small or too big.' } }

Everything works just fine as long as I send it URL's. When sending it image attachments. I receive this JSON error: { error: { code: 'InvalidImageSize', message: 'Image size is too small or too big.' } }

发送较小或较大的版本没有帮助. 发送相同图片的网址,然后突然又可以正常工作了.

Sending it smaller or larger versions does not help. Send a URL of the same image, and suddenly it works fine again.

我以与其他认知服务API(即计算机视觉)完全相同的方式将附件流传输到API服务.这对流式附件非常有用.

I stream the attachment to the API service in the exact same way I do for another Cognitive Services API, namely Computer Vision. And that works great with streamed attachments.

代码在GitHub上: https://github.com/sebsylvester/botbuilder-mcs

The code is on GitHub: https://github.com/sebsylvester/botbuilder-mcs

我知道API仍在预览中,但这仍然是一个奇怪的问题.

I know the APIs are still in preview, but this is still a weird issue.

推荐答案

很遗憾,Emotion和Face API不支持分块传输,如摘录 :

Unfortunately, the Emotion and Face APIs do not support chunked transfers, as noted here. The 'workaround' is to load the image bits synchronously prior to making the web request. The code snippet from that project is thus:

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);
        });
    });
}

这篇关于Microsoft认知服务情感API.错误:“图像尺寸太小或太大".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆