From 9c23b105afcdb41560c76a1b42758bcaf608945d Mon Sep 17 00:00:00 2001 From: Catalina Peralta Date: Tue, 30 Mar 2021 09:17:41 -0700 Subject: [PATCH] update readme for preview.3 --- .../azure-ai-formrecognizer/README.md | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/README.md b/sdk/formrecognizer/azure-ai-formrecognizer/README.md index 031018d716f5..fbe1d966d779 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/README.md +++ b/sdk/formrecognizer/azure-ai-formrecognizer/README.md @@ -9,6 +9,7 @@ from form documents. It includes the following main functionalities: * Receipt model - Recognize data from sales receipts using a prebuilt model. * Business card model - Recognize data from business cards using a prebuilt model. * Invoice model - Recognize data from invoices using a prebuilt model. + * Id document model - Recognize data from id documents using a prebuilt model. [Source code][python-fr-src] | [Package (PyPI)][python-fr-pypi] | [API reference documentation][python-fr-ref-docs]| [Product documentation][python-fr-product-docs] | [Samples][python-fr-samples] @@ -26,14 +27,14 @@ Install the Azure Form Recognizer client library for Python with [pip][pip]: pip install azure-ai-formrecognizer --pre ``` -> Note: This version of the client library defaults to the v2.1-preview.2 version of the service +> Note: This version of the client library defaults to the v2.1-preview.3 version of the service This table shows the relationship between SDK versions and supported API versions of the service |SDK version|Supported API version of service |-|- |3.0.0 - Latest GA release (can be installed by removing the `--pre` flag)| 2.0 -|3.1.0b3 - Latest release (beta)| 2.0, 2.1-preview.2 +|3.1.0b4 - Latest release (beta)| 2.0, 2.1-preview.3 #### Create a Form Recognizer resource @@ -138,6 +139,7 @@ form_recognizer_client = FormRecognizerClient( - Sales receipts. See fields found on a receipt [here][service_recognize_receipt]. - Business cards. See fields found on a business card [here][service_recognize_business_cards]. - Invoices. See fields found on an invoice [here][service_recognize_invoice]. + - Id documents. See fields found on an id document [here][service_recognize_id_documents]. - Recognizing form content, including tables, lines, words, and selection marks, without the need to train a model. Form content is returned in a collection of `FormPage` objects. Sample code snippets are provided to illustrate using a FormRecognizerClient [here](#recognize-forms-using-a-custom-model "Recognize Forms Using a Custom Model"). @@ -175,6 +177,7 @@ The following section provides several code snippets covering some of the most c * [Recognize Receipts](#recognize-receipts "Recognize receipts") * [Recognize Business Cards](#recognize-business-cards "Recognize business cards") * [Recognize Invoices](#recognize-invoices "Recognize invoices") +* [Recognize Id Documents](#recognize-id-documents "Recognize id documents") * [Train a Model](#train-a-model "Train a model") * [Manage Your Models](#manage-your-models "Manage Your Models") @@ -340,6 +343,28 @@ for invoice in result: print("{}: {} has confidence {}".format(name, field.value, field.confidence)) ``` +### Recognize Id documents +Recognize data from id documents using a prebuilt model. Id document fields recognized by the service can be found [here][service_recognize_id_documents]. + +```python +from azure.ai.formrecognizer import FormRecognizerClient +from azure.core.credentials import AzureKeyCredential + +endpoint = "https://.api.cognitive.microsoft.com/" +credential = AzureKeyCredential("") + +form_recognizer_client = FormRecognizerClient(endpoint, credential) + +with open("", "rb") as fd: + id_document = fd.read() + +poller = form_recognizer_client.begin_recognize_id_documents(id_document) +result = poller.result() + +for id_document in result: + for name, field in id_document.fields.items(): + print("{}: {} has confidence {}".format(name, field.value, field.confidence)) +``` ### Train a model Train a custom model on your own form type. The resulting model can be used to recognize values from the types of forms it was trained on. @@ -472,6 +497,7 @@ These code samples show common scenario operations with the Azure Form Recognize * Recognize receipts from a URL: [sample_recognize_receipts_from_url.py][sample_recognize_receipts_from_url] * Recognize business cards: [sample_recognize_business_cards.py][sample_recognize_business_cards] * Recognize invoices: [sample_recognize_invoices.py][sample_recognize_invoices] +* Recognize id documents: [sample_recognize_id_documents.py][sample_recognize_id_documents] * Recognize content: [sample_recognize_content.py][sample_recognize_content] * Recognize custom forms: [sample_recognize_custom_forms.py][sample_recognize_custom_forms] * Train a model without labels: [sample_train_model_without_labels.py][sample_train_model_without_labels] @@ -490,6 +516,7 @@ are found under the `azure.ai.formrecognizer.aio` namespace. * Recognize receipts from a URL: [sample_recognize_receipts_from_url_async.py][sample_recognize_receipts_from_url_async] * Recognize business cards: [sample_recognize_business_cards_async.py][sample_recognize_business_cards_async] * Recognize invoices: [sample_recognize_invoices_async.py][sample_recognize_invoices_async] +* Recognize id documents: [sample_recognize_id_documents_async.py][sample_recognize_id_documents_async] * Recognize content: [sample_recognize_content_async.py][sample_recognize_content_async] * Recognize custom forms: [sample_recognize_custom_forms_async.py][sample_recognize_custom_forms_async] * Train a model without labels: [sample_train_model_without_labels_async.py][sample_train_model_without_labels_async] @@ -545,6 +572,7 @@ This project has adopted the [Microsoft Open Source Code of Conduct][code_of_con [service_recognize_receipt]: https://aka.ms/formrecognizer/receiptfields [service_recognize_business_cards]: https://aka.ms/formrecognizer/businesscardfields [service_recognize_invoice]: https://aka.ms/formrecognizer/invoicefields +[service_recognize_id_documents]: https://aka.ms/formrecognizer/iddocumentfields [sdk_logging_docs]: https://docs.microsoft.com/azure/developer/python/azure-sdk-logging [cla]: https://cla.microsoft.com @@ -568,6 +596,8 @@ This project has adopted the [Microsoft Open Source Code of Conduct][code_of_con [sample_recognize_business_cards_async]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/formrecognizer/azure-ai-formrecognizer/samples/async_samples/sample_recognize_business_cards_async.py [sample_recognize_invoices]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/formrecognizer/azure-ai-formrecognizer/samples/sample_recognize_invoices.py [sample_recognize_invoices_async]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/formrecognizer/azure-ai-formrecognizer/samples/async_samples/sample_recognize_invoices_async.py +[sample_recognize_id_documents]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/formrecognizer/azure-ai-formrecognizer/samples/sample_recognize_id_documents.py +[sample_recognize_id_documents_async]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/formrecognizer/azure-ai-formrecognizer/samples/async_samples/sample_recognize_id_documents_async.py [sample_train_model_with_labels]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/formrecognizer/azure-ai-formrecognizer/samples/sample_train_model_with_labels.py [sample_train_model_with_labels_async]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/formrecognizer/azure-ai-formrecognizer/samples/async_samples/sample_train_model_with_labels_async.py [sample_train_model_without_labels]: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/formrecognizer/azure-ai-formrecognizer/samples/sample_train_model_without_labels.py