-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathinference.py
More file actions
38 lines (32 loc) · 1.23 KB
/
inference.py
File metadata and controls
38 lines (32 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from typing import Optional
from mindee.parsing.common.string_dict import StringDict
from mindee.parsing.v2.inference_file import InferenceFile
from mindee.parsing.v2.inference_model import InferenceModel
from mindee.parsing.v2.inference_result import InferenceResult
class Inference:
"""Inference object for a V2 API return."""
model: InferenceModel
"""Model info for the inference."""
file: InferenceFile
"""File info for the inference."""
result: InferenceResult
"""Result of the inference."""
id: Optional[str]
"""ID of the inference."""
def __init__(self, raw_response: StringDict):
self.model = InferenceModel(raw_response["model"])
self.file = InferenceFile(raw_response["file"])
self.result = InferenceResult(raw_response["result"])
self.id = raw_response["id"] if "id" in raw_response else None
def __str__(self) -> str:
alias = f" {self.file.alias}" if self.file.alias else ""
return (
f"Inference\n#########"
f"\nModel\n====="
f"\n:ID: {self.model.id}"
f"\n\nFile\n===="
f"\n:Name: {self.file.name}"
f"\n:Alias:{alias}"
f"{self.result}"
"\n"
)