Generated V1
Sample Code (sync):
from mindee import Client, PredictResponse, product
# 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 = mindee_client.source_from_path("/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):
from mindee import Client, AsyncPredictResponse, product
# 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 = mindee_client.source_from_path("/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.
- static get_endpoint_info(klass)
Retrives 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: Optional[str] = 'custom'
Name of the endpoint (placeholder).
- endpoint_version: Optional[str] = '1'
Version of the endpoint.
- is_rotation_applied: Optional[bool]
Whether the document has had any rotation applied to it.
- page_id: Optional[int]
Optional page id for page-level predictions.
-
pages:
List
[Page
[GeneratedV1Page
]] Page-level prediction(s).
-
prediction:
GeneratedV1Document
Document-level prediction.
- product: Product
Name and version of a given product, as sent back by the API.
- 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
,Union
[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 (Optional[int]) –
- 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
,Union
[GeneratedListField
,StringField
,GeneratedObjectField
]] Dictionary of all fields in the document