How to Use Form Recognizer to Extract Items From Receipt
Table of Contents
In this article, Let’s use Azure Form Recognizer, latest AI-OCR tool developed by Microsoft to extract items from receipt.
Setup Azure
Behind Azure Form Recognizer is actually Azure Cognitive Services like Computer Vision Read API.
So an Azure account is required. Let’s setup azure account and cognitive service resource first.
Firstly let’s open the Azure portal URL.
Azure Portal
https://portal.azure.com/
If you don’t have an Azure account, the page below will show up and you must create your own Azure account first. When you created your Azure free account for the first time, you will get popular services free for 12 months and 25+ services free always and start with $200 credit to use in your first 30 days.
After you finished creating Azure free account, sign in to it.
The home page of Azure will show up like below.
Let’s create cognitive service resource.
Input “cognitive services” in top search bar and click “Cognitive Services” in result list.
The home page of “Cognitive Services” will show up and scroll down to bottom, you will find Multipurpose service and click "+ Create".
Subscription: default, Free account you created.
Resource group: Resource management unit that manages all resources under it. You should click “Create new” and input a name.
Region: Where the computing instance locates, select nearest region.
Name: Input a not used cognitive services name.
Pricing tier: Standard S0
Check terms confirm checkbox and click “Review + create”.
Confirm page will show up and click Create.
When resource deployment is complete, you finished the setup of Azure account.
Start using Form Recognizer Studio
Form Recognizer Studio
https://formrecognizer.appliedai.azure.com/
We will use Prebuilt model “Receipts” this time.
After clicking “Receipts”, configuration dialog will show up.
Subscription: Free Azure account created above.
Resource group: Created above in Azure account setup.
Cognitive Service Resource: Created above in Azure account setup.
Click “Continue”. Confirm dialog will show up. Click “Finish”.
Receipts recognization workspace will show up. Let’s review the layout of workspace together.
①: Upload receipt images or pdfs that you want to extract items from.
②: Uploaded receipt images or pdfs.
③: Analyze receipt and extract itmes.
④: Scalable image of receipts.
⑤: Extracted results.
⑥: Layers to show (Text, Tables, Selection marks).
⑦: API version.
⑧: Extracted result in JSON format.
⑨: Python code using API.
Above is just preset samples, so let’s download a receipt from Internet to check the performance of Azure Form Recognizer.
Download above image and upload it to Form Recognizer Studio to analyze it.
The item name, quantity and price, etc. are extracted correctly.
You can download the result JSON file and utilize it in other system.
Conclusion
- To use Azure Form Recognizer, you have to create your own free azure account first and create a resource group, a cognitive service resource.
- Use prebuilt receipt model to analyze receipt images or pdfs and extract items as JSON result.