Custom V1
Sample Code:
from mindee import Client, PredictResponse, product
# Init a new client
mindee_client = Client(api_key="my-api-key")
# Add your custom endpoint (document)
my_endpoint = mindee_client.create_endpoint(
account_name="my-account",
endpoint_name="my-endpoint",
)
# 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.CustomV1,
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 CustomV1(raw_prediction)
Custom document (API Builder) 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
[CustomV1Page
]] Page-level prediction(s).
-
prediction:
CustomV1Document
Document-level prediction.
- product: Product
Name and version of a given product, as sent back by the API.
- class CustomV1Document(raw_prediction)
Custom V1 document prediction results.
- Parameters:
raw_prediction (Dict[str, Any]) –
- columns_to_line_items(anchor_names, field_names, height_tolerance=0.01)
Order column fields into line items.
- Parameters:
anchor_names (
List
[str
]) – list of possible anchor fields.field_names (
List
[str
]) – list of all column fields.height_tolerance (
float
, default:0.01
) – height tolerance to apply to lines.
- Return type:
List
[CustomLine
]
-
classifications:
Dict
[str
,ClassificationField
] Dictionary of all classifications in the document
- class CustomV1Page(raw_prediction, page_id)
Custom V1 page prediction results.
- Parameters:
raw_prediction (Dict[str, Any]) –
page_id (Optional[int]) –
- columns_to_line_items(anchor_names, field_names, height_tolerance=0.01)
Order column fields into line items.
- Parameters:
anchor_names (
List
[str
]) – list of possible anchor fields.field_names (
List
[str
]) – list of all column fields.height_tolerance (
float
, default:0.01
) – height tolerance to apply to lines.
- Return type:
List
[CustomLine
]