denkproto 1.0.49__py3-none-any.whl → 1.0.51__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of denkproto might be problematic. Click here for more details.

denkproto/__about__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "1.0.49"
1
+ __version__ = "1.0.51"
File without changes
@@ -0,0 +1,90 @@
1
+ from uuid import UUID
2
+ from typing import Any, List, TypeVar, Callable, Type, cast
3
+
4
+
5
+ T = TypeVar("T")
6
+
7
+
8
+ def from_float(x: Any) -> float:
9
+ assert isinstance(x, (float, int)) and not isinstance(x, bool)
10
+ return float(x)
11
+
12
+
13
+ def to_float(x: Any) -> float:
14
+ assert isinstance(x, (int, float))
15
+ return x
16
+
17
+
18
+ def from_list(f: Callable[[Any], T], x: Any) -> List[T]:
19
+ assert isinstance(x, list)
20
+ return [f(y) for y in x]
21
+
22
+
23
+ def from_int(x: Any) -> int:
24
+ assert isinstance(x, int) and not isinstance(x, bool)
25
+ return x
26
+
27
+
28
+ def to_class(c: Type[T], x: Any) -> dict:
29
+ assert isinstance(x, c)
30
+ return cast(Any, x).to_dict()
31
+
32
+
33
+ class Annotation:
34
+ id: UUID
35
+ label_id: UUID
36
+ value: float
37
+
38
+ def __init__(self, id: UUID, label_id: UUID, value: float) -> None:
39
+ self.id = id
40
+ self.label_id = label_id
41
+ self.value = value
42
+
43
+ @staticmethod
44
+ def from_dict(obj: Any) -> 'Annotation':
45
+ assert isinstance(obj, dict)
46
+ id = UUID(obj.get("id"))
47
+ label_id = UUID(obj.get("label_id"))
48
+ value = from_float(obj.get("value"))
49
+ return Annotation(id, label_id, value)
50
+
51
+ def to_dict(self) -> dict:
52
+ result: dict = {}
53
+ result["id"] = str(self.id)
54
+ result["label_id"] = str(self.label_id)
55
+ result["value"] = to_float(self.value)
56
+ return result
57
+
58
+
59
+ class ClassificationMarkup:
60
+ annotations: List[Annotation]
61
+ height: int
62
+ width: int
63
+
64
+ def __init__(self, annotations: List[Annotation], height: int, width: int) -> None:
65
+ self.annotations = annotations
66
+ self.height = height
67
+ self.width = width
68
+
69
+ @staticmethod
70
+ def from_dict(obj: Any) -> 'ClassificationMarkup':
71
+ assert isinstance(obj, dict)
72
+ annotations = from_list(Annotation.from_dict, obj.get("annotations"))
73
+ height = from_int(obj.get("height"))
74
+ width = from_int(obj.get("width"))
75
+ return ClassificationMarkup(annotations, height, width)
76
+
77
+ def to_dict(self) -> dict:
78
+ result: dict = {}
79
+ result["annotations"] = from_list(lambda x: to_class(Annotation, x), self.annotations)
80
+ result["height"] = from_int(self.height)
81
+ result["width"] = from_int(self.width)
82
+ return result
83
+
84
+
85
+ def classification_markup_from_dict(s: Any) -> ClassificationMarkup:
86
+ return ClassificationMarkup.from_dict(s)
87
+
88
+
89
+ def classification_markup_to_dict(x: ClassificationMarkup) -> Any:
90
+ return to_class(ClassificationMarkup, x)
@@ -0,0 +1,153 @@
1
+ from enum import Enum
2
+ from typing import Optional, Any, List, TypeVar, Type, Callable, cast
3
+ from uuid import UUID
4
+
5
+
6
+ T = TypeVar("T")
7
+ EnumT = TypeVar("EnumT", bound=Enum)
8
+
9
+
10
+ def from_float(x: Any) -> float:
11
+ assert isinstance(x, (float, int)) and not isinstance(x, bool)
12
+ return float(x)
13
+
14
+
15
+ def from_none(x: Any) -> Any:
16
+ assert x is None
17
+ return x
18
+
19
+
20
+ def from_union(fs, x):
21
+ for f in fs:
22
+ try:
23
+ return f(x)
24
+ except:
25
+ pass
26
+ assert False
27
+
28
+
29
+ def from_bool(x: Any) -> bool:
30
+ assert isinstance(x, bool)
31
+ return x
32
+
33
+
34
+ def to_float(x: Any) -> float:
35
+ assert isinstance(x, (int, float))
36
+ return x
37
+
38
+
39
+ def to_enum(c: Type[EnumT], x: Any) -> EnumT:
40
+ assert isinstance(x, c)
41
+ return x.value
42
+
43
+
44
+ def from_list(f: Callable[[Any], T], x: Any) -> List[T]:
45
+ assert isinstance(x, list)
46
+ return [f(y) for y in x]
47
+
48
+
49
+ def from_int(x: Any) -> int:
50
+ assert isinstance(x, int) and not isinstance(x, bool)
51
+ return x
52
+
53
+
54
+ def to_class(c: Type[T], x: Any) -> dict:
55
+ assert isinstance(x, c)
56
+ return cast(Any, x).to_dict()
57
+
58
+
59
+ class AnnotationType(Enum):
60
+ IGNORE = "IGNORE"
61
+ NEGATIVE = "NEGATIVE"
62
+ POSITIVE = "POSITIVE"
63
+ ROI = "ROI"
64
+
65
+
66
+ class Annotation:
67
+ angle: Optional[float]
68
+ annotation_type: AnnotationType
69
+ average_width: float
70
+ bottom_right_x: float
71
+ bottom_right_y: float
72
+ full_orientation: Optional[bool]
73
+ id: UUID
74
+ label_id: UUID
75
+ top_left_x: float
76
+ top_left_y: float
77
+
78
+ def __init__(self, angle: Optional[float], annotation_type: AnnotationType, average_width: float, bottom_right_x: float, bottom_right_y: float, full_orientation: Optional[bool], id: UUID, label_id: UUID, top_left_x: float, top_left_y: float) -> None:
79
+ self.angle = angle
80
+ self.annotation_type = annotation_type
81
+ self.average_width = average_width
82
+ self.bottom_right_x = bottom_right_x
83
+ self.bottom_right_y = bottom_right_y
84
+ self.full_orientation = full_orientation
85
+ self.id = id
86
+ self.label_id = label_id
87
+ self.top_left_x = top_left_x
88
+ self.top_left_y = top_left_y
89
+
90
+ @staticmethod
91
+ def from_dict(obj: Any) -> 'Annotation':
92
+ assert isinstance(obj, dict)
93
+ angle = from_union([from_float, from_none], obj.get("angle"))
94
+ annotation_type = AnnotationType(obj.get("annotation_type"))
95
+ average_width = from_float(obj.get("average_width"))
96
+ bottom_right_x = from_float(obj.get("bottom_right_x"))
97
+ bottom_right_y = from_float(obj.get("bottom_right_y"))
98
+ full_orientation = from_union([from_bool, from_none], obj.get("full_orientation"))
99
+ id = UUID(obj.get("id"))
100
+ label_id = UUID(obj.get("label_id"))
101
+ top_left_x = from_float(obj.get("top_left_x"))
102
+ top_left_y = from_float(obj.get("top_left_y"))
103
+ return Annotation(angle, annotation_type, average_width, bottom_right_x, bottom_right_y, full_orientation, id, label_id, top_left_x, top_left_y)
104
+
105
+ def to_dict(self) -> dict:
106
+ result: dict = {}
107
+ if self.angle is not None:
108
+ result["angle"] = from_union([to_float, from_none], self.angle)
109
+ result["annotation_type"] = to_enum(AnnotationType, self.annotation_type)
110
+ result["average_width"] = to_float(self.average_width)
111
+ result["bottom_right_x"] = to_float(self.bottom_right_x)
112
+ result["bottom_right_y"] = to_float(self.bottom_right_y)
113
+ if self.full_orientation is not None:
114
+ result["full_orientation"] = from_union([from_bool, from_none], self.full_orientation)
115
+ result["id"] = str(self.id)
116
+ result["label_id"] = str(self.label_id)
117
+ result["top_left_x"] = to_float(self.top_left_x)
118
+ result["top_left_y"] = to_float(self.top_left_y)
119
+ return result
120
+
121
+
122
+ class ObjectDetectionMarkup:
123
+ annotations: List[Annotation]
124
+ height: int
125
+ width: int
126
+
127
+ def __init__(self, annotations: List[Annotation], height: int, width: int) -> None:
128
+ self.annotations = annotations
129
+ self.height = height
130
+ self.width = width
131
+
132
+ @staticmethod
133
+ def from_dict(obj: Any) -> 'ObjectDetectionMarkup':
134
+ assert isinstance(obj, dict)
135
+ annotations = from_list(Annotation.from_dict, obj.get("annotations"))
136
+ height = from_int(obj.get("height"))
137
+ width = from_int(obj.get("width"))
138
+ return ObjectDetectionMarkup(annotations, height, width)
139
+
140
+ def to_dict(self) -> dict:
141
+ result: dict = {}
142
+ result["annotations"] = from_list(lambda x: to_class(Annotation, x), self.annotations)
143
+ result["height"] = from_int(self.height)
144
+ result["width"] = from_int(self.width)
145
+ return result
146
+
147
+
148
+ def object_detection_markup_from_dict(s: Any) -> ObjectDetectionMarkup:
149
+ return ObjectDetectionMarkup.from_dict(s)
150
+
151
+
152
+ def object_detection_markup_to_dict(x: ObjectDetectionMarkup) -> Any:
153
+ return to_class(ObjectDetectionMarkup, x)
@@ -0,0 +1,193 @@
1
+ from typing import Any, List, Optional, TypeVar, Callable, Type, cast
2
+ from uuid import UUID
3
+
4
+
5
+ T = TypeVar("T")
6
+
7
+
8
+ def from_float(x: Any) -> float:
9
+ assert isinstance(x, (float, int)) and not isinstance(x, bool)
10
+ return float(x)
11
+
12
+
13
+ def to_float(x: Any) -> float:
14
+ assert isinstance(x, (int, float))
15
+ return x
16
+
17
+
18
+ def from_list(f: Callable[[Any], T], x: Any) -> List[T]:
19
+ assert isinstance(x, list)
20
+ return [f(y) for y in x]
21
+
22
+
23
+ def to_class(c: Type[T], x: Any) -> dict:
24
+ assert isinstance(x, c)
25
+ return cast(Any, x).to_dict()
26
+
27
+
28
+ def from_none(x: Any) -> Any:
29
+ assert x is None
30
+ return x
31
+
32
+
33
+ def from_union(fs, x):
34
+ for f in fs:
35
+ try:
36
+ return f(x)
37
+ except:
38
+ pass
39
+ assert False
40
+
41
+
42
+ def from_str(x: Any) -> str:
43
+ assert isinstance(x, str)
44
+ return x
45
+
46
+
47
+ def from_int(x: Any) -> int:
48
+ assert isinstance(x, int) and not isinstance(x, bool)
49
+ return x
50
+
51
+
52
+ class BoundingBox:
53
+ bottom_right_x: float
54
+ bottom_right_y: float
55
+ top_left_x: float
56
+ top_left_y: float
57
+
58
+ def __init__(self, bottom_right_x: float, bottom_right_y: float, top_left_x: float, top_left_y: float) -> None:
59
+ self.bottom_right_x = bottom_right_x
60
+ self.bottom_right_y = bottom_right_y
61
+ self.top_left_x = top_left_x
62
+ self.top_left_y = top_left_y
63
+
64
+ @staticmethod
65
+ def from_dict(obj: Any) -> 'BoundingBox':
66
+ assert isinstance(obj, dict)
67
+ bottom_right_x = from_float(obj.get("bottom_right_x"))
68
+ bottom_right_y = from_float(obj.get("bottom_right_y"))
69
+ top_left_x = from_float(obj.get("top_left_x"))
70
+ top_left_y = from_float(obj.get("top_left_y"))
71
+ return BoundingBox(bottom_right_x, bottom_right_y, top_left_x, top_left_y)
72
+
73
+ def to_dict(self) -> dict:
74
+ result: dict = {}
75
+ result["bottom_right_x"] = to_float(self.bottom_right_x)
76
+ result["bottom_right_y"] = to_float(self.bottom_right_y)
77
+ result["top_left_x"] = to_float(self.top_left_x)
78
+ result["top_left_y"] = to_float(self.top_left_y)
79
+ return result
80
+
81
+
82
+ class Point:
83
+ x: float
84
+ y: float
85
+
86
+ def __init__(self, x: float, y: float) -> None:
87
+ self.x = x
88
+ self.y = y
89
+
90
+ @staticmethod
91
+ def from_dict(obj: Any) -> 'Point':
92
+ assert isinstance(obj, dict)
93
+ x = from_float(obj.get("x"))
94
+ y = from_float(obj.get("y"))
95
+ return Point(x, y)
96
+
97
+ def to_dict(self) -> dict:
98
+ result: dict = {}
99
+ result["x"] = to_float(self.x)
100
+ result["y"] = to_float(self.y)
101
+ return result
102
+
103
+
104
+ class Polygon:
105
+ points: List[Point]
106
+
107
+ def __init__(self, points: List[Point]) -> None:
108
+ self.points = points
109
+
110
+ @staticmethod
111
+ def from_dict(obj: Any) -> 'Polygon':
112
+ assert isinstance(obj, dict)
113
+ points = from_list(Point.from_dict, obj.get("points"))
114
+ return Polygon(points)
115
+
116
+ def to_dict(self) -> dict:
117
+ result: dict = {}
118
+ result["points"] = from_list(lambda x: to_class(Point, x), self.points)
119
+ return result
120
+
121
+
122
+ class Annotation:
123
+ bounding_box: Optional[BoundingBox]
124
+ id: UUID
125
+ label_id: UUID
126
+ polygon: Optional[Polygon]
127
+ text: str
128
+
129
+ def __init__(self, bounding_box: Optional[BoundingBox], id: UUID, label_id: UUID, polygon: Optional[Polygon], text: str) -> None:
130
+ self.bounding_box = bounding_box
131
+ self.id = id
132
+ self.label_id = label_id
133
+ self.polygon = polygon
134
+ self.text = text
135
+
136
+ @staticmethod
137
+ def from_dict(obj: Any) -> 'Annotation':
138
+ assert isinstance(obj, dict)
139
+ bounding_box = from_union([BoundingBox.from_dict, from_none], obj.get("bounding_box"))
140
+ id = UUID(obj.get("id"))
141
+ label_id = UUID(obj.get("label_id"))
142
+ polygon = from_union([Polygon.from_dict, from_none], obj.get("polygon"))
143
+ text = from_str(obj.get("text"))
144
+ return Annotation(bounding_box, id, label_id, polygon, text)
145
+
146
+ def to_dict(self) -> dict:
147
+ result: dict = {}
148
+ if self.bounding_box is not None:
149
+ result["bounding_box"] = from_union([lambda x: to_class(BoundingBox, x), from_none], self.bounding_box)
150
+ result["id"] = str(self.id)
151
+ result["label_id"] = str(self.label_id)
152
+ if self.polygon is not None:
153
+ result["polygon"] = from_union([lambda x: to_class(Polygon, x), from_none], self.polygon)
154
+ result["text"] = from_str(self.text)
155
+ return result
156
+
157
+
158
+ class OcrMarkup:
159
+ annotations: List[Annotation]
160
+ average_object_widths: List[float]
161
+ height: int
162
+ width: int
163
+
164
+ def __init__(self, annotations: List[Annotation], average_object_widths: List[float], height: int, width: int) -> None:
165
+ self.annotations = annotations
166
+ self.average_object_widths = average_object_widths
167
+ self.height = height
168
+ self.width = width
169
+
170
+ @staticmethod
171
+ def from_dict(obj: Any) -> 'OcrMarkup':
172
+ assert isinstance(obj, dict)
173
+ annotations = from_list(Annotation.from_dict, obj.get("annotations"))
174
+ average_object_widths = from_list(from_float, obj.get("average_object_widths"))
175
+ height = from_int(obj.get("height"))
176
+ width = from_int(obj.get("width"))
177
+ return OcrMarkup(annotations, average_object_widths, height, width)
178
+
179
+ def to_dict(self) -> dict:
180
+ result: dict = {}
181
+ result["annotations"] = from_list(lambda x: to_class(Annotation, x), self.annotations)
182
+ result["average_object_widths"] = from_list(to_float, self.average_object_widths)
183
+ result["height"] = from_int(self.height)
184
+ result["width"] = from_int(self.width)
185
+ return result
186
+
187
+
188
+ def ocr_markup_from_dict(s: Any) -> OcrMarkup:
189
+ return OcrMarkup.from_dict(s)
190
+
191
+
192
+ def ocr_markup_to_dict(x: OcrMarkup) -> Any:
193
+ return to_class(OcrMarkup, x)
@@ -0,0 +1,526 @@
1
+ from enum import Enum
2
+ from typing import Any, List, Optional, TypeVar, Callable, Type, cast
3
+ from uuid import UUID
4
+
5
+
6
+ T = TypeVar("T")
7
+ EnumT = TypeVar("EnumT", bound=Enum)
8
+
9
+
10
+ def from_float(x: Any) -> float:
11
+ assert isinstance(x, (float, int)) and not isinstance(x, bool)
12
+ return float(x)
13
+
14
+
15
+ def to_float(x: Any) -> float:
16
+ assert isinstance(x, (int, float))
17
+ return x
18
+
19
+
20
+ def from_str(x: Any) -> str:
21
+ assert isinstance(x, str)
22
+ return x
23
+
24
+
25
+ def from_list(f: Callable[[Any], T], x: Any) -> List[T]:
26
+ assert isinstance(x, list)
27
+ return [f(y) for y in x]
28
+
29
+
30
+ def from_int(x: Any) -> int:
31
+ assert isinstance(x, int) and not isinstance(x, bool)
32
+ return x
33
+
34
+
35
+ def to_class(c: Type[T], x: Any) -> dict:
36
+ assert isinstance(x, c)
37
+ return cast(Any, x).to_dict()
38
+
39
+
40
+ def from_none(x: Any) -> Any:
41
+ assert x is None
42
+ return x
43
+
44
+
45
+ def from_union(fs, x):
46
+ for f in fs:
47
+ try:
48
+ return f(x)
49
+ except:
50
+ pass
51
+ assert False
52
+
53
+
54
+ def to_enum(c: Type[EnumT], x: Any) -> EnumT:
55
+ assert isinstance(x, c)
56
+ return x.value
57
+
58
+
59
+ class AnnotationType(Enum):
60
+ IGNORE = "IGNORE"
61
+ NEGATIVE = "NEGATIVE"
62
+ POSITIVE = "POSITIVE"
63
+ ROI = "ROI"
64
+
65
+
66
+ class CircleAnnotation:
67
+ center_x: float
68
+ center_y: float
69
+ radius: float
70
+
71
+ def __init__(self, center_x: float, center_y: float, radius: float) -> None:
72
+ self.center_x = center_x
73
+ self.center_y = center_y
74
+ self.radius = radius
75
+
76
+ @staticmethod
77
+ def from_dict(obj: Any) -> 'CircleAnnotation':
78
+ assert isinstance(obj, dict)
79
+ center_x = from_float(obj.get("center_x"))
80
+ center_y = from_float(obj.get("center_y"))
81
+ radius = from_float(obj.get("radius"))
82
+ return CircleAnnotation(center_x, center_y, radius)
83
+
84
+ def to_dict(self) -> dict:
85
+ result: dict = {}
86
+ result["center_x"] = to_float(self.center_x)
87
+ result["center_y"] = to_float(self.center_y)
88
+ result["radius"] = to_float(self.radius)
89
+ return result
90
+
91
+
92
+ class MagicwandAnnotationPoint:
93
+ x: float
94
+ y: float
95
+
96
+ def __init__(self, x: float, y: float) -> None:
97
+ self.x = x
98
+ self.y = y
99
+
100
+ @staticmethod
101
+ def from_dict(obj: Any) -> 'MagicwandAnnotationPoint':
102
+ assert isinstance(obj, dict)
103
+ x = from_float(obj.get("x"))
104
+ y = from_float(obj.get("y"))
105
+ return MagicwandAnnotationPoint(x, y)
106
+
107
+ def to_dict(self) -> dict:
108
+ result: dict = {}
109
+ result["x"] = to_float(self.x)
110
+ result["y"] = to_float(self.y)
111
+ return result
112
+
113
+
114
+ class MagicwandAnnotation:
115
+ bottom_right_x: float
116
+ bottom_right_y: float
117
+ center_x: float
118
+ center_y: float
119
+ data_url: str
120
+ points: List[MagicwandAnnotationPoint]
121
+ threshold: int
122
+ top_left_x: float
123
+ top_left_y: float
124
+
125
+ def __init__(self, bottom_right_x: float, bottom_right_y: float, center_x: float, center_y: float, data_url: str, points: List[MagicwandAnnotationPoint], threshold: int, top_left_x: float, top_left_y: float) -> None:
126
+ self.bottom_right_x = bottom_right_x
127
+ self.bottom_right_y = bottom_right_y
128
+ self.center_x = center_x
129
+ self.center_y = center_y
130
+ self.data_url = data_url
131
+ self.points = points
132
+ self.threshold = threshold
133
+ self.top_left_x = top_left_x
134
+ self.top_left_y = top_left_y
135
+
136
+ @staticmethod
137
+ def from_dict(obj: Any) -> 'MagicwandAnnotation':
138
+ assert isinstance(obj, dict)
139
+ bottom_right_x = from_float(obj.get("bottom_right_x"))
140
+ bottom_right_y = from_float(obj.get("bottom_right_y"))
141
+ center_x = from_float(obj.get("center_x"))
142
+ center_y = from_float(obj.get("center_y"))
143
+ data_url = from_str(obj.get("dataURL"))
144
+ points = from_list(MagicwandAnnotationPoint.from_dict, obj.get("points"))
145
+ threshold = from_int(obj.get("threshold"))
146
+ top_left_x = from_float(obj.get("top_left_x"))
147
+ top_left_y = from_float(obj.get("top_left_y"))
148
+ return MagicwandAnnotation(bottom_right_x, bottom_right_y, center_x, center_y, data_url, points, threshold, top_left_x, top_left_y)
149
+
150
+ def to_dict(self) -> dict:
151
+ result: dict = {}
152
+ result["bottom_right_x"] = to_float(self.bottom_right_x)
153
+ result["bottom_right_y"] = to_float(self.bottom_right_y)
154
+ result["center_x"] = to_float(self.center_x)
155
+ result["center_y"] = to_float(self.center_y)
156
+ result["dataURL"] = from_str(self.data_url)
157
+ result["points"] = from_list(lambda x: to_class(MagicwandAnnotationPoint, x), self.points)
158
+ result["threshold"] = from_int(self.threshold)
159
+ result["top_left_x"] = to_float(self.top_left_x)
160
+ result["top_left_y"] = to_float(self.top_left_y)
161
+ return result
162
+
163
+
164
+ class PenAnnotationPoint:
165
+ x: float
166
+ y: float
167
+
168
+ def __init__(self, x: float, y: float) -> None:
169
+ self.x = x
170
+ self.y = y
171
+
172
+ @staticmethod
173
+ def from_dict(obj: Any) -> 'PenAnnotationPoint':
174
+ assert isinstance(obj, dict)
175
+ x = from_float(obj.get("x"))
176
+ y = from_float(obj.get("y"))
177
+ return PenAnnotationPoint(x, y)
178
+
179
+ def to_dict(self) -> dict:
180
+ result: dict = {}
181
+ result["x"] = to_float(self.x)
182
+ result["y"] = to_float(self.y)
183
+ return result
184
+
185
+
186
+ class PenAnnotation:
187
+ bottom_right_x: float
188
+ bottom_right_y: float
189
+ data_url: str
190
+ points: List[PenAnnotationPoint]
191
+ thickness: float
192
+ top_left_x: float
193
+ top_left_y: float
194
+
195
+ def __init__(self, bottom_right_x: float, bottom_right_y: float, data_url: str, points: List[PenAnnotationPoint], thickness: float, top_left_x: float, top_left_y: float) -> None:
196
+ self.bottom_right_x = bottom_right_x
197
+ self.bottom_right_y = bottom_right_y
198
+ self.data_url = data_url
199
+ self.points = points
200
+ self.thickness = thickness
201
+ self.top_left_x = top_left_x
202
+ self.top_left_y = top_left_y
203
+
204
+ @staticmethod
205
+ def from_dict(obj: Any) -> 'PenAnnotation':
206
+ assert isinstance(obj, dict)
207
+ bottom_right_x = from_float(obj.get("bottom_right_x"))
208
+ bottom_right_y = from_float(obj.get("bottom_right_y"))
209
+ data_url = from_str(obj.get("dataURL"))
210
+ points = from_list(PenAnnotationPoint.from_dict, obj.get("points"))
211
+ thickness = from_float(obj.get("thickness"))
212
+ top_left_x = from_float(obj.get("top_left_x"))
213
+ top_left_y = from_float(obj.get("top_left_y"))
214
+ return PenAnnotation(bottom_right_x, bottom_right_y, data_url, points, thickness, top_left_x, top_left_y)
215
+
216
+ def to_dict(self) -> dict:
217
+ result: dict = {}
218
+ result["bottom_right_x"] = to_float(self.bottom_right_x)
219
+ result["bottom_right_y"] = to_float(self.bottom_right_y)
220
+ result["dataURL"] = from_str(self.data_url)
221
+ result["points"] = from_list(lambda x: to_class(PenAnnotationPoint, x), self.points)
222
+ result["thickness"] = to_float(self.thickness)
223
+ result["top_left_x"] = to_float(self.top_left_x)
224
+ result["top_left_y"] = to_float(self.top_left_y)
225
+ return result
226
+
227
+
228
+ class PixelAnnotation:
229
+ blob_id: UUID
230
+ bottom_right_x: float
231
+ bottom_right_y: float
232
+ top_left_x: float
233
+ top_left_y: float
234
+
235
+ def __init__(self, blob_id: UUID, bottom_right_x: float, bottom_right_y: float, top_left_x: float, top_left_y: float) -> None:
236
+ self.blob_id = blob_id
237
+ self.bottom_right_x = bottom_right_x
238
+ self.bottom_right_y = bottom_right_y
239
+ self.top_left_x = top_left_x
240
+ self.top_left_y = top_left_y
241
+
242
+ @staticmethod
243
+ def from_dict(obj: Any) -> 'PixelAnnotation':
244
+ assert isinstance(obj, dict)
245
+ blob_id = UUID(obj.get("blob_id"))
246
+ bottom_right_x = from_float(obj.get("bottom_right_x"))
247
+ bottom_right_y = from_float(obj.get("bottom_right_y"))
248
+ top_left_x = from_float(obj.get("top_left_x"))
249
+ top_left_y = from_float(obj.get("top_left_y"))
250
+ return PixelAnnotation(blob_id, bottom_right_x, bottom_right_y, top_left_x, top_left_y)
251
+
252
+ def to_dict(self) -> dict:
253
+ result: dict = {}
254
+ result["blob_id"] = str(self.blob_id)
255
+ result["bottom_right_x"] = to_float(self.bottom_right_x)
256
+ result["bottom_right_y"] = to_float(self.bottom_right_y)
257
+ result["top_left_x"] = to_float(self.top_left_x)
258
+ result["top_left_y"] = to_float(self.top_left_y)
259
+ return result
260
+
261
+
262
+ class PolygonAnnotationPoint:
263
+ x: float
264
+ y: float
265
+
266
+ def __init__(self, x: float, y: float) -> None:
267
+ self.x = x
268
+ self.y = y
269
+
270
+ @staticmethod
271
+ def from_dict(obj: Any) -> 'PolygonAnnotationPoint':
272
+ assert isinstance(obj, dict)
273
+ x = from_float(obj.get("x"))
274
+ y = from_float(obj.get("y"))
275
+ return PolygonAnnotationPoint(x, y)
276
+
277
+ def to_dict(self) -> dict:
278
+ result: dict = {}
279
+ result["x"] = to_float(self.x)
280
+ result["y"] = to_float(self.y)
281
+ return result
282
+
283
+
284
+ class PolygonAnnotation:
285
+ points: List[PolygonAnnotationPoint]
286
+
287
+ def __init__(self, points: List[PolygonAnnotationPoint]) -> None:
288
+ self.points = points
289
+
290
+ @staticmethod
291
+ def from_dict(obj: Any) -> 'PolygonAnnotation':
292
+ assert isinstance(obj, dict)
293
+ points = from_list(PolygonAnnotationPoint.from_dict, obj.get("points"))
294
+ return PolygonAnnotation(points)
295
+
296
+ def to_dict(self) -> dict:
297
+ result: dict = {}
298
+ result["points"] = from_list(lambda x: to_class(PolygonAnnotationPoint, x), self.points)
299
+ return result
300
+
301
+
302
+ class RectangleAnnotation:
303
+ bottom_right_x: float
304
+ bottom_right_y: float
305
+ top_left_x: float
306
+ top_left_y: float
307
+
308
+ def __init__(self, bottom_right_x: float, bottom_right_y: float, top_left_x: float, top_left_y: float) -> None:
309
+ self.bottom_right_x = bottom_right_x
310
+ self.bottom_right_y = bottom_right_y
311
+ self.top_left_x = top_left_x
312
+ self.top_left_y = top_left_y
313
+
314
+ @staticmethod
315
+ def from_dict(obj: Any) -> 'RectangleAnnotation':
316
+ assert isinstance(obj, dict)
317
+ bottom_right_x = from_float(obj.get("bottom_right_x"))
318
+ bottom_right_y = from_float(obj.get("bottom_right_y"))
319
+ top_left_x = from_float(obj.get("top_left_x"))
320
+ top_left_y = from_float(obj.get("top_left_y"))
321
+ return RectangleAnnotation(bottom_right_x, bottom_right_y, top_left_x, top_left_y)
322
+
323
+ def to_dict(self) -> dict:
324
+ result: dict = {}
325
+ result["bottom_right_x"] = to_float(self.bottom_right_x)
326
+ result["bottom_right_y"] = to_float(self.bottom_right_y)
327
+ result["top_left_x"] = to_float(self.top_left_x)
328
+ result["top_left_y"] = to_float(self.top_left_y)
329
+ return result
330
+
331
+
332
+ class SausageAnnotationPoint:
333
+ x: float
334
+ y: float
335
+
336
+ def __init__(self, x: float, y: float) -> None:
337
+ self.x = x
338
+ self.y = y
339
+
340
+ @staticmethod
341
+ def from_dict(obj: Any) -> 'SausageAnnotationPoint':
342
+ assert isinstance(obj, dict)
343
+ x = from_float(obj.get("x"))
344
+ y = from_float(obj.get("y"))
345
+ return SausageAnnotationPoint(x, y)
346
+
347
+ def to_dict(self) -> dict:
348
+ result: dict = {}
349
+ result["x"] = to_float(self.x)
350
+ result["y"] = to_float(self.y)
351
+ return result
352
+
353
+
354
+ class SausageAnnotation:
355
+ bottom_right_x: float
356
+ bottom_right_y: float
357
+ data_url: str
358
+ points: List[SausageAnnotationPoint]
359
+ radius: float
360
+ top_left_x: float
361
+ top_left_y: float
362
+
363
+ def __init__(self, bottom_right_x: float, bottom_right_y: float, data_url: str, points: List[SausageAnnotationPoint], radius: float, top_left_x: float, top_left_y: float) -> None:
364
+ self.bottom_right_x = bottom_right_x
365
+ self.bottom_right_y = bottom_right_y
366
+ self.data_url = data_url
367
+ self.points = points
368
+ self.radius = radius
369
+ self.top_left_x = top_left_x
370
+ self.top_left_y = top_left_y
371
+
372
+ @staticmethod
373
+ def from_dict(obj: Any) -> 'SausageAnnotation':
374
+ assert isinstance(obj, dict)
375
+ bottom_right_x = from_float(obj.get("bottom_right_x"))
376
+ bottom_right_y = from_float(obj.get("bottom_right_y"))
377
+ data_url = from_str(obj.get("dataURL"))
378
+ points = from_list(SausageAnnotationPoint.from_dict, obj.get("points"))
379
+ radius = from_float(obj.get("radius"))
380
+ top_left_x = from_float(obj.get("top_left_x"))
381
+ top_left_y = from_float(obj.get("top_left_y"))
382
+ return SausageAnnotation(bottom_right_x, bottom_right_y, data_url, points, radius, top_left_x, top_left_y)
383
+
384
+ def to_dict(self) -> dict:
385
+ result: dict = {}
386
+ result["bottom_right_x"] = to_float(self.bottom_right_x)
387
+ result["bottom_right_y"] = to_float(self.bottom_right_y)
388
+ result["dataURL"] = from_str(self.data_url)
389
+ result["points"] = from_list(lambda x: to_class(SausageAnnotationPoint, x), self.points)
390
+ result["radius"] = to_float(self.radius)
391
+ result["top_left_x"] = to_float(self.top_left_x)
392
+ result["top_left_y"] = to_float(self.top_left_y)
393
+ return result
394
+
395
+
396
+ class Annotation:
397
+ annotation_type: AnnotationType
398
+ average_width: float
399
+ circle_annotation: Optional[CircleAnnotation]
400
+ id: UUID
401
+ label_id: UUID
402
+ magicwand_annotation: Optional[MagicwandAnnotation]
403
+ pen_annotation: Optional[PenAnnotation]
404
+ pixel_annotation: Optional[PixelAnnotation]
405
+ polygon_annotation: Optional[PolygonAnnotation]
406
+ rectangle_annotation: Optional[RectangleAnnotation]
407
+ sausage_annotation: Optional[SausageAnnotation]
408
+
409
+ def __init__(self, annotation_type: AnnotationType, average_width: float, circle_annotation: Optional[CircleAnnotation], id: UUID, label_id: UUID, magicwand_annotation: Optional[MagicwandAnnotation], pen_annotation: Optional[PenAnnotation], pixel_annotation: Optional[PixelAnnotation], polygon_annotation: Optional[PolygonAnnotation], rectangle_annotation: Optional[RectangleAnnotation], sausage_annotation: Optional[SausageAnnotation]) -> None:
410
+ self.annotation_type = annotation_type
411
+ self.average_width = average_width
412
+ self.circle_annotation = circle_annotation
413
+ self.id = id
414
+ self.label_id = label_id
415
+ self.magicwand_annotation = magicwand_annotation
416
+ self.pen_annotation = pen_annotation
417
+ self.pixel_annotation = pixel_annotation
418
+ self.polygon_annotation = polygon_annotation
419
+ self.rectangle_annotation = rectangle_annotation
420
+ self.sausage_annotation = sausage_annotation
421
+
422
+ @staticmethod
423
+ def from_dict(obj: Any) -> 'Annotation':
424
+ assert isinstance(obj, dict)
425
+ annotation_type = AnnotationType(obj.get("annotation_type"))
426
+ average_width = from_float(obj.get("average_width"))
427
+ circle_annotation = from_union([CircleAnnotation.from_dict, from_none], obj.get("circle_annotation"))
428
+ id = UUID(obj.get("id"))
429
+ label_id = UUID(obj.get("label_id"))
430
+ magicwand_annotation = from_union([MagicwandAnnotation.from_dict, from_none], obj.get("magicwand_annotation"))
431
+ pen_annotation = from_union([PenAnnotation.from_dict, from_none], obj.get("pen_annotation"))
432
+ pixel_annotation = from_union([PixelAnnotation.from_dict, from_none], obj.get("pixel_annotation"))
433
+ polygon_annotation = from_union([PolygonAnnotation.from_dict, from_none], obj.get("polygon_annotation"))
434
+ rectangle_annotation = from_union([RectangleAnnotation.from_dict, from_none], obj.get("rectangle_annotation"))
435
+ sausage_annotation = from_union([SausageAnnotation.from_dict, from_none], obj.get("sausage_annotation"))
436
+ return Annotation(annotation_type, average_width, circle_annotation, id, label_id, magicwand_annotation, pen_annotation, pixel_annotation, polygon_annotation, rectangle_annotation, sausage_annotation)
437
+
438
+ def to_dict(self) -> dict:
439
+ result: dict = {}
440
+ result["annotation_type"] = to_enum(AnnotationType, self.annotation_type)
441
+ result["average_width"] = to_float(self.average_width)
442
+ if self.circle_annotation is not None:
443
+ result["circle_annotation"] = from_union([lambda x: to_class(CircleAnnotation, x), from_none], self.circle_annotation)
444
+ result["id"] = str(self.id)
445
+ result["label_id"] = str(self.label_id)
446
+ if self.magicwand_annotation is not None:
447
+ result["magicwand_annotation"] = from_union([lambda x: to_class(MagicwandAnnotation, x), from_none], self.magicwand_annotation)
448
+ if self.pen_annotation is not None:
449
+ result["pen_annotation"] = from_union([lambda x: to_class(PenAnnotation, x), from_none], self.pen_annotation)
450
+ if self.pixel_annotation is not None:
451
+ result["pixel_annotation"] = from_union([lambda x: to_class(PixelAnnotation, x), from_none], self.pixel_annotation)
452
+ if self.polygon_annotation is not None:
453
+ result["polygon_annotation"] = from_union([lambda x: to_class(PolygonAnnotation, x), from_none], self.polygon_annotation)
454
+ if self.rectangle_annotation is not None:
455
+ result["rectangle_annotation"] = from_union([lambda x: to_class(RectangleAnnotation, x), from_none], self.rectangle_annotation)
456
+ if self.sausage_annotation is not None:
457
+ result["sausage_annotation"] = from_union([lambda x: to_class(SausageAnnotation, x), from_none], self.sausage_annotation)
458
+ return result
459
+
460
+
461
+ class SegmentationMap:
462
+ blob_id: UUID
463
+ label_id: UUID
464
+ thumbnail: str
465
+
466
+ def __init__(self, blob_id: UUID, label_id: UUID, thumbnail: str) -> None:
467
+ self.blob_id = blob_id
468
+ self.label_id = label_id
469
+ self.thumbnail = thumbnail
470
+
471
+ @staticmethod
472
+ def from_dict(obj: Any) -> 'SegmentationMap':
473
+ assert isinstance(obj, dict)
474
+ blob_id = UUID(obj.get("blob_id"))
475
+ label_id = UUID(obj.get("label_id"))
476
+ thumbnail = from_str(obj.get("thumbnail"))
477
+ return SegmentationMap(blob_id, label_id, thumbnail)
478
+
479
+ def to_dict(self) -> dict:
480
+ result: dict = {}
481
+ result["blob_id"] = str(self.blob_id)
482
+ result["label_id"] = str(self.label_id)
483
+ result["thumbnail"] = from_str(self.thumbnail)
484
+ return result
485
+
486
+
487
+ class SegmentationMarkup:
488
+ annotations: List[Annotation]
489
+ average_object_widths: List[float]
490
+ height: int
491
+ segmentation_maps: List[SegmentationMap]
492
+ width: int
493
+
494
+ def __init__(self, annotations: List[Annotation], average_object_widths: List[float], height: int, segmentation_maps: List[SegmentationMap], width: int) -> None:
495
+ self.annotations = annotations
496
+ self.average_object_widths = average_object_widths
497
+ self.height = height
498
+ self.segmentation_maps = segmentation_maps
499
+ self.width = width
500
+
501
+ @staticmethod
502
+ def from_dict(obj: Any) -> 'SegmentationMarkup':
503
+ assert isinstance(obj, dict)
504
+ annotations = from_list(Annotation.from_dict, obj.get("annotations"))
505
+ average_object_widths = from_list(from_float, obj.get("average_object_widths"))
506
+ height = from_int(obj.get("height"))
507
+ segmentation_maps = from_list(SegmentationMap.from_dict, obj.get("segmentation_maps"))
508
+ width = from_int(obj.get("width"))
509
+ return SegmentationMarkup(annotations, average_object_widths, height, segmentation_maps, width)
510
+
511
+ def to_dict(self) -> dict:
512
+ result: dict = {}
513
+ result["annotations"] = from_list(lambda x: to_class(Annotation, x), self.annotations)
514
+ result["average_object_widths"] = from_list(to_float, self.average_object_widths)
515
+ result["height"] = from_int(self.height)
516
+ result["segmentation_maps"] = from_list(lambda x: to_class(SegmentationMap, x), self.segmentation_maps)
517
+ result["width"] = from_int(self.width)
518
+ return result
519
+
520
+
521
+ def segmentation_markup_from_dict(s: Any) -> SegmentationMarkup:
522
+ return SegmentationMarkup.from_dict(s)
523
+
524
+
525
+ def segmentation_markup_to_dict(x: SegmentationMarkup) -> Any:
526
+ return to_class(SegmentationMarkup, x)
@@ -1,5 +1,5 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: denkproto
3
- Version: 1.0.49
3
+ Version: 1.0.51
4
4
  Requires-Python: >=3.10
5
5
  Requires-Dist: protobuf>=3.20.3
@@ -4,7 +4,7 @@ denkproto/DENKbuffer_pb2_grpc.py,sha256=-CPJPM4FOqwvwV8-f1iJlD18UD9juVIIHfdWUecu
4
4
  denkproto/ImageAnalysis_ProtobufMessages_pb2.py,sha256=iEY0j9ySGUThnqTdYD4uAVr9P3GiC5R02iK53zEOXUQ,21015
5
5
  denkproto/ImageAnalysis_ProtobufMessages_pb2.pyi,sha256=5LFtxrmYpJHizDDNGFTkL7-NQ_TkwqCSdq7vcv3lg-c,36243
6
6
  denkproto/ImageAnalysis_ProtobufMessages_pb2_grpc.py,sha256=l3agtDjgu4jay6P9TRnHhyhJ-7UdoII27ywhw3k84oo,911
7
- denkproto/__about__.py,sha256=cLeI-2KMNxZsDCBNigqMv6a6lpKn76no1bUUjQvyFw8,23
7
+ denkproto/__about__.py,sha256=QX1ke24vMqdXVlwT-R7XbSu-SafqDs-7vhbUduaYw8E,23
8
8
  denkproto/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  denkproto/denkcache_pb2.py,sha256=fvrIvDfK8ED_w0EfO0tIrLMsBh2T5yvVI-sNFCK7NEQ,6627
10
10
  denkproto/denkcache_pb2.pyi,sha256=qOzFOkddUapSJZz5d_mqcfHvWDAmM-70m_7FeM7n5fI,5595
@@ -22,6 +22,11 @@ denkproto/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  denkproto/results_pb2.py,sha256=rBZ4HIHgdKHdASDbF8mTmZ0_xi1ffq3YJ2g_cvzIlhk,14109
23
23
  denkproto/results_pb2.pyi,sha256=8l1v1QenLzWlYnQtnCBqzXMMHUagOTalq9xJKfK6FKo,26711
24
24
  denkproto/results_pb2_grpc.py,sha256=z-4qcDMjjuPRy7lDtECTtReByVEyz3fjIPES9dMlO58,888
25
- denkproto-1.0.49.dist-info/METADATA,sha256=48Uwo4Kavhnl9T2HLfMEWniLOuGD-i0iPo6ZK7aEPbU,110
26
- denkproto-1.0.49.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
27
- denkproto-1.0.49.dist-info/RECORD,,
25
+ denkproto/json/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
+ denkproto/json/classification_markup.py,sha256=vTu0H7Cb3gU6UUUSg1vDTRlFUorZrjMbcp_yx6UssZA,2461
27
+ denkproto/json/object_detection_markup.py,sha256=T0hcFPq8F_galjDjRC9dbcRVwCSOYtu2jt9wpEeHlQs,4904
28
+ denkproto/json/ocr_markup.py,sha256=IaWbTCcJbLnS0e4u0PB1m8F-UpEwaQNTexVYKdXUPHI,5771
29
+ denkproto/json/segmentation_markup.py,sha256=AQLZ-m7hq1hMPc9kLwhETaFPmTXfV3Omah5CIi-cJF0,19893
30
+ denkproto-1.0.51.dist-info/METADATA,sha256=1_vBw4w2UsvpWnDNiVUEQ8WiLusa-ljkSJJiDzRY3vA,110
31
+ denkproto-1.0.51.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
32
+ denkproto-1.0.51.dist-info/RECORD,,