How to fix Training data is missing: Could not find any training data at the given path

Anandaraj Edward 0 Reputation points
2024-11-20T16:51:16.2933333+00:00

How can I resolve the error 'Training data is missing: Could not find any training data at the given path' when creating a custom model for documents containing my organization's data?

I am using the following C# code to create the model. Can you assist me in identifying what I might be missing?

I have already verified the QA& Assist steps, but still same issue.

public class CreateCustomModel

{

public async Task<string> CreateCustomDocumentIntlligenceModel()

{

    // Configuration        

    string endpoint = "https://eastus.api.cognitive.microsoft.com/";

    string apiKey = "{API_Key}";

    string modelId = string.Empty;

    try

    {            

        // Step 2: Train the Custom Model

        string trainingBlobContainerUrl = {FULL_Container_Name_With_SAS_TOKEN};          

        Uri blobContainerUri = new Uri(trainingBlobContainerUrl);

        var client = new DocumentModelAdministrationClient(new Uri(endpoint), new AzureKeyCredential(apiKey));

        // We are selecting the Template build mode in this sample. For more information about the available

        // build modes and their differences, please see:

        // https://aka.ms/azsdk/formrecognizer/buildmode

        BuildDocumentModelOperation operation = await client.BuildDocumentModelAsync(WaitUntil.Completed, blobContainerUri, DocumentBuildMode.Template);

        DocumentModelDetails model = operation.Value;

        Console.WriteLine($"  Model Id: {model.ModelId}");

        Console.WriteLine($"  Created on: {model.CreatedOn}");

        Console.WriteLine("  Document types the model can recognize:");

        foreach (KeyValuePair<string, DocumentTypeDetails> documentType in model.DocumentTypes)

        {

            Console.WriteLine($"    Document type: {documentType.Key} which has the following fields:");

            foreach (KeyValuePair<string, DocumentFieldSchema> schema in documentType.Value.FieldSchema)

            {

                Console.WriteLine($"    Field: {schema.Key} with confidence {documentType.Value.FieldConfidence[schema.Key]}");

            }

        }

        modelId = model.ModelId;

    }

    catch (Exception ex)

    {

        Console.WriteLine($"Error: {ex.Message}");

    }

    return modelId;

}

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

1 answer

Sort by: Most helpful
  1. Q&A Assist
    2024-11-20T16:51:16.3233333+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    The error message 'Training data is missing: Could not find any training data at the given path' typically indicates that the specified path to your training data in the Azure Blob Storage is incorrect or that the data is not accessible. Here are some steps you can take to resolve this issue:

    1. Check the SAS Token: Ensure that the SAS token you are using in the trainingBlobContainerUrl has the correct permissions (Read, Write, Delete, and List) and that it is not expired.
    2. Verify the Blob Container URL: Make sure that the URL you are using for the blob container is correctly formatted. It should look like this: https://<storage account>.blob.core.windows.net/<container name>?<SAS value>. Double-check that the container name and the storage account name are correct.
    3. Ensure Data Exists: Confirm that the training data (documents) is indeed uploaded to the specified container in Azure Blob Storage. You can do this by accessing the Azure portal and navigating to your storage account.
    4. Organize Your Data: If your training data is organized in subfolders, ensure that your API call is configured to include subfolders. You may need to adjust your request body to specify the prefix if you're using subfolders.
    5. Use the Correct Build Mode: Ensure that you are using the correct build mode for your documents. The DocumentBuildMode.Template is suitable for documents with a consistent structure.

    By following these steps, you should be able to identify and resolve the issue with your training data path.


    References:

    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.