Generated V1
Sample Code (sync):
#
# Install the Python client library by running:
# pip install mindee
#
from mindee.v1 import Client, PredictResponse, product
from mindee import PathInput
# Init a new client
mindee_client = Client(api_key="my-api-key")
# Add the corresponding endpoint (document).
# Set the account_name to "mindee" if you are using OTS.
my_endpoint = mindee_client.create_endpoint(
account_name="my-account",
endpoint_name="my-endpoint",
version="my-version"
)
# Load a file from disk
input_doc = PathInput("/path/to/the/file.ext")
# Parse the file.
# The endpoint must be specified since it cannot be determined from the class.
result: PredictResponse = mindee_client.parse(
product.GeneratedV1,
input_doc,
endpoint=my_endpoint
)
# Print a brief summary of the parsed data
print(result.document)
# # Iterate over all the fields in the document
# for field_name, field_values in result.document.inference.prediction.fields.items():
# print(field_name, "=", field_values)
Sample Code (async):
#
# Install the Python client library by running:
# pip install mindee
#
from mindee.v1 import Client, AsyncPredictResponse, product
from mindee import PathInput
# Init a new client
mindee_client = Client(api_key="my-api-key")
# Add the corresponding endpoint (document).
# Set the account_name to "mindee" if you are using OTS.
my_endpoint = mindee_client.create_endpoint(
account_name="my-account",
endpoint_name="my-endpoint",
version="my-version"
)
# Load a file from disk
input_doc = PathInput("/path/to/the/file.ext")
# Parse the file.
# The endpoint must be specified since it cannot be determined from the class.
result: AsyncPredictResponse = mindee_client.enqueue_and_parse(
product.GeneratedV1,
input_doc,
endpoint=my_endpoint
)
# Print a brief summary of the parsed data
print(result.document)
# # Iterate over all the fields in the document
# for field_name, field_values in result.document.inference.prediction.fields.items():
# print(field_name, "=", field_values)
- class GeneratedV1(raw_prediction)
Generated API V1 inference results.
- Parameters:
raw_prediction (dict[str, Any])
- static get_endpoint_info(klass)
Retrieves the endpoint information for an Inference.
Should never retrieve info for CustomV1, as a custom endpoint should be created to use CustomV1.
- Parameters:
klass (
type[Inference]) – product subclass to access endpoint information.- Return type:
dict[str,str]
- endpoint_name: str | None = 'custom'
Name of the endpoint (placeholder).
- endpoint_version: str | None = '1'
Version of the endpoint.
- is_rotation_applied: bool | None
Whether the document has had any rotation applied to it.
- page_id: int | None
Optional page id for page-level predictions.
- pages: list[Page[GeneratedV1Page]]
Page-level prediction(s).
- prediction: GeneratedV1Document
Document-level prediction.
- class GeneratedV1Document(raw_prediction)
Generated V1 document prediction results.
- Parameters:
raw_prediction (dict[str, Any])
- get_list_fields()
Returns a dictionary of all list-like fields.
- Return type:
dict[str,GeneratedListField]
- get_object_fields()
Returns a dictionary of all object-like fields.
- Return type:
dict[str,GeneratedObjectField]
- get_single_fields()
Returns a dictionary of all fields that aren’t a collection.
- Return type:
dict[str,StringField]
- list_field_names()
Lists names of all top-level field keys.
- Return type:
list[str]
- fields: dict[str, GeneratedListField | StringField | GeneratedObjectField]
Dictionary of all fields in the document
- class GeneratedV1Page(raw_prediction, page_id=None)
Generated V1 page prediction results.
- Parameters:
raw_prediction (dict[str, Any])
page_id (int | None)
- get_list_fields()
Returns a dictionary of all list-like fields.
- Return type:
dict[str,GeneratedListField]
- get_object_fields()
Returns a dictionary of all object-like fields.
- Return type:
dict[str,GeneratedObjectField]
- get_single_fields()
Returns a dictionary of all fields that aren’t a collection.
- Return type:
dict[str,StringField]
- list_field_names()
Lists names of all top-level field keys.
- Return type:
list[str]
- fields: dict[str, GeneratedListField | StringField | GeneratedObjectField]
Dictionary of all fields in the document