Skip to content

Commit d6bfc5e

Browse files
✨ add support for V2 Classification, Crop and OCR utilities (#382)
1 parent 93f3058 commit d6bfc5e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+840
-11
lines changed

.github/workflows/_test-code-samples.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
4141
- name: Tests code samples
4242
run: |
43-
./tests/test_code_samples.sh ${{ secrets.MINDEE_ACCOUNT_SE_TESTS }} ${{ secrets.MINDEE_ENDPOINT_SE_TESTS }} ${{ secrets.MINDEE_API_KEY_SE_TESTS }} ${{ secrets.MINDEE_V2_SE_TESTS_API_KEY }} ${{ secrets.MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID }} ${{ secrets.MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID }}
43+
./tests/test_code_samples.sh ${{ secrets.MINDEE_ACCOUNT_SE_TESTS }} ${{ secrets.MINDEE_ENDPOINT_SE_TESTS }} ${{ secrets.MINDEE_API_KEY_SE_TESTS }} ${{ secrets.MINDEE_V2_SE_TESTS_API_KEY }} ${{ secrets.MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID }} ${{ secrets.MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID }} ${{ secrets.MINDEE_V2_SE_TESTS_CROP_MODEL_ID }} ${{ secrets.MINDEE_V2_SE_TESTS_OCR_MODEL_ID }} ${{ secrets.MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID }}
4444
4545
- name: Notify Slack Action on Failure
4646
uses: ravsamhq/notify-slack-action@2.3.0

.github/workflows/_test-integrations.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ jobs:
4949
MINDEE_V2_API_KEY: ${{ secrets.MINDEE_V2_SE_TESTS_API_KEY }}
5050
MINDEE_V2_FINDOC_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID }}
5151
MINDEE_V2_SE_TESTS_BLANK_PDF_URL: ${{ secrets.MINDEE_V2_SE_TESTS_BLANK_PDF_URL }}
52+
MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CLASSIFICATION_MODEL_ID }}
53+
MINDEE_V2_SE_TESTS_CROP_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_CROP_MODEL_ID }}
5254
MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID }}
55+
MINDEE_V2_SE_TESTS_OCR_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_OCR_MODEL_ID }}
5356
run: |
5457
pytest --cov mindee -m integration
5558
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from mindee import (
2+
ClientV2,
3+
PathInput,
4+
ClassificationParameters,
5+
ClassificationResponse,
6+
)
7+
8+
input_path = "/path/to/the/file.ext"
9+
api_key = "MY_API_KEY"
10+
model_id = "MY_CLASSIFICATION_MODEL_ID"
11+
12+
# Init a new client
13+
mindee_client = ClientV2(api_key)
14+
15+
# Set parameters
16+
params = ClassificationParameters(
17+
# ID of the model, required.
18+
model_id=model_id,
19+
)
20+
21+
# Load a file from disk
22+
input_source = PathInput(input_path)
23+
24+
# Send for processing using polling
25+
response = mindee_client.enqueue_and_get_result(
26+
ClassificationResponse,
27+
input_source,
28+
params,
29+
)
30+
31+
# Print a brief summary of the parsed data
32+
print(response.inference)
33+
34+
# Access the classification result
35+
classification: str = response.inference.result.classification.document_type
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from mindee import (
2+
ClientV2,
3+
PathInput,
4+
CropParameters,
5+
CropResponse,
6+
)
7+
8+
input_path = "/path/to/the/file.ext"
9+
api_key = "MY_API_KEY"
10+
model_id = "MY_CROP_MODEL_ID"
11+
12+
# Init a new client
13+
mindee_client = ClientV2(api_key)
14+
15+
# Set parameters
16+
params = CropParameters(
17+
# ID of the model, required.
18+
model_id=model_id,
19+
)
20+
21+
# Load a file from disk
22+
input_source = PathInput(input_path)
23+
24+
# Send for processing using polling
25+
response = mindee_client.enqueue_and_get_result(
26+
CropResponse,
27+
input_source,
28+
params,
29+
)
30+
31+
# Print a brief summary of the parsed data
32+
print(response.inference)
33+
34+
# Access the crop result
35+
crops: list = response.inference.result.crops
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from mindee import (
2+
ClientV2,
3+
PathInput,
4+
OCRParameters,
5+
OCRResponse,
6+
)
7+
8+
input_path = "/path/to/the/file.ext"
9+
api_key = "MY_API_KEY"
10+
model_id = "MY_OCR_MODEL_ID"
11+
12+
# Init a new client
13+
mindee_client = ClientV2(api_key)
14+
15+
# Set parameters
16+
params = OCRParameters(
17+
# ID of the model, required.
18+
model_id=model_id,
19+
)
20+
21+
# Load a file from disk
22+
input_source = PathInput(input_path)
23+
24+
# Send for processing using polling
25+
response = mindee_client.enqueue_and_get_result(
26+
OCRResponse,
27+
input_source,
28+
params,
29+
)
30+
31+
# Print a brief summary of the parsed data
32+
print(response.inference)
33+
34+
# Access the ocr result
35+
pages: list = response.inference.result.pages

mindee/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@
2222
from mindee.parsing.common.predict_response import PredictResponse
2323
from mindee.parsing.common.workflow_response import WorkflowResponse
2424
from mindee.parsing.v2 import InferenceResponse, JobResponse
25+
from mindee.v2.product.classification.classification_parameters import (
26+
ClassificationParameters,
27+
)
28+
from mindee.v2.product.classification.classification_response import (
29+
ClassificationResponse,
30+
)
31+
from mindee.v2.product.crop.crop_parameters import CropParameters
32+
from mindee.v2.product.crop.crop_response import CropResponse
33+
from mindee.v2.product.ocr.ocr_parameters import OCRParameters
34+
from mindee.v2.product.ocr.ocr_response import OCRResponse
2535
from mindee.v2.product.split.split_parameters import SplitParameters
2636
from mindee.v2.product.split.split_response import SplitResponse
2737

@@ -30,8 +40,12 @@
3040
"AsyncPredictResponse",
3141
"Base64Input",
3242
"BytesInput",
43+
"ClassificationResponse",
44+
"ClassificationParameters",
3345
"Client",
3446
"ClientV2",
47+
"CropParameters",
48+
"CropResponse",
3549
"DataSchema",
3650
"DataSchemaField",
3751
"DataSchemaReplace",
@@ -42,6 +56,8 @@
4256
"Job",
4357
"JobResponse",
4458
"LocalResponse",
59+
"OCRParameters",
60+
"OCRResponse",
4561
"PageOptions",
4662
"PathInput",
4763
"PollingOptions",

mindee/input/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from mindee.input.local_response import LocalResponse
22
from mindee.input.base_parameters import BaseParameters
33
from mindee.input.inference_parameters import InferenceParameters
4-
from mindee.v2.product.split.split_parameters import SplitParameters
54
from mindee.input.page_options import PageOptions
65
from mindee.input.polling_options import PollingOptions
76
from mindee.input.sources.base_64_input import Base64Input
@@ -26,6 +25,5 @@
2625
"PathInput",
2726
"PollingOptions",
2827
"UrlInputSource",
29-
"SplitParameters",
3028
"WorkflowOptions",
3129
]

mindee/v2/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
1+
from mindee.v2.product.classification.classification_parameters import (
2+
ClassificationParameters,
3+
)
4+
from mindee.v2.product.classification.classification_response import (
5+
ClassificationResponse,
6+
)
7+
from mindee.v2.product.crop.crop_parameters import CropParameters
8+
from mindee.v2.product.crop.crop_response import CropResponse
9+
from mindee.v2.product.ocr.ocr_parameters import OCRParameters
10+
from mindee.v2.product.ocr.ocr_response import OCRResponse
111
from mindee.v2.product.split.split_parameters import SplitParameters
212
from mindee.v2.product.split.split_response import SplitResponse
313

414
__all__ = [
15+
"ClassificationResponse",
16+
"ClassificationParameters",
17+
"CropResponse",
18+
"CropParameters",
19+
"OCRResponse",
20+
"OCRParameters",
521
"SplitResponse",
622
"SplitParameters",
723
]

mindee/v2/product/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
1+
from mindee.v2.product.classification.classification_parameters import (
2+
ClassificationParameters,
3+
)
4+
from mindee.v2.product.classification.classification_response import (
5+
ClassificationResponse,
6+
)
7+
from mindee.v2.product.crop.crop_parameters import CropParameters
8+
from mindee.v2.product.crop.crop_response import CropResponse
9+
from mindee.v2.product.ocr.ocr_parameters import OCRParameters
10+
from mindee.v2.product.ocr.ocr_response import OCRResponse
111
from mindee.v2.product.split.split_parameters import SplitParameters
212
from mindee.v2.product.split.split_response import SplitResponse
313

414
__all__ = [
15+
"ClassificationParameters",
16+
"ClassificationResponse",
17+
"CropResponse",
18+
"CropParameters",
19+
"OCRResponse",
20+
"OCRParameters",
521
"SplitResponse",
622
"SplitParameters",
723
]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from mindee.v2.product.classification.classification_classifier import (
2+
ClassificationClassifier,
3+
)
4+
from mindee.v2.product.classification.classification_inference import (
5+
ClassificationInference,
6+
)
7+
from mindee.v2.product.classification.classification_parameters import (
8+
ClassificationParameters,
9+
)
10+
from mindee.v2.product.classification.classification_response import (
11+
ClassificationResponse,
12+
)
13+
from mindee.v2.product.classification.classification_result import ClassificationResult
14+
15+
__all__ = [
16+
"ClassificationClassifier",
17+
"ClassificationInference",
18+
"ClassificationParameters",
19+
"ClassificationResponse",
20+
"ClassificationResult",
21+
]

0 commit comments

Comments
 (0)