API中超出了速率限制

API中超出了速率限制

本文介绍了Face API中超出了速率限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用面部表情API而不是使用Task.Delay(1000)超出速率限制时该怎么办?
我有大约50条记录,并在2秒钟内检测/识别/验证.对于identifyasync,我将置信度阈值设置为0.0f,返回的最大候选数为50.我尝试使用Task.Delay(1000)并减少了候选数,但这无助于解决我的问题.

What should I do when i encountered rate limit exceeded for face api other than using Task.Delay(1000)?
I have about 50 records and detect/identify/verify in 2 seconds. For the identifyasync, I set the confidence threshold to be 0.0f and the max number of candidates returned to be 50. I tried to use Task.Delay(1000) and reduced the number of candidates, but it doesn't help to solve my problem.

由于我是新来的,请给我一些有关如何解决此问题的建议.

Please give me advice on how to resolve this issue as i'm new to this.

推荐答案

我写了一个库 RateLimiter 处理此类约束.它是可组合的,异步的和可取消的.

I wrote a library RateLimiter to handle this kind of constraints. It is composable, asynchroneous and cancellable.

Face API配额限制为每秒10个调用,因此您可以编写:

Its seems that Face API quota limit of 10 calls per second, so you can write:

var timeconstraint = TimeLimiter.GetFromMaxCountByInterval(10, TimeSpan.FromSeconds(1));

for(int i=0; i<1000; i++)
{
   await timeconstraint.Perform(DoFaceAPIRequest);
}

private Task DoFaceAPIRequest()
{
   //send request to Face API
}

它也可以作为 nuget包使用.

这篇关于Face API中超出了速率限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 16:57