Skip to content

Commit

Permalink
updated with package updates and fixes (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
Geoff Allix authored Aug 30, 2024
1 parent bb3bb24 commit 6a33da9
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 25 deletions.
4 changes: 2 additions & 2 deletions Instructions/Exercises/01-use-prebuilt-models.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Before you can call the Azure AI Document Intelligence service, you must create

1. In a browser tab, open the Azure portal at [https://portal.azure.com](https://portal.azure.com?azure-portal=true), signing in with the Microsoft account associated with your Azure subscription.
1. On the Azure portal home page, navigate to the top search box and type **Document Intelligence** and then press **Enter**.
1. On the **Document Intelligence** page, select **Create**.
1. On the **Document Intelligence** page, select **Create Document Intelligence**.
1. On the **Create Document Intelligence** page, use the following to configure your resource:
- **Subscription**: Your Azure subscription.
- **Resource group**: Select or create a resource group with a unique name such as *DocIntelligenceResources*.
Expand Down Expand Up @@ -81,7 +81,7 @@ Applications for both C# and Python have been provided, as well as a sample pdf
**Python**:
```powershell
pip install azure-ai-formrecognizer==3.3.0
pip install azure-ai-formrecognizer==3.3.3
```
## Add code to use the Azure Document Intelligence service
Expand Down
5 changes: 3 additions & 2 deletions Instructions/Exercises/02-custom-document-intelligence.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@ Now you will train the model using the files uploaded to the storage account.
- Select *Continue*.
- Select *Create project*
1. Once your project is created, select **Train** to train your model. Use the following configurations:
1. Once your project is created, on the top right of the screen, select **Train** to train your model. Use the following configurations:
- **Model ID**: *Provide a globally unique name (you'll need the model ID name in the next step)*.
- **Build Mode**: Template.
1. Select **Go to Models**.
1. Training can take some time. You'll see a notification when it's complete.
## Test your custom Document Intelligence model
Expand All @@ -144,7 +145,7 @@ Now you will train the model using the files uploaded to the storage account.
**Python**:
```powershell
pip install azure-ai-formrecognizer==3.3.0
pip install azure-ai-formrecognizer==3.3.3
```
1. In Visual Studio Code, in the **Labfiles/02-custom-document-intelligence** folder, select the language you are using. Edit the configuration file (**appsettings.json** or **.env**, depending on your language preference) with the following values:
Expand Down
36 changes: 15 additions & 21 deletions Instructions/Exercises/03-composed-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ To create a composed model, we must first create two or more custom models. To c
1. In the **Project name** textbox, type **1040 Forms**, and then select **Continue**.
1. On the **Configure service resource** page, in the **Subscription** drop-down list, select your Azure subscription.
1. In the **Resource group** drop-down list, select the **DocumentIntelligenceResources<xxxx>** created for you.
1. In the **Azure AI Document Intelligence or Azure AI Service Resource** drop-down list, select **DocumentIntelligence<xxxx>**.
1. In the **API version** drop-down list, ensure that **2023-10-31-preview** is selected and then select **Continue**.
1. In the **Document Intelligence or Cognitive Service Resource** drop-down list, select **DocumentIntelligence<xxxx>**.
1. In the **API version** drop-down list, ensure that **2024-07-31 (Preview)** is selected and then select **Continue**.
1. On the **Connect training data source** page, in the **Subscription** drop-down list, select your Azure subscription.
1. In the **Resource group** drop-down list, select **DocumentIntelligenceResources<xxxx>**.
1. In the **Storage account** drop-down list, select the only storage account listed. If you have multiple storage accounts in your subscription, choose the one starting with *docintelstorage*
1. In the **Blob container** drop-down list, select **1040examples**, and then select **Continue**.
1. In the **Review and create** page, select **Create project**.
1. Select **Run layout** in the *Start labeling now* pop up, and wait for the analysis to complete.
1. Select **Run now** under *Run layout* in the *Start labeling now* pop up, and wait for the analysis to complete.

## Label the 1040 Forms custom model

Expand All @@ -74,7 +74,7 @@ Now, let's label the fields in the example forms:
1. In the top-right of the page, select **+ Add a field**, and then select **Field**.
1. Type **State** and then press *Enter*.
1. In the document, select **CA** and then select **State**.
1. Repeat the labeling process for the remaining forms in the list on the left, using the labels you created. Label the same four fields: *FirstName*, *LastName*, *City*, and *State*.
1. Repeat the labeling process for the remaining forms in the list on the left, using the labels you created. Label the same four fields: *FirstName*, *LastName*, *City*, and *State*. Notice that one of the documents does not have city or state data.

> **IMPORTANT**
> For the purposes of this exercise, we're using only five example forms and labeling only four fields. In your real-world models, you should use as many samples as possible to maximize the accuracy and confidence of your predictions. You should also label all the available fields in the forms, rather than just four fields.
Expand All @@ -83,7 +83,7 @@ Now, let's label the fields in the example forms:

Now that the sample forms are labeled, we can train the first custom model:

1. In the Azure AI Document Intelligence Studio, select **Train**.
1. In the Azure AI Document Intelligence Studio,on the top right of the screen, select **Train**.
1. In the **Train a new model** dialog, in the **Model ID** textbox, type **1040FormsModel**.
1. In the **Build mode** drop-down list, select **Template**, and then select **Train**.
1. In the **Training in progress** dialog, select **Go to Models**.
Expand All @@ -97,14 +97,15 @@ Now, you must create a second model, which you'll train on example 1099 tax form
1. In the **Project name** textbox, type **1099 Forms**, and then select **Continue**.
1. On the **Configure service resource** page, in the **Subscription** drop-down list, select your Azure subscription.
1. In the **Resource group** drop-down list, select **DocumentIntelligenceResources<xxxx>**.
1. In the **Azure AI Document Intelligence or Azure AI Service Resource** drop-down list, select **DocumentIntelligence<xxxx>**.
1. In the **API version** drop-down list, ensure that **20223-10-31-preview** is selected and then select **Continue**.
1. In the **Document Intelligence or Cognitive Service Resource** drop-down list, select **DocumentIntelligence<xxxx>**.
1. In the **API version** drop-down list, ensure that **2024-07-31 (Preview)** is selected and then select **Continue**.
1. On the **Connnect training data source** page, in the **Subscription** drop-down list, select your Azure subscription.
1. In the **Resource group** drop-down list, select **DocumentIntelligenceResources<xxxx>**.
1. In the **Storage account** drop-down list, select the only storage account listed.
1. In the **Blob container** drop-down list, select **1099examples**, and then select **Continue**.
1. In the **Review and create** page, select **Create project**.
1. Select **Run layout** in the *Start labeling now* pop up, and wait for the analysis to complete.
1. Select the drop-down button for **Run layout** and select **Unanalyzed documents**.
1. Wait for the analysis to complete.

## Label the 1099 Forms custom model

Expand All @@ -122,31 +123,24 @@ Now, label the example forms with some fields:
1. In the top-right of the page, select **+ Add a field**, and then select **Field**.
1. Type **State** and then press *Enter*.
1. In the document, select **CT** and then select **State**.
1. Repeat the labeling process for the remaining forms in the list on the left. Label the same four fields: *FirstName*, *LastName*, *City*, and *State*.
1. Repeat the labeling process for the remaining forms in the list on the left. Label the same four fields: *FirstName*, *LastName*, *City*, and *State*. Notice that two of the documents don't have any name data to label.

## Train the 1099 Forms custom model

You can now train the second custom model:

1. In the Azure AI Document Intelligence Studio, select **Train**.
1. In the Azure AI Document Intelligence Studio,on the top right, select **Train**.
1. In the **Train a new model** dialog, in the **Model ID** textbox, type **1099FormsModel**.
1. In the **Build mode** drop-down list, select **Template**, and then select **Train**.
1. In the **Training in progress** dialog, select **Go to Models**.
1. The training process can take a few minutes. Refresh the browser occasionally until both models display the **succeeded** status.

## Create and assemble a composed model

This comment has been minimized.

Copy link
@awattar

awattar Sep 4, 2024

Hi,

Saw that "Create and assemble a compose model" that was referred also in https://learn.microsoft.com/en-gb/training/modules/create-composed-form-recognizer-model/4-exercise-model has been removed. Any reason for that? Is the composition part realised now by choosing manually the right model?

Regards,
Michal

## Use the model

The two custom models, which analyze 1040 and 1099 tax forms, are now complete. You can proceed to create the composed model:
Now that the model is complete, let's test it with an example form:

1. In the Azure AI Document Intelligence Models page, select both **1040FormsModel** and **1099FormsModel**.
1. At the top of the list of models, select **Compose**.
1. In the **Compose a new model** dialog, in the **Model ID** textbox, type **TaxFormsModel** and then select **Compose**. Azure AI Document Intelligence creates the composed model and displays it in the list of custom models:

## Use the composed model

Now that the composed model is complete, let's test it with an example form:

1. In the Azure AI Document Intelligence Studio, select the **Test** page, select the **TaxFormsModel** from the dropdown.
1. In the Azure AI Document Intelligence Studio, select the **Models** page, select the **1040FormsModel**.
1. Select **Test**.
1. Select **Browse for files** and then browse to the location where you cloned the repository.
1. Select **03-composed-model/trainingdata/TestDoc/f1040_7.pdf**, and then select **Open**.
1. Select **Run analysis**. Azure AI Document Intelligence analyses the form by using the composed model.
Expand Down
43 changes: 43 additions & 0 deletions mslearn-ai-document-intelligence.generated.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Labfiles", "Labfiles", "{B5FA3A18-78FF-4102-92D5-1EC0341D84E8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "01-prebuild-models", "01-prebuild-models", "{4CB3A070-BF75-449F-A7BD-DABB3A7C3A0B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "invoicereader", "Labfiles\01-prebuild-models\CSharp\invoicereader.csproj", "{208E9976-000E-473E-A471-AF98CC2E1009}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "02-custom-document-intelligence", "02-custom-document-intelligence", "{E5DE3F97-A2E3-4B7E-9C58-65D7BFE1BB67}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "test-model", "Labfiles\02-custom-document-intelligence\C-Sharp\test-model.csproj", "{D71B58DD-B2F4-45D2-A9CF-8D449B654325}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{208E9976-000E-473E-A471-AF98CC2E1009}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{208E9976-000E-473E-A471-AF98CC2E1009}.Debug|Any CPU.Build.0 = Debug|Any CPU
{208E9976-000E-473E-A471-AF98CC2E1009}.Release|Any CPU.ActiveCfg = Release|Any CPU
{208E9976-000E-473E-A471-AF98CC2E1009}.Release|Any CPU.Build.0 = Release|Any CPU
{D71B58DD-B2F4-45D2-A9CF-8D449B654325}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D71B58DD-B2F4-45D2-A9CF-8D449B654325}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D71B58DD-B2F4-45D2-A9CF-8D449B654325}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D71B58DD-B2F4-45D2-A9CF-8D449B654325}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{4CB3A070-BF75-449F-A7BD-DABB3A7C3A0B} = {B5FA3A18-78FF-4102-92D5-1EC0341D84E8}
{208E9976-000E-473E-A471-AF98CC2E1009} = {4CB3A070-BF75-449F-A7BD-DABB3A7C3A0B}
{E5DE3F97-A2E3-4B7E-9C58-65D7BFE1BB67} = {B5FA3A18-78FF-4102-92D5-1EC0341D84E8}
{D71B58DD-B2F4-45D2-A9CF-8D449B654325} = {E5DE3F97-A2E3-4B7E-9C58-65D7BFE1BB67}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {526B95FD-D76F-452F-9F81-B01B1EDE1930}
EndGlobalSection
EndGlobal

0 comments on commit 6a33da9

Please sign in to comment.