Skip to content

Commit 4ffea7a

Browse files
fixes
1 parent fdc99d9 commit 4ffea7a

4 files changed

Lines changed: 34 additions & 10 deletions

File tree

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
from mindee import ClientV2, ClassificationParameters, ClassificationResponse, PathInput
1+
from mindee import (
2+
ClientV2,
3+
PathInput,
4+
ClassificationParameters,
5+
ClassificationResponse,
6+
)
27

38
input_path = "/path/to/the/file.ext"
49
api_key = "MY_API_KEY"
@@ -7,7 +12,7 @@ model_id = "MY_CLASSIFICATION_MODEL_ID"
712
# Init a new client
813
mindee_client = ClientV2(api_key)
914

10-
# Set inference parameters
15+
# Set parameters
1116
params = ClassificationParameters(
1217
# ID of the model, required.
1318
model_id=model_id,
@@ -16,7 +21,7 @@ params = ClassificationParameters(
1621
# Load a file from disk
1722
input_source = PathInput(input_path)
1823

19-
# Send for processing
24+
# Send for processing using polling
2025
response = 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
2732
print(response.inference)
33+
34+
# Access the classification result
35+
classifications: list = response.inference.result.classifications
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
from mindee import ClientV2, CropParameters, CropResponse, PathInput
1+
from mindee import (
2+
ClientV2,
3+
PathInput,
4+
CropParameters,
5+
CropResponse,
6+
)
27

38
input_path = "/path/to/the/file.ext"
49
api_key = "MY_API_KEY"
@@ -7,7 +12,7 @@ model_id = "MY_CROP_MODEL_ID"
712
# Init a new client
813
mindee_client = ClientV2(api_key)
914

10-
# Set inference parameters
15+
# Set parameters
1116
params = CropParameters(
1217
# ID of the model, required.
1318
model_id=model_id,
@@ -16,7 +21,7 @@ params = CropParameters(
1621
# Load a file from disk
1722
input_source = PathInput(input_path)
1823

19-
# Send for processing
24+
# Send for processing using polling
2025
response = 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
2732
print(response.inference)
33+
34+
# Access the crop result
35+
crops: list = response.inference.result.crops
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
from mindee import ClientV2, OCRParameters, OCRResponse, PathInput
1+
from mindee import (
2+
ClientV2,
3+
PathInput,
4+
OCRParameters,
5+
OCRResponse,
6+
)
27

38
input_path = "/path/to/the/file.ext"
49
api_key = "MY_API_KEY"
@@ -7,7 +12,7 @@ model_id = "MY_OCR_MODEL_ID"
712
# Init a new client
813
mindee_client = ClientV2(api_key)
914

10-
# Set inference parameters
15+
# Set parameters
1116
params = OCRParameters(
1217
# ID of the model, required.
1318
model_id=model_id,
@@ -16,7 +21,7 @@ params = OCRParameters(
1621
# Load a file from disk
1722
input_source = PathInput(input_path)
1823

19-
# Send for processing
24+
# Send for processing using polling
2025
response = 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
2732
print(response.inference)
33+
34+
# Access the ocr result
35+
ocrs: list = response.inference.result.ocrs

tests/v2/product/ocr/test_ocr_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)