Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.55k stars 2.77k forks source link

Azure OCR JSON file creation #26592

Closed dsabarinathan closed 1 year ago

dsabarinathan commented 1 year ago

Describe the bug how to create the below ocr.json file using the azure documentanalysisclient or other OCR functions. when I load the blob folder in form recognizer studio, it creates the below ocr json for the pdf document automatically. I want to create the same JSON ocr file with the azure python ocr function.

train_docs.zip

To Reproduce Steps to reproduce the behavior: I used the below code but it is not returning the results in the OCR json format. https://learn.microsoft.com/en-us/python/api/azure-ai-formrecognizer/azure.ai.formrecognizer.documentanalysisclient?source=recommendations&view=azure-python Expected behavior A clear and concise description of what you expected to happen.

pvaneck commented 1 year ago

Hey, @dsabarinathan! Thanks for opening an issue. I can tag people who should be able to help. However, from a cursory look, have you tried looking through the form recognizer samples? I know we have one here that appears to outline the process of going converting some results to JSON.

catalinaperalta commented 1 year ago

Hi @dsabarinathan! Thanks for the question. The way to create the OCR files is through Form Recognizer Studio. Those files can then be used to train a new custom analysis model with the SDK. You can use begin_build_document_model() on DocumentModelAdministrationClient to do so. The DocumentModelAdministrationClient has methods that can be used to build, compose, copy, get, list, and delete document models, among others. Since the OCR files need to be labeled, the user interface in Form Recognizer Studio provides a way to easily do that. For unlabeled document analysis you could use begin_analyze_document() on DocumentAnalysisClient with the prebuilt-document model ID.

dsabarinathan commented 1 year ago

Thank you for the suggestion. @pvaneck @catalinaperalta .

The below code is working for me. https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2/sample_convert_to_and_from_dict.py#L60

ghost commented 1 year ago

Hi @dsabarinathan. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.