Rate limit exceeded in Face API

[亡魂溺海] 提交于 2019-12-11 04:55:38

问题


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.


回答1:


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

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
}

It is also available as a nuget package.



来源:https://stackoverflow.com/questions/49359508/rate-limit-exceeded-in-face-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!