From 45ebd61f7c336639a107f1d146e3f963c15c6403 Mon Sep 17 00:00:00 2001 From: jonathanMindee <41388086+jonathanMindee@users.noreply.github.com> Date: Wed, 25 Aug 2021 13:01:33 +0200 Subject: [PATCH] Invoice2.1 (#8) * chg :bookmark: prepare V1.2.0 * chg: :sparkles: updated SDK to new Mindee API * chg: :white_check_mark: Updated tests * chg: :heavy_minus_sign: Deleted Numpy dependency * chg: :see_no_evil: added DS_Store to gitignore * chg: :see_no_evil: deleted DS_Store --- .gitignore | 3 + CHANGELOG.md | 9 + mindee/__init__.py | 78 +- mindee/documents/__init__.py | 21 - mindee/documents/financial_document.py | 14 +- mindee/documents/invoice.py | 6 +- mindee/documents/receipt.py | 3 +- mindee/fields/__init__.py | 4 +- mindee/http.py | 4 +- mindee/plots.py | 20 +- requirements.txt | 1 - tests/data/expense_receipts/v3/receipt.json | 381 +++++--- .../expense_receipts/v3/receipt_all_na.json | 191 ++-- tests/data/invoices/v2/invoice.json | 883 +++++++++++------- tests/data/invoices/v2/invoice_all_na.json | 221 +++-- tests/data/license_plates/v1/plate.json | 110 ++- .../data/license_plates/v1/plate_all_na.json | 73 +- tests/data/passport/v1/passport.json | 485 +++++++--- tests/data/passport/v1/passport_all_na.json | 261 ++++-- tests/data/response_dump.json | 2 +- tests/documents/test_document.py | 16 +- tests/documents/test_financial_doc.py | 12 +- tests/documents/test_invoice.py | 6 +- tests/documents/test_passport.py | 4 +- tests/documents/test_plate.py | 4 +- tests/documents/test_receipt.py | 6 +- tests/fields/test_field.py | 16 +- tests/fields/test_tax.py | 14 +- tests/test_client.py | 8 +- tests/test_plots.py | 8 + 30 files changed, 1865 insertions(+), 999 deletions(-) create mode 100644 tests/test_plots.py diff --git a/.gitignore b/.gitignore index 6f0ab30d..6b069e3d 100644 --- a/.gitignore +++ b/.gitignore @@ -128,3 +128,6 @@ dmypy.json # Pyre type checker .pyre/ /data/ + +# Mac OS +.DS_Store \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index b100f7ee..bb625622 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Mindee python SDK +## v1.2.0 (2020-08-25) + +### Chg + +* :sparkles: Adapted SDK to the new Mindee API endpoint +* :zap: Single page object reconstruction is now server-side +* :heavy_minus_sign: Removed Numpy dependency +* :white_check_mark: Updated tests with new data + ## v1.1.3 (2020-02-21) ### Fix diff --git a/mindee/__init__.py b/mindee/__init__.py index 80ad6650..c464e36a 100644 --- a/mindee/__init__.py +++ b/mindee/__init__.py @@ -10,6 +10,14 @@ from mindee.documents.passport import Passport from mindee.benchmark import Benchmark +DOCUMENT_CLASSES = { + "receipt": Receipt, + "invoice": Invoice, + "financial_document": FinancialDocument, + "passport": Passport, + "license_plate": CarPlate +} + class Client(object): def __init__( @@ -29,7 +37,7 @@ def __init__( """ assert type(raise_on_error) == bool self.raise_on_error = raise_on_error - self.base_url = "https://api.mindee.net/products/" + self.base_url = "https://api.mindee.net/v1/products/mindee/" self.expense_receipt_token = expense_receipt_token self.invoice_token = invoice_token self.passport_token = passport_token @@ -79,10 +87,11 @@ def _wrap_response( :return: Full response object """ dict_response = response.json() - if response.status_code != 200 and self.raise_on_error: + + if response.status_code > 201 and self.raise_on_error: raise HTTPException( "Receipt API %s HTTP error: %s" % (response.status_code, json.dumps(dict_response))) - elif response.status_code != 200: + elif response.status_code > 201: return Response( http_response=dict_response, pages=[], @@ -288,55 +297,30 @@ def format_response(json_response, document_type, input_file): json_response["filepath"] = input_file.filepath json_response["file_extension"] = input_file.file_extension pages = [] - for page_n, page_prediction in enumerate(json_response["predictions"]): - if document_type == "receipt": - pages.append( - Receipt( - api_prediction=page_prediction, - input_file=input_file, - page_n=page_n - ) - ) - elif document_type == "invoice": - pages.append( - Invoice( - api_prediction=page_prediction, - input_file=input_file, - page_n=page_n - ) - ) - elif document_type == "financial_document": - pages.append( - FinancialDocument( - api_prediction=page_prediction, - input_file=input_file, - page_n=page_n - ) - ) - elif document_type == "passport": - pages.append( - Passport( - api_prediction=page_prediction, - input_file=input_file, - page_n=page_n - ) - ) - elif document_type == "license_plate": - pages.append( - CarPlate( - api_prediction=page_prediction, - input_file=input_file, - page_n=page_n - ) + + if document_type not in DOCUMENT_CLASSES.keys(): + raise Exception("Document type not supported.") + + # Create page level objects + for page_n, page_prediction in enumerate(json_response["document"]["inference"]["pages"]): + pages.append( + DOCUMENT_CLASSES[document_type]( + api_prediction=page_prediction["prediction"], + input_file=input_file, + page_n=page_prediction["id"] ) - else: - raise Exception("Document type not supported.") + ) - document = Document.merge_pages(pages) + # Create the document level object + document_level = DOCUMENT_CLASSES[document_type]( + api_prediction=json_response["document"]["inference"]["prediction"], + input_file=input_file, + page_n="-1" + ) return Response( http_response=json_response, pages=pages, - document=document, + document=document_level, document_type=document_type ) diff --git a/mindee/documents/__init__.py b/mindee/documents/__init__.py index 5e63e6ee..4655b9d5 100644 --- a/mindee/documents/__init__.py +++ b/mindee/documents/__init__.py @@ -1,6 +1,3 @@ -import copy - - class Document(object): def __init__(self, input_file=None): self.filepath = None @@ -24,21 +21,3 @@ def _reconstruct(self, *args): def all_checks(self): return all(self.checklist) - - @staticmethod - def merge_pages(page_documents): - """ - :param page_documents: Document object list - :return: A single Document where each field is set with the maximum probability field - """ - document = copy.deepcopy(page_documents[0]) - attributes = [a for a in dir(document)] - for doc in page_documents: - for attribute in attributes: - if not hasattr(getattr(doc, attribute), "probability"): - continue - - if getattr(doc, attribute).probability > getattr(document, attribute).probability: - setattr(document, attribute, getattr(doc, attribute)) - - return document diff --git a/mindee/documents/financial_document.py b/mindee/documents/financial_document.py index b3ef8ae1..dc753938 100644 --- a/mindee/documents/financial_document.py +++ b/mindee/documents/financial_document.py @@ -138,18 +138,26 @@ def build_from_api_prediction(self, api_prediction, input_file, page_n=0): self.company_number = [] def __str__(self): - return "-----Financial document-----\n" \ + return "-----Financial Document data-----\n" \ "Filename: %s \n" \ - "Total amount: %s \n" \ + "Invoice number: %s \n" \ + "Total amount including taxes: %s \n" \ + "Total amount excluding taxes: %s \n" \ "Date: %s\n" \ - "Merchant name: %s\n" \ + "Invoice due date: %s\n" \ + "Supplier name: %s\n" \ + "Taxes: %s\n" \ "Total taxes: %s\n" \ "----------------------" % \ ( self.filename, + self.invoice_number.value, self.total_incl.value, + self.total_excl.value, self.date.value, + self.due_date.value, self.merchant_name.value, + ",".join([str(t.value) + " " + str(t.rate) + "%" for t in self.taxes]), self.total_tax.value ) diff --git a/mindee/documents/invoice.py b/mindee/documents/invoice.py index 31833c90..1c4f5f6b 100644 --- a/mindee/documents/invoice.py +++ b/mindee/documents/invoice.py @@ -26,7 +26,6 @@ def __init__( supplier=None, payment_details=None, company_number=None, - vat_number=None, orientation=None, total_tax=None, page_n=0 @@ -106,7 +105,8 @@ def build_from_api_prediction(self, api_prediction, page_n=0): self.due_date = Date(api_prediction["due_date"], value_key="value", page_n=page_n) self.invoice_number = Field(api_prediction["invoice_number"], page_n=page_n) self.locale = Locale(api_prediction["locale"], value_key="language", page_n=page_n) - self.orientation = Orientation(api_prediction["orientation"], page_n=page_n) + if str(page_n) != "-1": + self.orientation = Orientation(api_prediction["orientation"], page_n=page_n) self.supplier = Field(api_prediction["supplier"], page_n=page_n) self.taxes = [ Tax(tax_prediction, page_n=page_n, value_key="value") for tax_prediction in api_prediction["taxes"] @@ -128,6 +128,7 @@ def __str__(self): "Total amount including taxes: %s \n" \ "Total amount excluding taxes: %s \n" \ "Invoice date: %s\n" \ + "Invoice due date: %s\n" \ "Supplier name: %s\n" \ "Taxes: %s\n" \ "Total taxes: %s\n" \ @@ -138,6 +139,7 @@ def __str__(self): self.total_incl.value, self.total_excl.value, self.invoice_date.value, + self.due_date.value, self.supplier.value, ",".join([str(t.value) + " " + str(t.rate) + "%" for t in self.taxes]), self.total_tax.value diff --git a/mindee/documents/receipt.py b/mindee/documents/receipt.py index 70c0104e..b1d4e701 100644 --- a/mindee/documents/receipt.py +++ b/mindee/documents/receipt.py @@ -117,7 +117,8 @@ def build_from_api_prediction(self, api_prediction, page_n=0): self.taxes = [ Tax(tax_prediction, page_n=page_n, value_key="value", rate_key="rate", code_key="code") for tax_prediction in api_prediction["taxes"]] - self.orientation = Orientation(api_prediction["orientation"], page_n=page_n) + if str(page_n) != "-1": + self.orientation = Orientation(api_prediction["orientation"], page_n=page_n) self.total_tax = Amount({"value": None, "probability": 0.}, value_key="value", page_n=page_n) self.total_excl = Amount({"value": None, "probability": 0.}, value_key="value", page_n=page_n) diff --git a/mindee/fields/__init__.py b/mindee/fields/__init__.py index b75068a8..f5885a02 100644 --- a/mindee/fields/__init__.py +++ b/mindee/fields/__init__.py @@ -27,8 +27,8 @@ def __init__( else: self.probability = 0. - if "segmentation" in abstract_prediction: - self.bbox = abstract_prediction["segmentation"]["bounding_box"] + if "polygon" in abstract_prediction: + self.bbox = abstract_prediction["polygon"] else: self.bbox = [] diff --git a/mindee/http.py b/mindee/http.py index 4cbecd79..42f9e3dc 100644 --- a/mindee/http.py +++ b/mindee/http.py @@ -11,7 +11,7 @@ def request(url, input_file, token, include_words=False): """ input_file.file_object.seek(0) - files = {"file": input_file.file_object.read()} + files = {"document": input_file.file_object.read()} headers = {"X-Inferuser-Token": token} @@ -20,7 +20,7 @@ def request(url, input_file, token, include_words=False): params["include_mvision"] = "true" response = requests.post( - url+"?include_mvision=True", + url, files=files, headers=headers, data=params diff --git a/mindee/plots.py b/mindee/plots.py index 65fe3c50..a0081c4b 100644 --- a/mindee/plots.py +++ b/mindee/plots.py @@ -1,4 +1,3 @@ -import numpy as np import matplotlib.pyplot as plt @@ -17,30 +16,35 @@ def autolabel(ax, rects): ha='center', va='bottom', rotation=90) -def plot_metrics(metrics, accuracies, precisions, save_path): +def plot_metrics(metrics, accuracies, precisions, save_path, savefig=True): """ + :param savefig: Boolean to specify whether saving the plot as a png file or not :param metrics: List of metrics names :param accuracies: List of accuracy values :param precisions: List of precision values :param save_path: Path to save the figure - :return: (void) plot the precision and accuracy bar charts and save the figure in save_path + :return: the plt object """ - x = np.arange(len(metrics)) # the label locations + x_range = [float(k) for k in range(len(metrics))] # the label locations width = 0.4 # the width of the bars fig, ax = plt.subplots() fig.subplots_adjust(bottom=0.15) - rects1 = ax.bar(x - width / 2, accuracies, width, color='#fd3246', label='Accuracy') - rects2 = ax.bar(x + width / 2, precisions, width, color='#007af9', label='Precision') + rects1 = ax.bar([x - width / 2 for x in x_range], accuracies, width, color='#fd3246', label='Accuracy') + rects2 = ax.bar([x + width / 2 for x in x_range], precisions, width, color='#007af9', label='Precision') autolabel(ax, rects1) autolabel(ax, rects2) + # Add some text for labels, title and custom x-axis tick labels, etc. ax.set_ylabel('%') ax.set_title('Metrics') - ax.set_xticks(x) + ax.set_xticks(x_range) ax.set_xticklabels(metrics, rotation=45, fontsize=6) ax.legend(loc='lower left') plt.grid(True, linestyle='--', color='#e1e1e1', alpha=0.4) - plt.savefig(save_path, dpi=300) \ No newline at end of file + if savefig: + plt.savefig(save_path, dpi=300) + + return plt \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index f355cf36..65216540 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,5 +2,4 @@ requests~=2.23.0 pytz~=2021.1 setuptools~=49.2.0 matplotlib~=3.1.2 -numpy~=1.18.5 PyMuPDF~=1.18.6 \ No newline at end of file diff --git a/tests/data/expense_receipts/v3/receipt.json b/tests/data/expense_receipts/v3/receipt.json index c0db413a..51e47ec6 100644 --- a/tests/data/expense_receipts/v3/receipt.json +++ b/tests/data/expense_receipts/v3/receipt.json @@ -1,70 +1,198 @@ { - "input_type": "path", - "filename": "receipt.jpg", - "filepath": "/dummy/receipt.jpg", - "file_extension": "image/png", - "document_type": "receipt", - "call": { - "endpoint": { - "name": "expense_receipts", - "version": "2.1" - }, - "finished_at": "2020-10-09T20:56:38+00:00", - "id": "d1c35ec5-8c22-4a2f-a735-861440bbe6cf", - "n_documents": 1, - "n_inputs": 1, - "processing_time": 0.896, - "started_at": "2020-10-09T20:56:37+00:00" + "api_request": { + "error": {}, + "resources": [ + "document" + ], + "status": "success", + "status_code": 201, + "url": "http://api.mindee.net/v1/products/mindee/expense_receipts/v3/predict?include_mvision=True" }, - "documents": [ - { - "id": "65943b99-a7bb-464d-8728-ba3df2d38962", - "name": "receipt.jpg" - } - ], - "predictions": [ - { - "category": { - "probability": 0.99, - "value": "food" - }, - "date": { - "value": "2016-02-26", - "probability": 0.99, - "raw": "26-Feb-2016", - "segmentation": { - "bounding_box": [ + "document": { + "annotations": { + "labels": [] + }, + "id": "79b9ea7f-ab4f-429e-9631-98d29ba2a49d", + "inference": { + "finished_at": "2021-08-24T08:10:12+00:00", + "pages": [ + { + "id": 0, + "prediction": { + "category": { + "confidence": 0.99, + "value": "food" + }, + "date": { + "confidence": 0.99, + "polygon": [ + [ + 0.479, + 0.173 + ], + [ + 0.613, + 0.173 + ], + [ + 0.613, + 0.197 + ], + [ + 0.479, + 0.197 + ] + ], + "raw": "26-Feb-2016", + "value": "2016-02-26" + }, + "locale": { + "confidence": 0.82, + "country": "GB", + "currency": "GBP", + "language": "en", + "value": "en-GB" + }, + "orientation": { + "confidence": 0.99, + "degrees": 0 + }, + "supplier": { + "confidence": 0.71, + "polygon": [ + [ + 0.394, + 0.068 + ], + [ + 0.477, + 0.068 + ], + [ + 0.477, + 0.087 + ], + [ + 0.394, + 0.087 + ] + ], + "value": "CLACHAN" + }, + "taxes": [ + { + "code": "None", + "confidence": 0.98, + "polygon": [ + [ + 0.19, + 0.402 + ], + [ + 0.698, + 0.402 + ], + [ + 0.698, + 0.432 + ], + [ + 0.19, + 0.432 + ] + ], + "rate": 20.0, + "value": 1.7 + } + ], + "time": { + "confidence": 0.99, + "polygon": [ + [ + 0.62, + 0.173 + ], + [ + 0.681, + 0.173 + ], + [ + 0.681, + 0.191 + ], + [ + 0.62, + 0.191 + ] + ], + "raw": "15:20", + "value": "15:20" + }, + "total_incl": { + "confidence": 0.99, + "polygon": [ + [ + 0.549, + 0.619 + ], + [ + 0.715, + 0.619 + ], + [ + 0.715, + 0.642 + ], + [ + 0.549, + 0.642 + ] + ], + "value": 10.2 + } + } + } + ], + "prediction": { + "category": { + "confidence": 0.99, + "value": "food" + }, + "date": { + "confidence": 0.99, + "page_id": 0, + "polygon": [ [ 0.479, - 0.172 + 0.173 ], [ - 0.611, - 0.172 + 0.613, + 0.173 ], [ - 0.611, - 0.196 + 0.613, + 0.197 ], [ 0.479, - 0.196 + 0.197 ] - ] - } - }, - "locale": { - "country": "GB", - "currency": "GBP", - "language": "en", - "probability": 0.82, - "value": "en-GB" - }, - "supplier": { - "value": "CLACHAN", - "probability": 0.71, - "segmentation": { - "bounding_box": [ + ], + "raw": "26-Feb-2016", + "value": "2016-02-26" + }, + "locale": { + "confidence": 0.82, + "country": "GB", + "currency": "GBP", + "language": "en", + "value": "en-GB" + }, + "supplier": { + "confidence": 0.71, + "page_id": 0, + "polygon": [ [ 0.394, 0.068 @@ -81,90 +209,109 @@ 0.394, 0.087 ] - ] - } - }, - "orientation": { - "degrees": 0, - "probability": 0.99 - }, - "taxes": [ - { - "value": 1.7, - "probability": 1.0, - "rate": 20.0, - "code": "N/A", - "segmentation": { - "bounding_box": [ + ], + "value": "CLACHAN" + }, + "taxes": [ + { + "code": "None", + "confidence": 0.98, + "page_id": 0, + "polygon": [ [ - 0.17, - 0.647 + 0.19, + 0.402 ], [ - 0.719, - 0.647 + 0.698, + 0.402 ], [ - 0.719, - 0.675 + 0.698, + 0.432 ], [ - 0.17, - 0.675 + 0.19, + 0.432 ] - ] + ], + "rate": 20.0, + "value": 1.7 } - } - ], - "time": { - "value": "15:20", - "probability": 0.99, - "raw": "15:20", - "segmentation": { - "bounding_box": [ - [ - 0.623, - 0.172 + ], + "time": { + "confidence": 0.99, + "page_id": 0, + "polygon": [ + [ + 0.62, + 0.173 ], [ - 0.68, - 0.172 + 0.681, + 0.173 ], [ - 0.68, - 0.189 + 0.681, + 0.191 ], [ - 0.623, - 0.189 + 0.62, + 0.191 ] - ] - } - }, - "total_incl": { - "value": 10.2, - "probability": 0.99, - "segmentation": { - "bounding_box": [ - [ - 0.564, - 0.614 + ], + "raw": "15:20", + "value": "15:20" + }, + "total_incl": { + "confidence": 0.99, + "page_id": 0, + "polygon": [ + [ + 0.549, + 0.619 ], [ - 0.725, - 0.614 + 0.715, + 0.619 ], [ - 0.725, - 0.644 + 0.715, + 0.642 ], [ - 0.564, - 0.644 + 0.549, + 0.642 ] - ] + ], + "value": 10.2 } - } - } - ] + }, + "processing_time": 1.099, + "product": { + "features": [ + "locale", + "category", + "date", + "time", + "total_incl", + "taxes", + "supplier", + "orientation" + ], + "name": "mindee/expense_receipts", + "type": "standard", + "version": "3.0" + }, + "started_at": "2021-08-24T08:10:11+00:00" + }, + "n_pages": 1, + "name": "document", + "ocr": {} + }, + "document_type": "receipt", + "input_type": "path", + "filename": "receipt.jpg", + "filepath": "./tests/data/expense_receipts/receipt.jpg", + "file_extension": "image/jpeg" } \ No newline at end of file diff --git a/tests/data/expense_receipts/v3/receipt_all_na.json b/tests/data/expense_receipts/v3/receipt_all_na.json index 9dc4ddff..8272b6f9 100644 --- a/tests/data/expense_receipts/v3/receipt_all_na.json +++ b/tests/data/expense_receipts/v3/receipt_all_na.json @@ -1,75 +1,130 @@ { - "input_type": "path", - "filename": "receipt.jpg", - "filepath": "/dummy/receipt.jpg", - "file_extension": "image/png", - "document_type": "receipt", - "call": { - "endpoint": { - "name": "expense_receipts", - "version": "2.1" - }, - "finished_at": "2020-10-09T20:56:38+00:00", - "id": "d1c35ec5-8c22-4a2f-a735-861440bbe6cf", - "n_documents": 1, - "n_inputs": 1, - "processing_time": 0.896, - "started_at": "2020-10-09T20:56:37+00:00" + "api_request": { + "error": {}, + "resources": [ + "document" + ], + "status": "success", + "status_code": 201, + "url": "http://api.mindee.net/v1/products/mindee/expense_receipts/v3/predict?include_mvision=True" }, - "documents": [ - { - "id": "65943b99-a7bb-464d-8728-ba3df2d38962", - "name": "receipt.jpg" - } - ], - "predictions": [ - { - "category": { - "probability": 0.99, - "value": "N/A" - }, - "date": { - "value": "N/A", - "probability": 0.09, - "raw": "", - "segmentation": { - "bounding_box": [] + "document": { + "annotations": { + "labels": [] + }, + "id": "0fdf5179-d31c-4cc6-9aae-b69cbca2d70d", + "inference": { + "finished_at": "2021-08-24T08:11:28+00:00", + "pages": [ + { + "id": 0, + "prediction": { + "category": { + "confidence": 0.46, + "value": "food" + }, + "date": { + "confidence": 0.0, + "polygon": [], + "raw": null, + "value": null + }, + "locale": { + "confidence": 0.15, + "country": null, + "currency": null, + "language": null, + "value": null + }, + "orientation": { + "confidence": 0.99, + "degrees": 0 + }, + "supplier": { + "confidence": 0.0, + "polygon": [], + "value": null + }, + "taxes": [], + "time": { + "confidence": 0.0, + "polygon": [], + "raw": null, + "value": null + }, + "total_incl": { + "confidence": 0.0, + "polygon": [], + "value": null + } + } } - }, - "locale": { - "country": "N/A", - "currency": "N/A", - "language": "N/A", - "probability": 0.82, - "value": "N/A" - }, - "supplier": { - "value": "N/A", - "probability": 0.71, - "segmentation": { - "bounding_box": [] + ], + "prediction": { + "category": { + "confidence": 0.46, + "value": "food" + }, + "date": { + "confidence": 0.0, + "page_id": null, + "polygon": [], + "raw": null, + "value": null + }, + "locale": { + "confidence": 0.15, + "country": "FR", + "currency": "EUR", + "language": "fr", + "value": "fr-FR" + }, + "supplier": { + "confidence": 0.0, + "page_id": null, + "polygon": [], + "value": null + }, + "taxes": [], + "time": { + "confidence": 0.0, + "page_id": null, + "polygon": [], + "raw": null, + "value": null + }, + "total_incl": { + "confidence": 0.0, + "page_id": null, + "polygon": [], + "value": null } }, - "orientation": { - "degrees": 0, - "probability": 0.99 + "processing_time": 1.42, + "product": { + "features": [ + "locale", + "category", + "date", + "time", + "total_incl", + "taxes", + "supplier", + "orientation" + ], + "name": "mindee/expense_receipts", + "type": "standard", + "version": "3.0" }, - "taxes": [], - "time": { - "value": "N/A", - "probability": 0.99, - "raw": "", - "segmentation": { - "bounding_box": [] - } - }, - "total_incl": { - "value": "N/A", - "probability": 0.99, - "segmentation": { - "bounding_box": [] - } - } - } - ] + "started_at": "2021-08-24T08:11:26+00:00" + }, + "n_pages": 1, + "name": "document", + "ocr": {} + }, + "document_type": "receipt", + "input_type": "path", + "filename": "passport.jpeg", + "filepath": "./tests/data/passport/passport.jpeg", + "file_extension": "image/jpeg" } \ No newline at end of file diff --git a/tests/data/invoices/v2/invoice.json b/tests/data/invoices/v2/invoice.json index be6c7cb2..1e06126b 100644 --- a/tests/data/invoices/v2/invoice.json +++ b/tests/data/invoices/v2/invoice.json @@ -1,314 +1,518 @@ { - "call": { - "endpoint": { - "name": "invoices", - "version": "2.0" - }, - "finished_at": "2020-12-02T16:04:28+00:00", - "id": "084301d1-51a1-4e2e-9457-c25569583144", - "n_documents": 2, - "n_inputs": 2, - "processing_time": 3.999, - "started_at": "2020-12-02T16:04:24+00:00" + "api_request": { + "error": {}, + "resources": [ + "document" + ], + "status": "success", + "status_code": 201, + "url": "http://api.mindee.net/v1/products/mindee/invoices/v2/predict?include_mvision=True" }, - "documents": [ - { - "id": "283be3f3-b328-43c8-baeb-c6223fee912b", - "name": "file.pdf-p001" + "document": { + "annotations": { + "labels": [] }, - { - "id": "9a4ae3af-858d-4274-ac5c-2878982022ba", - "name": "file.pdf-p002" - } - ], - "predictions": [ - { - "company_registration": [ + "id": "4e948ed6-a99f-47f4-9f34-29dc3e80f25f", + "inference": { + "finished_at": "2021-08-24T08:01:39+00:00", + "pages": [ { - "probability": 0.49, - "segmentation": { - "bounding_box": [ - [ - 0.756, - 0.124 + "id": 0, + "prediction": { + "company_registration": [ + { + "confidence": 0.39, + "polygon": [ + [ + 0.759, + 0.125 + ], + [ + 0.835, + 0.125 + ], + [ + 0.835, + 0.137 + ], + [ + 0.759, + 0.137 + ] + ], + "type": "SIREN", + "value": "501124705" + }, + { + "confidence": 0.39, + "polygon": [ + [ + 0.759, + 0.125 + ], + [ + 0.835, + 0.125 + ], + [ + 0.835, + 0.137 + ], + [ + 0.759, + 0.137 + ] + ], + "type": "VAT NUMBER", + "value": "FR33501124705" + } + ], + "date": { + "confidence": 0.97, + "polygon": [ + [ + 0.288, + 0.306 + ], + [ + 0.348, + 0.306 + ], + [ + 0.348, + 0.319 + ], + [ + 0.288, + 0.319 + ] ], - [ - 0.836, - 0.124 + "value": "2020-02-17" + }, + "document_type": { + "value": "INVOICE" + }, + "due_date": { + "confidence": 0.45, + "polygon": [ + [ + 0.399, + 0.801 + ], + [ + 0.461, + 0.801 + ], + [ + 0.461, + 0.812 + ], + [ + 0.399, + 0.812 + ] ], - [ - 0.836, - 0.138 + "raw": "à réception et", + "value": "2020-02-17" + }, + "invoice_number": { + "confidence": 0.95, + "polygon": [ + [ + 0.177, + 0.307 + ], + [ + 0.264, + 0.307 + ], + [ + 0.264, + 0.32 + ], + [ + 0.177, + 0.32 + ] ], - [ - 0.756, - 0.138 - ] - ] - }, - "type": "SIREN", - "value": "501124705" + "value": "0042004801351" + }, + "locale": { + "confidence": 0.94, + "currency": "EUR", + "language": "fr" + }, + "orientation": { + "confidence": 0.99, + "degrees": 0 + }, + "payment_details": [], + "supplier": { + "confidence": 0.54, + "polygon": [ + [ + 0.207, + 0.078 + ], + [ + 0.281, + 0.078 + ], + [ + 0.281, + 0.107 + ], + [ + 0.207, + 0.107 + ] + ], + "value": "1" + }, + "taxes": [ + { + "confidence": 0.85, + "polygon": [ + [ + 0.291, + 0.749 + ], + [ + 0.543, + 0.749 + ], + [ + 0.543, + 0.766 + ], + [ + 0.291, + 0.766 + ] + ], + "rate": 20.0, + "value": 97.98 + } + ], + "total_excl": { + "confidence": 0.99, + "polygon": [ + [ + 0.66, + 0.762 + ], + [ + 0.712, + 0.762 + ], + [ + 0.712, + 0.78 + ], + [ + 0.66, + 0.78 + ] + ], + "value": 489.97 + }, + "total_incl": { + "confidence": 0.99, + "polygon": [ + [ + 0.887, + 0.762 + ], + [ + 0.938, + 0.762 + ], + [ + 0.938, + 0.779 + ], + [ + 0.887, + 0.779 + ] + ], + "value": 587.95 + } + } }, { - "probability": 0.49, - "segmentation": { - "bounding_box": [ + "id": 1, + "prediction": { + "company_registration": [], + "date": { + "confidence": 0.99, + "polygon": [ + [ + 0.838, + 0.304 + ], + [ + 0.933, + 0.304 + ], + [ + 0.933, + 0.318 + ], + [ + 0.838, + 0.318 + ] + ], + "value": "2018-09-25" + }, + "document_type": { + "value": "INVOICE" + }, + "due_date": { + "confidence": 0.86, + "polygon": [ + [ + 0.841, + 0.323 + ], + [ + 0.94, + 0.323 + ], + [ + 0.94, + 0.339 + ], + [ + 0.841, + 0.339 + ] + ], + "raw": "Upon receipt", + "value": "2018-09-25" + }, + "invoice_number": { + "confidence": 0.99, + "polygon": [ + [ + 0.841, + 0.265 + ], + [ + 0.862, + 0.265 + ], + [ + 0.862, + 0.279 + ], + [ + 0.841, + 0.279 + ] + ], + "value": "14" + }, + "locale": { + "confidence": 0.94, + "currency": "EUR", + "language": "fr" + }, + "orientation": { + "confidence": 0.99, + "degrees": 0 + }, + "payment_details": [], + "supplier": { + "confidence": 0.75, + "polygon": [ + [ + 0.162, + 0.087 + ], + [ + 0.388, + 0.087 + ], + [ + 0.388, + 0.147 + ], + [ + 0.162, + 0.147 + ] + ], + "value": "TURNPIKE DESIGNS CO" + }, + "taxes": [ + { + "confidence": 0.79, + "polygon": [ + [ + 0.785, + 0.743 + ], + [ + 0.963, + 0.743 + ], + [ + 0.963, + 0.758 + ], + [ + 0.785, + 0.758 + ] + ], + "rate": 8.0, + "value": 193.2 + } + ], + "total_excl": { + "confidence": 0.0, + "polygon": [], + "value": "None" + }, + "total_incl": { + "confidence": 0.99, + "polygon": [ + [ + 0.887, + 0.84 + ], + [ + 0.969, + 0.84 + ], + [ + 0.969, + 0.857 + ], + [ + 0.887, + 0.857 + ] + ], + "value": 2608.2 + } + } + } + ], + "prediction": { + "company_registration": [ + { + "confidence": 0.39, + "page_id": 0, + "polygon": [ [ - 0.756, - 0.124 + 0.759, + 0.125 ], [ - 0.836, - 0.124 + 0.835, + 0.125 ], [ - 0.836, - 0.138 + 0.835, + 0.137 ], [ - 0.756, - 0.138 + 0.759, + 0.137 ] - ] - }, - "type": "VAT NUMBER", - "value": "FR33501124705" - } - ], - "date": { - "probability": 0.99, - "segmentation": { - "bounding_box": [ - [ - 0.381, - 0.306 - ], - [ - 0.439, - 0.306 - ], - [ - 0.439, - 0.318 - ], - [ - 0.381, - 0.318 - ] - ] - }, - "value": "2020-02-17" - }, - "document_type": { - "value": "INVOICE" - }, - "due_date": { - "probability": 0.25, - "raw": "\u00e0 r\u00e9ceptionet", - "segmentation": { - "bounding_box": [ - [ - 0.399, - 0.801 - ], - [ - 0.46, - 0.801 - ], - [ - 0.46, - 0.812 - ], - [ - 0.399, - 0.812 - ] - ] - }, - "value": "2020-02-17" - }, - "invoice_number": { - "probability": 0.8, - "segmentation": { - "bounding_box": [ - [ - 0.168, - 0.306 - ], - [ - 0.265, - 0.306 - ], - [ - 0.265, - 0.32 ], - [ - 0.168, - 0.32 - ] - ] - }, - "value": "0042004801351" - }, - "locale": { - "currency": "EUR", - "language": "fr", - "probability": 0.77 - }, - "orientation": { - "degrees": 0, - "probability": 0.99 - }, - "payment_details": [], - "supplier": { - "probability": 0.0, - "segmentation": { - "bounding_box": [] - }, - "value": "N/A" - }, - "taxes": [ - { - "probability": 0.87, - "rate": 20.0, - "segmentation": { - "bounding_box": [ + "type": "SIREN", + "value": "501124705" + }, + { + "confidence": 0.39, + "page_id": 0, + "polygon": [ [ - 0.29, - 0.748 + 0.759, + 0.125 ], [ - 0.543, - 0.748 + 0.835, + 0.125 ], [ - 0.543, - 0.766 + 0.835, + 0.137 ], [ - 0.29, - 0.766 + 0.759, + 0.137 ] - ] - }, - "value": 97.98 - } - ], - "total_excl": { - "probability": 0.99, - "segmentation": { - "bounding_box": [ - [ - 0.659, - 0.762 - ], - [ - 0.713, - 0.762 - ], - [ - 0.713, - 0.781 - ], - [ - 0.659, - 0.781 - ] - ] - }, - "value": 489.97 - }, - "total_incl": { - "probability": 0.99, - "segmentation": { - "bounding_box": [ - [ - 0.886, - 0.762 ], - [ - 0.938, - 0.762 - ], - [ - 0.938, - 0.779 - ], - [ - 0.886, - 0.779 - ] - ] - }, - "value": 587.95 - } - }, - { - "company_registration": [], - "date": { - "probability": 0.99, - "segmentation": { - "bounding_box": [ + "type": "VAT NUMBER", + "value": "FR33501124705" + } + ], + "date": { + "confidence": 0.99, + "page_id": 1, + "polygon": [ [ 0.838, 0.304 ], [ - 0.932, + 0.933, 0.304 ], [ - 0.932, + 0.933, 0.318 ], [ 0.838, 0.318 ] - ] + ], + "value": "2018-09-25" }, - "value": "2018-09-25" - }, - "document_type": { - "value": "INVOICE" - }, - "due_date": { - "probability": 0.85, - "raw": "Upon receipt", - "segmentation": { - "bounding_box": [ + "document_type": { + "value": "INVOICE" + }, + "due_date": { + "confidence": 0.86, + "page_id": 1, + "polygon": [ [ - 0.84, + 0.841, 0.323 ], [ - 0.939, + 0.94, 0.323 ], [ - 0.939, + 0.94, 0.339 ], [ - 0.84, + 0.841, 0.339 ] - ] + ], + "raw": "Upon receipt", + "value": "2018-09-25" }, - "value": "2018-09-25" - }, - "invoice_number": { - "probability": 0.99, - "segmentation": { - "bounding_box": [ + "invoice_number": { + "confidence": 0.99, + "page_id": 1, + "polygon": [ [ 0.841, - 0.264 + 0.265 ], [ 0.862, - 0.264 + 0.265 ], [ 0.862, @@ -318,107 +522,140 @@ 0.841, 0.279 ] - ] + ], + "value": "14" }, - "value": "14" - }, - "locale": { - "currency": "CAD", - "language": "en", - "probability": 0.94 - }, - "orientation": { - "degrees": 0, - "probability": 0.99 - }, - "payment_details": [], - "supplier": { - "probability": 0.15, - "segmentation": { - "bounding_box": [ - [ - 0.165, - 0.089 + "locale": { + "confidence": 0.94, + "currency": "EUR", + "language": "fr" + }, + "payment_details": [], + "supplier": { + "confidence": 0.54, + "page_id": 0, + "polygon": [ + [ + 0.207, + 0.078 ], [ - 0.385, - 0.089 + 0.281, + 0.078 ], [ - 0.385, - 0.144 + 0.281, + 0.107 ], [ - 0.165, - 0.144 + 0.207, + 0.107 ] - ] + ], + "value": "1" }, - "value": "DESIGNS TURNPIKE CO" - }, - "taxes": [ - { - "probability": 0.73, - "rate": 8.0, - "segmentation": { - "bounding_box": [ + "taxes": [ + { + "confidence": 0.85, + "page_id": 0, + "polygon": [ [ - 0.785, - 0.744 + 0.291, + 0.749 ], [ - 0.963, - 0.744 + 0.543, + 0.749 ], [ - 0.963, - 0.759 + 0.543, + 0.766 ], [ - 0.785, - 0.759 + 0.291, + 0.766 ] + ], + "rate": 20.0, + "value": 97.98 + } + ], + "total_excl": { + "confidence": 0.99, + "page_id": 0, + "polygon": [ + [ + 0.66, + 0.762 + ], + [ + 0.712, + 0.762 + ], + [ + 0.712, + 0.78 + ], + [ + 0.66, + 0.78 ] - }, - "value": 193.2 - } - ], - "total_excl": { - "probability": 0.0, - "segmentation": { - "bounding_box": [] + ], + "value": 489.97 }, - "value": "N/A" - }, - "total_incl": { - "probability": 0.99, - "segmentation": { - "bounding_box": [ + "total_incl": { + "confidence": 0.99, + "page_id": 0, + "polygon": [ [ - 0.886, - 0.84 + 0.887, + 0.762 ], [ - 0.969, - 0.84 + 0.938, + 0.762 ], [ - 0.969, - 0.858 + 0.938, + 0.779 ], [ - 0.886, - 0.858 + 0.887, + 0.779 ] - ] - }, - "value": 2608.2 - } - } - ], + ], + "value": 587.95 + } + }, + "processing_time": 3.678, + "product": { + "features": [ + "locale", + "invoice_number", + "date", + "due_date", + "total_incl", + "total_excl", + "taxes", + "document_type", + "payment_details", + "company_registration", + "supplier", + "orientation" + ], + "name": "mindee/invoices", + "type": "standard", + "version": "2.1" + }, + "started_at": "2021-08-24T08:01:35+00:00" + }, + "n_pages": 2, + "name": "document", + "ocr": {} + }, "document_type": "invoice", "input_type": "path", "filename": "invoice.pdf", - "filepath": "/home/jonathan/mindee/dev/issues_git/mindee-api-python/tests/data/invoices/invoice.pdf", + "filepath": "./tests/data/invoices/invoice.pdf", "file_extension": "application/pdf" } \ No newline at end of file diff --git a/tests/data/invoices/v2/invoice_all_na.json b/tests/data/invoices/v2/invoice_all_na.json index 0037b882..a29fe257 100644 --- a/tests/data/invoices/v2/invoice_all_na.json +++ b/tests/data/invoices/v2/invoice_all_na.json @@ -1,95 +1,152 @@ { - "call": { - "endpoint": { - "name": "invoices", - "version": "2.0" - }, - "finished_at": "2020-12-02T16:04:28+00:00", - "id": "084301d1-51a1-4e2e-9457-c25569583144", - "n_documents": 2, - "n_inputs": 2, - "processing_time": 3.999, - "started_at": "2020-12-02T16:04:24+00:00" + "api_request": { + "error": {}, + "resources": [ + "document" + ], + "status": "success", + "status_code": 201, + "url": "http://api.mindee.net/v1/products/mindee/invoices/v2/predict?include_mvision=True" }, - "documents": [ - { - "id": "283be3f3-b328-43c8-baeb-c6223fee912b", - "name": "file.pdf-p001" + "document": { + "annotations": { + "labels": [] }, - { - "id": "9a4ae3af-858d-4274-ac5c-2878982022ba", - "name": "file.pdf-p002" - } - ], - "predictions": [ - { - "company_registration": [ + "id": "dffeef9c-dc36-4688-9973-c0f1b6af2b05", + "inference": { + "finished_at": "2021-08-24T08:07:06+00:00", + "pages": [ + { + "id": 0, + "prediction": { + "company_registration": [], + "date": { + "confidence": 0.0, + "polygon": [], + "value": null + }, + "document_type": { + "value": "INVOICE" + }, + "due_date": { + "confidence": 0.0, + "polygon": [], + "raw": null, + "value": null + }, + "invoice_number": { + "confidence": 0.0, + "polygon": [], + "value": null + }, + "locale": { + "confidence": 0.36, + "currency": null, + "language": null + }, + "orientation": { + "confidence": 0.99, + "degrees": 0 + }, + "payment_details": [], + "supplier": { + "confidence": 0.0, + "polygon": [], + "value": null + }, + "taxes": [], + "total_excl": { + "confidence": 0.0, + "polygon": [], + "value": null + }, + "total_incl": { + "confidence": 0.0, + "polygon": [], + "value": null + } + } + } ], - "date": { - "probability": 0.99, - "segmentation": { - "bounding_box": [ - ] + "prediction": { + "company_registration": [], + "date": { + "confidence": 0.0, + "page_id": null, + "polygon": [], + "value": null }, - "value": "N/A" - }, - "due_date": { - "probability": 0.25, - "raw": "N/A", - "segmentation": { - "bounding_box": [ - ] + "document_type": { + "value": "INVOICE" }, - "value": "N/A" - }, - "invoice_number": { - "probability": 0.8, - "segmentation": { - "bounding_box": [ - ] + "due_date": { + "confidence": 0.0, + "page_id": null, + "polygon": [], + "raw": null, + "value": null }, - "value": "N/A" - }, - "locale": { - "currency": "N/A", - "language": "N/A", - "probability": 0.77 - }, - "orientation": { - "degrees": 0, - "probability": 0.99 - }, - "payment_details": [], - "supplier": { - "probability": 0.0, - "segmentation": { - "bounding_box": [] + "invoice_number": { + "confidence": 0.0, + "page_id": null, + "polygon": [], + "value": null }, - "value": "N/A" - }, - "taxes": [ - ], - "total_excl": { - "probability": 0.99, - "segmentation": { - "bounding_box": [ - ] + "locale": { + "confidence": 0.36, + "currency": "EUR", + "language": "fr" }, - "value": "N/A" - }, - "total_incl": { - "probability": 0.99, - "segmentation": { - "bounding_box": [ - ] + "payment_details": [], + "supplier": { + "confidence": 0.0, + "page_id": 0, + "polygon": [], + "value": null }, - "value": "N/A" - } - } - ], + "taxes": [], + "total_excl": { + "confidence": 0.0, + "page_id": null, + "polygon": [], + "value": null + }, + "total_incl": { + "confidence": 0.0, + "page_id": null, + "polygon": [], + "value": null + } + }, + "processing_time": 1.641, + "product": { + "features": [ + "locale", + "invoice_number", + "date", + "due_date", + "total_incl", + "total_excl", + "taxes", + "document_type", + "payment_details", + "company_registration", + "supplier", + "orientation" + ], + "name": "mindee/invoices", + "type": "standard", + "version": "2.1" + }, + "started_at": "2021-08-24T08:07:05+00:00" + }, + "n_pages": 1, + "name": "document", + "ocr": {} + }, "document_type": "invoice", "input_type": "path", - "filename": "invoice.pdf", - "filepath": "/home/jonathan/mindee/dev/issues_git/mindee-api-python/tests/data/invoices/invoice.pdf", - "file_extension": "application/pdf" + "filename": "passport.jpeg", + "filepath": "./tests/data/passport/passport.jpeg", + "file_extension": "image/jpeg" } \ No newline at end of file diff --git a/tests/data/license_plates/v1/plate.json b/tests/data/license_plates/v1/plate.json index 3e1bf139..3859267b 100644 --- a/tests/data/license_plates/v1/plate.json +++ b/tests/data/license_plates/v1/plate.json @@ -1,33 +1,57 @@ { - "input_type": "path", - "filename": "receipt.jpg", - "filepath": "/dummy/receipt.jpg", - "file_extension": "image/png", - "call": { - "endpoint": { - "name": "license_plates", - "version": "1.0" - }, - "finished_at": "2020-10-09T20:56:34+00:00", - "id": "c9877842-6090-413b-bb4c-77fed33ad18e", - "n_documents": 1, - "n_inputs": 1, - "processing_time": 0.413, - "started_at": "2020-10-09T20:56:33+00:00" + "api_request": { + "error": {}, + "resources": [ + "document" + ], + "status": "success", + "status_code": 201, + "url": "http://api.mindee.net/v1/products/mindee/license_plates/v1/predict?include_mvision=True" }, - "documents": [ - { - "id": "2d5b968b-fd81-4309-a227-f654cf72de69", - "name": "plate.png" - } - ], - "predictions": [ - { - "license_plates": [ + "document": { + "annotations": { + "labels": [] + }, + "id": "8d12cace-3541-449d-8819-4ef4fb601e02", + "inference": { + "finished_at": "2021-08-24T08:14:06+00:00", + "pages": [ { - "probability": 0.97, - "segmentation": { - "bounding_box": [ + "id": 0, + "prediction": { + "license_plates": [ + { + "confidence": 0.97, + "polygon": [ + [ + 0.574, + 0.492 + ], + [ + 0.761, + 0.492 + ], + [ + 0.761, + 0.553 + ], + [ + 0.574, + 0.553 + ] + ], + "value": "7EQE707" + } + ] + } + } + ], + "prediction": { + "license_plates": [ + { + "confidence": 0.97, + "page_id": 0, + "polygon": [ [ 0.574, 0.492 @@ -44,11 +68,29 @@ 0.574, 0.553 ] - ] - }, - "value": "7EQE707" - } - ] - } - ] + ], + "value": "7EQE707" + } + ] + }, + "processing_time": 0.741, + "product": { + "features": [ + "license_plates" + ], + "name": "mindee/license_plates", + "type": "standard", + "version": "1.0" + }, + "started_at": "2021-08-24T08:14:06+00:00" + }, + "n_pages": 1, + "name": "document", + "ocr": {} + }, + "document_type": "license_plate", + "input_type": "path", + "filename": "plate.png", + "filepath": "./tests/data/license_plates/plate.png", + "file_extension": "image/png" } \ No newline at end of file diff --git a/tests/data/license_plates/v1/plate_all_na.json b/tests/data/license_plates/v1/plate_all_na.json index 99a7dc94..c0a6dae2 100644 --- a/tests/data/license_plates/v1/plate_all_na.json +++ b/tests/data/license_plates/v1/plate_all_na.json @@ -1,30 +1,51 @@ { - "input_type": "path", - "filename": "receipt.jpg", - "filepath": "/dummy/receipt.jpg", - "file_extension": "image/png", - "call": { - "endpoint": { - "name": "license_plates", - "version": "1.0" + "api_request": { + "error": {}, + "resources": [ + "document" + ], + "status": "success", + "status_code": 201, + "url": "http://api.mindee.net/v1/products/mindee/license_plates/v1/predict?include_mvision=True" + }, + "document": { + "annotations": { + "labels": [] }, - "finished_at": "2020-10-09T20:56:34+00:00", - "id": "c9877842-6090-413b-bb4c-77fed33ad18e", - "n_documents": 1, - "n_inputs": 1, - "processing_time": 0.413, - "started_at": "2020-10-09T20:56:33+00:00" + "id": "8d12cace-3541-449d-8819-4ef4fb601e02", + "inference": { + "finished_at": "2021-08-24T08:14:06+00:00", + "pages": [ + { + "id": 0, + "prediction": { + "license_plates": [ + ] + } + } + ], + "prediction": { + "license_plates": [ + ] + }, + "processing_time": 0.741, + "product": { + "features": [ + "license_plates" + ], + "name": "mindee/license_plates", + "type": "standard", + "version": "1.0" + }, + "started_at": "2021-08-24T08:14:06+00:00" + }, + "n_pages": 1, + "name": "document", + "ocr": {} }, - "documents": [ - { - "id": "2d5b968b-fd81-4309-a227-f654cf72de69", - "name": "plate.png" - } - ], - "predictions": [ - { - "license_plates": [ - ] - } - ] + "document_type": "license_plate", + "input_type": "path", + "filename": "plate.png", + "filepath": "./tests/data/license_plates/plate.png", + "file_extension": "image/png" } \ No newline at end of file diff --git a/tests/data/passport/v1/passport.json b/tests/data/passport/v1/passport.json index 5d31d9a8..ac13692e 100644 --- a/tests/data/passport/v1/passport.json +++ b/tests/data/passport/v1/passport.json @@ -1,34 +1,280 @@ { - "input_type": "base64", - "file": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAgGBgiwQw+5sv/2Q==", - "filepath": "/dummy/receipt.jpg", - "filename": "receipt.jpg", - "file_extension": "image/png", - "document_type": "passport", - "call": { - "endpoint": { - "name": "passport", - "version": "1.0" - }, - "finished_at": "2020-10-09T20:56:36+00:00", - "id": "ddde5355-17d6-4c82-a7ae-0a10fbe34d8c", - "n_documents": 1, - "n_inputs": 1, - "processing_time": 1.412, - "started_at": "2020-10-09T20:56:35+00:00" + "api_request": { + "error": {}, + "resources": [ + "document" + ], + "status": "success", + "status_code": 201, + "url": "http://api.mindee.net/v1/products/mindee/passport/v1/predict?include_mvision=True" }, - "documents": [ - { - "id": "07beeefd-025d-42a0-a8e8-b8085f4f1dd6", - "name": "passport.jpeg" - } - ], - "predictions": [ - { - "birth_date": { - "probability": 1.0, - "segmentation": { - "bounding_box": [ + "document": { + "annotations": { + "labels": [] + }, + "id": "79db59c7-b312-4692-a77f-e8698666ffba", + "inference": { + "finished_at": "2021-08-24T08:17:05+00:00", + "pages": [ + { + "id": 0, + "prediction": { + "birth_date": { + "confidence": 1.0, + "polygon": [ + [ + 0.341, + 0.689 + ], + [ + 0.571, + 0.689 + ], + [ + 0.571, + 0.714 + ], + [ + 0.341, + 0.714 + ] + ], + "value": "1995-05-20" + }, + "birth_place": { + "confidence": 0.9, + "polygon": [ + [ + 0.441, + 0.724 + ], + [ + 0.556, + 0.724 + ], + [ + 0.556, + 0.744 + ], + [ + 0.441, + 0.744 + ] + ], + "value": "CAMTETH" + }, + "country": { + "confidence": 1.0, + "polygon": [ + [ + 0.508, + 0.547 + ], + [ + 0.559, + 0.547 + ], + [ + 0.559, + 0.568 + ], + [ + 0.508, + 0.568 + ] + ], + "value": "GBR" + }, + "expiry_date": { + "confidence": 1.0, + "polygon": [ + [ + 0.34, + 0.796 + ], + [ + 0.576, + 0.796 + ], + [ + 0.576, + 0.82 + ], + [ + 0.34, + 0.82 + ] + ], + "value": "2017-04-22" + }, + "gender": { + "confidence": 1.0, + "polygon": [ + [ + 0.054, + 0.919 + ], + [ + 0.928, + 0.919 + ], + [ + 0.928, + 0.945 + ], + [ + 0.054, + 0.945 + ] + ], + "value": "M" + }, + "given_names": [ + { + "confidence": 0.99, + "polygon": [ + [ + 0.341, + 0.617 + ], + [ + 0.435, + 0.617 + ], + [ + 0.435, + 0.638 + ], + [ + 0.341, + 0.638 + ] + ], + "value": "HENERT" + } + ], + "id_number": { + "confidence": 1.0, + "polygon": [ + [ + 0.723, + 0.547 + ], + [ + 0.899, + 0.547 + ], + [ + 0.899, + 0.569 + ], + [ + 0.723, + 0.569 + ] + ], + "value": "707797979" + }, + "issuance_date": { + "confidence": 1.0, + "polygon": [ + [ + 0.34, + 0.763 + ], + [ + 0.565, + 0.763 + ], + [ + 0.565, + 0.788 + ], + [ + 0.34, + 0.788 + ] + ], + "value": "2012-04-22" + }, + "mrz1": { + "confidence": 0.99, + "polygon": [ + [ + 0.055, + 0.882 + ], + [ + 0.926, + 0.882 + ], + [ + 0.926, + 0.911 + ], + [ + 0.055, + 0.911 + ] + ], + "value": "P