File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- from mindee import ClientV2, ClassificationParameters, ClassificationResponse, PathInput
1+ from mindee import (
2+ ClientV2,
3+ PathInput,
4+ ClassificationParameters,
5+ ClassificationResponse,
6+ )
27
38input_path = "/path/to/the/file.ext"
49api_key = "MY_API_KEY"
@@ -7,7 +12,7 @@ model_id = "MY_CLASSIFICATION_MODEL_ID"
712# Init a new client
813mindee_client = ClientV2(api_key)
914
10- # Set inference parameters
15+ # Set parameters
1116params = ClassificationParameters(
1217 # ID of the model, required.
1318 model_id=model_id,
@@ -16,7 +21,7 @@ params = ClassificationParameters(
1621# Load a file from disk
1722input_source = PathInput(input_path)
1823
19- # Send for processing
24+ # Send for processing using polling
2025response = mindee_client.enqueue_and_get_result(
2126 ClassificationResponse,
2227 input_source,
@@ -25,3 +30,6 @@ response = mindee_client.enqueue_and_get_result(
2530
2631# Print a brief summary of the parsed data
2732print(response.inference)
33+
34+ # Access the classification result
35+ classifications: list = response.inference.result.classifications
Original file line number Diff line number Diff line change 1- from mindee import ClientV2, CropParameters, CropResponse, PathInput
1+ from mindee import (
2+ ClientV2,
3+ PathInput,
4+ CropParameters,
5+ CropResponse,
6+ )
27
38input_path = "/path/to/the/file.ext"
49api_key = "MY_API_KEY"
@@ -7,7 +12,7 @@ model_id = "MY_CROP_MODEL_ID"
712# Init a new client
813mindee_client = ClientV2(api_key)
914
10- # Set inference parameters
15+ # Set parameters
1116params = CropParameters(
1217 # ID of the model, required.
1318 model_id=model_id,
@@ -16,7 +21,7 @@ params = CropParameters(
1621# Load a file from disk
1722input_source = PathInput(input_path)
1823
19- # Send for processing
24+ # Send for processing using polling
2025response = mindee_client.enqueue_and_get_result(
2126 CropResponse,
2227 input_source,
@@ -25,3 +30,6 @@ response = mindee_client.enqueue_and_get_result(
2530
2631# Print a brief summary of the parsed data
2732print(response.inference)
33+
34+ # Access the crop result
35+ crops: list = response.inference.result.crops
Original file line number Diff line number Diff line change 1- from mindee import ClientV2, OCRParameters, OCRResponse, PathInput
1+ from mindee import (
2+ ClientV2,
3+ PathInput,
4+ OCRParameters,
5+ OCRResponse,
6+ )
27
38input_path = "/path/to/the/file.ext"
49api_key = "MY_API_KEY"
@@ -7,7 +12,7 @@ model_id = "MY_OCR_MODEL_ID"
712# Init a new client
813mindee_client = ClientV2(api_key)
914
10- # Set inference parameters
15+ # Set parameters
1116params = OCRParameters(
1217 # ID of the model, required.
1318 model_id=model_id,
@@ -16,7 +21,7 @@ params = OCRParameters(
1621# Load a file from disk
1722input_source = PathInput(input_path)
1823
19- # Send for processing
24+ # Send for processing using polling
2025response = mindee_client.enqueue_and_get_result(
2126 OCRResponse,
2227 input_source,
@@ -25,3 +30,6 @@ response = mindee_client.enqueue_and_get_result(
2530
2631# Print a brief summary of the parsed data
2732print(response.inference)
33+
34+ # Access the ocr result
35+ ocrs: list = response.inference.result.ocrs
Original file line number Diff line number Diff line change @@ -31,4 +31,4 @@ def test_ocr_default_sample(v2_client: ClientV2, ocr_model_id: str):
3131 assert isinstance (response .inference , OCRInference )
3232 assert isinstance (response .inference .result , OCRResult )
3333 assert len (response .inference .result .pages ) == 1
34- assert len (response .inference .result .pages [0 ].words ) > 0
34+ assert len (response .inference .result .pages [0 ].words ) > 5
You can’t perform that action at this time.
0 commit comments