Hi, we are continuing to improve Form Recognizer performance on analyze requests. Currently there is no client side configuration to improve performance. We are working on improving response time, in instances where there are a lot of concurrent requests in a region it is not abnormal to see response times of 10+ seconds. If the you are sending large documents, it would help performance if you specify the pages to be analyzed to reduce the number of pages analyzed. Hope this helps!
Azure Form Recognizer performance
Anonymous
We are investigating the possibility of including document OCR into our product offering and would prefer to use Azure Form Recognizer. However, we are experiencing very slow performance when using custom or composed models for document OCR - often in excess of 10 seconds. Is this normal? If not, how can we improve performance. This is on an S0 tier on a local region and we are using Azure.AI.FormRecognizer v3.1.1 .NET client:
string endpoint = @"https://blabla.cognitiveservices.azure.com/";
string licenseKey = "123456";
var credential = new AzureKeyCredential(licenseKey);
FormRecognizerClient client = new FormRecognizerClient(new Uri(endpoint), credential);
FormRecognizeResponse response = new FormRecognizeResponse()
{
ImageID = imageID,
ImageTypeID = imageTypeID,
ImageTypeName = imageTypeName
};
//https://learn.microsoft.com/en-us/dotnet/api/overview/azure/ai.formrecognizer-readme
//ID Documents sample: https://github.com/Azure/azure-sdk-for-net/blob/Azure.AI.FormRecognizer_3.1.1/sdk/formrecognizer/Azure.AI.FormRecognizer/samples/Sample11_RecognizeIdentityDocuments.md
Stopwatch sw = Stopwatch.StartNew();
if (imageToDetect != null && imageToDetect.Length > 0)
{
//Custom forms:
var options = new RecognizeCustomFormsOptions()
{
IncludeFieldElements = false, //TODO: OK? We not using this in mapping,
//Pages = {"1-3","5-6"}
//ContentType = FormContentType.Jpeg
};
using (var stream = new MemoryStream(imageToDetect))
{
try
{
RecognizeCustomFormsOperation operation = client.StartRecognizeCustomForms(modelID, stream, options);
Response<RecognizedFormCollection> operationResponse = operation.WaitForCompletionAsync().Result;
//RecognizedFormCollection forms = operationResponse.Value;
response = MapToModel(imageID, imageTypeID, imageTypeName, operationResponse, false); //Pass fields and reset in caller
}
catch (RequestFailedException rfEx)
{
response.ErrorResponse = new FormRecognizeError()
{
code = rfEx.ErrorCode,
statusCode = rfEx.Status,
message = rfEx.Message
};
Console.WriteLine($"ERROR: {rfEx.ToString()}");
}
catch (Exception ex)
{
response.ErrorResponse = new FormRecognizeError()
{
statusCode = 400, //(int)HttpStatusCode.BadRequest,
message = ex.Message
};
Console.WriteLine($"ERROR: {ex.ToString()}");
}
}
sw.Stop();
Console.WriteLine("---------------------------------------------------------------------------------");
if(response.RecognizedForms?.Count() > 0)
Console.WriteLine($"{sw.ElapsedMilliseconds} Milliseconds --> DetectForm {imageTypeName} response: RecognizedForms:{response.RecognizedForms?.Count()}. Confidence: {response.RecognizedForms[0].TypeConfidence} Error:{response.ErrorResponse?.message}");
else
Console.WriteLine($"{sw.ElapsedMilliseconds} Milliseconds --> DetectForm {imageTypeName} response: No forms detected. Error:{response.ErrorResponse?.message}");
Console.WriteLine("---------------------------------------------------------------------------------");
if (printDetail)
{
Console.WriteLine(JsonConvert.SerializeObject(response, Formatting.Indented));
Console.WriteLine("---------------------------------------------------------------------------------");
}
Console.WriteLine("");
//Error Logged in caller?
}
else
{
Console.WriteLine($"ERROR: Empty image byte array");
}
2 answers
Sort by: Most helpful
-
-
Marco Wagener 1 Reputation point
2022-01-19T08:57:51.667+00:00 @GiftA-MSFT Andre is seeing this slow performance when sending a single document. So this issue cannot be related to throughput or rate-limiting.