Forms Recognizer studio issue vs C# Code

Chris Gilliam 11 Reputation points
2022-01-03T10:48:54.467+00:00

Hi

I have been using the new Forms Recognizer studio to label and train a custom forms model . All forms are multipage pdf documents. All is working fine within Forms Recogniser Studio however when I try to use the model in my C# code I am encountering issues.
Firstly the model ID is shown as bondTrackModel in forms studio
When I pass this as a parameter to
RecognizedFormCollection forms = await recognizerClient
.StartRecognizeCustomForms(modelId, image_data)
.WaitForCompletionAsync();
``with modelId="bondTrackModel" it throws a parameter exception because the model ID is not a guid. There is no way in Recognizer Studio to get the model guid from the friendly name.

I then tried to train the model myself in code. However when I call

            CustomFormModel model = await trainingClient
            .StartTrainingAsync(new Uri(trainingStorageUri), useTrainingLabels: true)
            .WaitForCompletionAsync();

It throws an exception Generic error during processing of OCR results for each each of the pdf documents I have in the container.

Any help or pointers appreciated.

Azure AI Document Intelligence
Azure AI Document Intelligence
An Azure service that turns documents into usable data. Previously known as Azure Form Recognizer.
1,622 questions
{count} vote

3 answers

Sort by: Most helpful
  1. Chris Gilliam 11 Reputation points
    2022-01-04T08:44:13.057+00:00

    Second issue I am having . I can train my model using the Forms Recogniser Studio but when I want to train my model in C# code using the label files I have made with Forms Recogniser Studio none of the training files are recognised .

    Here is the code I am using
    {
    static async Task Main(string[] args)
    {
    try
    {
    // Get configuration settings
    IConfigurationBuilder builder = new ConfigurationBuilder().AddJsonFile("appsettings.json");
    IConfigurationRoot configuration = builder.Build();
    string formEndpoint = configuration["FormEndpoint"];
    string formKey = configuration["FormKey"];
    string trainingStorageUri = configuration["StorageUri"];

                // Authenticate Form Training Client 
                var credential = new AzureKeyCredential(formKey);
                var trainingClient = new FormTrainingClient(new Uri(formEndpoint), credential);  
    
                // Train model 
                CustomFormModel model = await trainingClient
                .StartTrainingAsync(new Uri(trainingStorageUri), useTrainingLabels: true)
                .WaitForCompletionAsync();
    
                // Get model info
                Console.WriteLine($"Custom Model Info:");
                Console.WriteLine($"    Model Id: {model.ModelId}");
                //Console.WriteLine($"    Model Id: {model.ModelName}");
                Console.WriteLine($"    Model Status: {model.Status}");
                Console.WriteLine($"    Training model started on: {model.TrainingStartedOn}");
                Console.WriteLine($"    Training model completed on: {model.TrainingCompletedOn}");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }  
        }
    }
    

    And the exception being thrown is :

    Invalid model created with ID 7ff1fb0f-ba2c-41cb-b7c1-fe2aaf03cccb
    Status: 200 (OK)
    ErrorCode: 2102

    Additional Information:
    error-0: 2102: Only 0 valid input document(s) were found. Please provide at least 5 input documents. Generic error during processing of OCR results for BT-App V1.0-chrisg4.pdf Generic error during processing of OCR results for BT-App V1.0-chrisg2.pdf Generic error during processing of OCR results for BT-App V1.0-chrisg5.pdf Generic error during processing of OCR results for BT-App V1.0-chrisg3.pdf Generic error during processing of OCR results for BT-App V1.0-chrisg1.pdf

    These are the same documents I have used to successful train my model with the Forms Recogniser Studio and made the label files with.

    1 person found this answer helpful.

  2. Chris Gilliam 11 Reputation points
    2022-01-04T06:40:29.117+00:00

    Ok first issue . I am using Forms recogniser Studio to train model. Under models it has only one model ID value "bondTrackModel" . The code I use to test is

                RecognizedFormCollection forms = await recognizerClient
                .StartRecognizeCustomForms(modelId, image_data)
                .WaitForCompletionAsync();
    

    Where modelID="bondTrackModel" it throws error
    "The modelId must be a valid GUID. (Parameter 'modelId')"
    Previously I was using the old label making tool FOTT and there the model ID was shown as a GUID and it worked correctly. My problem is that the new Forms Recogniser Tool does not show model ID as GUIDs so the same call does not work with the model "friendly name"

    0 comments No comments

  3. William Hawkins 25 Reputation points
    2024-03-04T22:47:12.4166667+00:00

    Was the 'Generic error during processing of OCR results' issue resolved? I am experiencing the same thing. I tried to train a model but it stated 12/15 files I used had this error. They are carbon copies, structure-wise of the ones that did work. Any suggestions or guidance would be greatly appreciated:)

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.