denkproto 1.0.91__py3-none-any.whl → 1.0.93__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 +1 -1
- denkproto/json/annotation_comparer_request.py +1014 -0
- denkproto/json/ocr_prediction_request.py +510 -0
- denkproto/json/prediction_request.py +263 -0
- {denkproto-1.0.91.dist-info → denkproto-1.0.93.dist-info}/METADATA +1 -1
- {denkproto-1.0.91.dist-info → denkproto-1.0.93.dist-info}/RECORD +7 -4
- {denkproto-1.0.91.dist-info → denkproto-1.0.93.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,1014 @@
|
|
|
1
|
+
from uuid import UUID
|
|
2
|
+
from typing import Any, List, Optional, TypeVar, Callable, Type, cast
|
|
3
|
+
from enum import Enum
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
T = TypeVar("T")
|
|
7
|
+
EnumT = TypeVar("EnumT", bound=Enum)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def from_int(x: Any) -> int:
|
|
11
|
+
assert isinstance(x, int) and not isinstance(x, bool)
|
|
12
|
+
return x
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def from_list(f: Callable[[Any], T], x: Any) -> List[T]:
|
|
16
|
+
assert isinstance(x, list)
|
|
17
|
+
return [f(y) for y in x]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def from_str(x: Any) -> str:
|
|
21
|
+
assert isinstance(x, str)
|
|
22
|
+
return x
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def to_class(c: Type[T], x: Any) -> dict:
|
|
26
|
+
assert isinstance(x, c)
|
|
27
|
+
return cast(Any, x).to_dict()
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def from_float(x: Any) -> float:
|
|
31
|
+
assert isinstance(x, (float, int)) and not isinstance(x, bool)
|
|
32
|
+
return float(x)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def to_float(x: Any) -> float:
|
|
36
|
+
assert isinstance(x, (int, float))
|
|
37
|
+
return x
|
|
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 from_bool(x: Any) -> bool:
|
|
55
|
+
assert isinstance(x, bool)
|
|
56
|
+
return x
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def to_enum(c: Type[EnumT], x: Any) -> EnumT:
|
|
60
|
+
assert isinstance(x, c)
|
|
61
|
+
return x.value
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class Image:
|
|
65
|
+
blob_id: UUID
|
|
66
|
+
height: int
|
|
67
|
+
owned_by_group_id: UUID
|
|
68
|
+
width: int
|
|
69
|
+
|
|
70
|
+
def __init__(self, blob_id: UUID, height: int, owned_by_group_id: UUID, width: int) -> None:
|
|
71
|
+
self.blob_id = blob_id
|
|
72
|
+
self.height = height
|
|
73
|
+
self.owned_by_group_id = owned_by_group_id
|
|
74
|
+
self.width = width
|
|
75
|
+
|
|
76
|
+
@staticmethod
|
|
77
|
+
def from_dict(obj: Any) -> 'Image':
|
|
78
|
+
assert isinstance(obj, dict)
|
|
79
|
+
blob_id = UUID(obj.get("blob_id"))
|
|
80
|
+
height = from_int(obj.get("height"))
|
|
81
|
+
owned_by_group_id = UUID(obj.get("owned_by_group_id"))
|
|
82
|
+
width = from_int(obj.get("width"))
|
|
83
|
+
return Image(blob_id, height, owned_by_group_id, width)
|
|
84
|
+
|
|
85
|
+
def to_dict(self) -> dict:
|
|
86
|
+
result: dict = {}
|
|
87
|
+
result["blob_id"] = str(self.blob_id)
|
|
88
|
+
result["height"] = from_int(self.height)
|
|
89
|
+
result["owned_by_group_id"] = str(self.owned_by_group_id)
|
|
90
|
+
result["width"] = from_int(self.width)
|
|
91
|
+
return result
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class ClassLabelElement:
|
|
95
|
+
id: UUID
|
|
96
|
+
idx: int
|
|
97
|
+
|
|
98
|
+
def __init__(self, id: UUID, idx: int) -> None:
|
|
99
|
+
self.id = id
|
|
100
|
+
self.idx = idx
|
|
101
|
+
|
|
102
|
+
@staticmethod
|
|
103
|
+
def from_dict(obj: Any) -> 'ClassLabelElement':
|
|
104
|
+
assert isinstance(obj, dict)
|
|
105
|
+
id = UUID(obj.get("id"))
|
|
106
|
+
idx = from_int(obj.get("idx"))
|
|
107
|
+
return ClassLabelElement(id, idx)
|
|
108
|
+
|
|
109
|
+
def to_dict(self) -> dict:
|
|
110
|
+
result: dict = {}
|
|
111
|
+
result["id"] = str(self.id)
|
|
112
|
+
result["idx"] = from_int(self.idx)
|
|
113
|
+
return result
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
class NetworkExperiment:
|
|
117
|
+
class_labels: List[ClassLabelElement]
|
|
118
|
+
flavor: str
|
|
119
|
+
network_typename: str
|
|
120
|
+
|
|
121
|
+
def __init__(self, class_labels: List[ClassLabelElement], flavor: str, network_typename: str) -> None:
|
|
122
|
+
self.class_labels = class_labels
|
|
123
|
+
self.flavor = flavor
|
|
124
|
+
self.network_typename = network_typename
|
|
125
|
+
|
|
126
|
+
@staticmethod
|
|
127
|
+
def from_dict(obj: Any) -> 'NetworkExperiment':
|
|
128
|
+
assert isinstance(obj, dict)
|
|
129
|
+
class_labels = from_list(ClassLabelElement.from_dict, obj.get("class_labels"))
|
|
130
|
+
flavor = from_str(obj.get("flavor"))
|
|
131
|
+
network_typename = from_str(obj.get("network_typename"))
|
|
132
|
+
return NetworkExperiment(class_labels, flavor, network_typename)
|
|
133
|
+
|
|
134
|
+
def to_dict(self) -> dict:
|
|
135
|
+
result: dict = {}
|
|
136
|
+
result["class_labels"] = from_list(lambda x: to_class(ClassLabelElement, x), self.class_labels)
|
|
137
|
+
result["flavor"] = from_str(self.flavor)
|
|
138
|
+
result["network_typename"] = from_str(self.network_typename)
|
|
139
|
+
return result
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
class ClassificationMarkupAnnotation:
|
|
143
|
+
id: UUID
|
|
144
|
+
label_id: UUID
|
|
145
|
+
value: float
|
|
146
|
+
|
|
147
|
+
def __init__(self, id: UUID, label_id: UUID, value: float) -> None:
|
|
148
|
+
self.id = id
|
|
149
|
+
self.label_id = label_id
|
|
150
|
+
self.value = value
|
|
151
|
+
|
|
152
|
+
@staticmethod
|
|
153
|
+
def from_dict(obj: Any) -> 'ClassificationMarkupAnnotation':
|
|
154
|
+
assert isinstance(obj, dict)
|
|
155
|
+
id = UUID(obj.get("id"))
|
|
156
|
+
label_id = UUID(obj.get("label_id"))
|
|
157
|
+
value = from_float(obj.get("value"))
|
|
158
|
+
return ClassificationMarkupAnnotation(id, label_id, value)
|
|
159
|
+
|
|
160
|
+
def to_dict(self) -> dict:
|
|
161
|
+
result: dict = {}
|
|
162
|
+
result["id"] = str(self.id)
|
|
163
|
+
result["label_id"] = str(self.label_id)
|
|
164
|
+
result["value"] = to_float(self.value)
|
|
165
|
+
return result
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
class ClassificationMarkup:
|
|
169
|
+
annotations: List[ClassificationMarkupAnnotation]
|
|
170
|
+
height: int
|
|
171
|
+
width: int
|
|
172
|
+
|
|
173
|
+
def __init__(self, annotations: List[ClassificationMarkupAnnotation], height: int, width: int) -> None:
|
|
174
|
+
self.annotations = annotations
|
|
175
|
+
self.height = height
|
|
176
|
+
self.width = width
|
|
177
|
+
|
|
178
|
+
@staticmethod
|
|
179
|
+
def from_dict(obj: Any) -> 'ClassificationMarkup':
|
|
180
|
+
assert isinstance(obj, dict)
|
|
181
|
+
annotations = from_list(ClassificationMarkupAnnotation.from_dict, obj.get("annotations"))
|
|
182
|
+
height = from_int(obj.get("height"))
|
|
183
|
+
width = from_int(obj.get("width"))
|
|
184
|
+
return ClassificationMarkup(annotations, height, width)
|
|
185
|
+
|
|
186
|
+
def to_dict(self) -> dict:
|
|
187
|
+
result: dict = {}
|
|
188
|
+
result["annotations"] = from_list(lambda x: to_class(ClassificationMarkupAnnotation, x), self.annotations)
|
|
189
|
+
result["height"] = from_int(self.height)
|
|
190
|
+
result["width"] = from_int(self.width)
|
|
191
|
+
return result
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
class AnnotationType(Enum):
|
|
195
|
+
IGNORE = "IGNORE"
|
|
196
|
+
NEGATIVE = "NEGATIVE"
|
|
197
|
+
POSITIVE = "POSITIVE"
|
|
198
|
+
ROI = "ROI"
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
class ObjectDetectionMarkupAnnotation:
|
|
202
|
+
angle: Optional[float]
|
|
203
|
+
annotation_type: AnnotationType
|
|
204
|
+
average_width: float
|
|
205
|
+
bottom_right_x: float
|
|
206
|
+
bottom_right_y: float
|
|
207
|
+
full_orientation: Optional[bool]
|
|
208
|
+
id: UUID
|
|
209
|
+
label_id: UUID
|
|
210
|
+
top_left_x: float
|
|
211
|
+
top_left_y: float
|
|
212
|
+
|
|
213
|
+
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:
|
|
214
|
+
self.angle = angle
|
|
215
|
+
self.annotation_type = annotation_type
|
|
216
|
+
self.average_width = average_width
|
|
217
|
+
self.bottom_right_x = bottom_right_x
|
|
218
|
+
self.bottom_right_y = bottom_right_y
|
|
219
|
+
self.full_orientation = full_orientation
|
|
220
|
+
self.id = id
|
|
221
|
+
self.label_id = label_id
|
|
222
|
+
self.top_left_x = top_left_x
|
|
223
|
+
self.top_left_y = top_left_y
|
|
224
|
+
|
|
225
|
+
@staticmethod
|
|
226
|
+
def from_dict(obj: Any) -> 'ObjectDetectionMarkupAnnotation':
|
|
227
|
+
assert isinstance(obj, dict)
|
|
228
|
+
angle = from_union([from_float, from_none], obj.get("angle"))
|
|
229
|
+
annotation_type = AnnotationType(obj.get("annotation_type"))
|
|
230
|
+
average_width = from_float(obj.get("average_width"))
|
|
231
|
+
bottom_right_x = from_float(obj.get("bottom_right_x"))
|
|
232
|
+
bottom_right_y = from_float(obj.get("bottom_right_y"))
|
|
233
|
+
full_orientation = from_union([from_bool, from_none], obj.get("full_orientation"))
|
|
234
|
+
id = UUID(obj.get("id"))
|
|
235
|
+
label_id = UUID(obj.get("label_id"))
|
|
236
|
+
top_left_x = from_float(obj.get("top_left_x"))
|
|
237
|
+
top_left_y = from_float(obj.get("top_left_y"))
|
|
238
|
+
return ObjectDetectionMarkupAnnotation(angle, annotation_type, average_width, bottom_right_x, bottom_right_y, full_orientation, id, label_id, top_left_x, top_left_y)
|
|
239
|
+
|
|
240
|
+
def to_dict(self) -> dict:
|
|
241
|
+
result: dict = {}
|
|
242
|
+
if self.angle is not None:
|
|
243
|
+
result["angle"] = from_union([to_float, from_none], self.angle)
|
|
244
|
+
result["annotation_type"] = to_enum(AnnotationType, self.annotation_type)
|
|
245
|
+
result["average_width"] = to_float(self.average_width)
|
|
246
|
+
result["bottom_right_x"] = to_float(self.bottom_right_x)
|
|
247
|
+
result["bottom_right_y"] = to_float(self.bottom_right_y)
|
|
248
|
+
if self.full_orientation is not None:
|
|
249
|
+
result["full_orientation"] = from_union([from_bool, from_none], self.full_orientation)
|
|
250
|
+
result["id"] = str(self.id)
|
|
251
|
+
result["label_id"] = str(self.label_id)
|
|
252
|
+
result["top_left_x"] = to_float(self.top_left_x)
|
|
253
|
+
result["top_left_y"] = to_float(self.top_left_y)
|
|
254
|
+
return result
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
class ObjectDetectionMarkup:
|
|
258
|
+
annotations: List[ObjectDetectionMarkupAnnotation]
|
|
259
|
+
height: int
|
|
260
|
+
width: int
|
|
261
|
+
|
|
262
|
+
def __init__(self, annotations: List[ObjectDetectionMarkupAnnotation], height: int, width: int) -> None:
|
|
263
|
+
self.annotations = annotations
|
|
264
|
+
self.height = height
|
|
265
|
+
self.width = width
|
|
266
|
+
|
|
267
|
+
@staticmethod
|
|
268
|
+
def from_dict(obj: Any) -> 'ObjectDetectionMarkup':
|
|
269
|
+
assert isinstance(obj, dict)
|
|
270
|
+
annotations = from_list(ObjectDetectionMarkupAnnotation.from_dict, obj.get("annotations"))
|
|
271
|
+
height = from_int(obj.get("height"))
|
|
272
|
+
width = from_int(obj.get("width"))
|
|
273
|
+
return ObjectDetectionMarkup(annotations, height, width)
|
|
274
|
+
|
|
275
|
+
def to_dict(self) -> dict:
|
|
276
|
+
result: dict = {}
|
|
277
|
+
result["annotations"] = from_list(lambda x: to_class(ObjectDetectionMarkupAnnotation, x), self.annotations)
|
|
278
|
+
result["height"] = from_int(self.height)
|
|
279
|
+
result["width"] = from_int(self.width)
|
|
280
|
+
return result
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
class BoundingBox:
|
|
284
|
+
bottom_right_x: float
|
|
285
|
+
bottom_right_y: float
|
|
286
|
+
top_left_x: float
|
|
287
|
+
top_left_y: float
|
|
288
|
+
|
|
289
|
+
def __init__(self, bottom_right_x: float, bottom_right_y: float, top_left_x: float, top_left_y: float) -> None:
|
|
290
|
+
self.bottom_right_x = bottom_right_x
|
|
291
|
+
self.bottom_right_y = bottom_right_y
|
|
292
|
+
self.top_left_x = top_left_x
|
|
293
|
+
self.top_left_y = top_left_y
|
|
294
|
+
|
|
295
|
+
@staticmethod
|
|
296
|
+
def from_dict(obj: Any) -> 'BoundingBox':
|
|
297
|
+
assert isinstance(obj, dict)
|
|
298
|
+
bottom_right_x = from_float(obj.get("bottom_right_x"))
|
|
299
|
+
bottom_right_y = from_float(obj.get("bottom_right_y"))
|
|
300
|
+
top_left_x = from_float(obj.get("top_left_x"))
|
|
301
|
+
top_left_y = from_float(obj.get("top_left_y"))
|
|
302
|
+
return BoundingBox(bottom_right_x, bottom_right_y, top_left_x, top_left_y)
|
|
303
|
+
|
|
304
|
+
def to_dict(self) -> dict:
|
|
305
|
+
result: dict = {}
|
|
306
|
+
result["bottom_right_x"] = to_float(self.bottom_right_x)
|
|
307
|
+
result["bottom_right_y"] = to_float(self.bottom_right_y)
|
|
308
|
+
result["top_left_x"] = to_float(self.top_left_x)
|
|
309
|
+
result["top_left_y"] = to_float(self.top_left_y)
|
|
310
|
+
return result
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
class RingPoint:
|
|
314
|
+
x: float
|
|
315
|
+
y: float
|
|
316
|
+
|
|
317
|
+
def __init__(self, x: float, y: float) -> None:
|
|
318
|
+
self.x = x
|
|
319
|
+
self.y = y
|
|
320
|
+
|
|
321
|
+
@staticmethod
|
|
322
|
+
def from_dict(obj: Any) -> 'RingPoint':
|
|
323
|
+
assert isinstance(obj, dict)
|
|
324
|
+
x = from_float(obj.get("x"))
|
|
325
|
+
y = from_float(obj.get("y"))
|
|
326
|
+
return RingPoint(x, y)
|
|
327
|
+
|
|
328
|
+
def to_dict(self) -> dict:
|
|
329
|
+
result: dict = {}
|
|
330
|
+
result["x"] = to_float(self.x)
|
|
331
|
+
result["y"] = to_float(self.y)
|
|
332
|
+
return result
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
class AnnotationComparerRequestSchema:
|
|
336
|
+
hierarchy: int
|
|
337
|
+
points: List[RingPoint]
|
|
338
|
+
|
|
339
|
+
def __init__(self, hierarchy: int, points: List[RingPoint]) -> None:
|
|
340
|
+
self.hierarchy = hierarchy
|
|
341
|
+
self.points = points
|
|
342
|
+
|
|
343
|
+
@staticmethod
|
|
344
|
+
def from_dict(obj: Any) -> 'AnnotationComparerRequestSchema':
|
|
345
|
+
assert isinstance(obj, dict)
|
|
346
|
+
hierarchy = from_int(obj.get("hierarchy"))
|
|
347
|
+
points = from_list(RingPoint.from_dict, obj.get("points"))
|
|
348
|
+
return AnnotationComparerRequestSchema(hierarchy, points)
|
|
349
|
+
|
|
350
|
+
def to_dict(self) -> dict:
|
|
351
|
+
result: dict = {}
|
|
352
|
+
result["hierarchy"] = from_int(self.hierarchy)
|
|
353
|
+
result["points"] = from_list(lambda x: to_class(RingPoint, x), self.points)
|
|
354
|
+
return result
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
class Polygon:
|
|
358
|
+
rings: List[AnnotationComparerRequestSchema]
|
|
359
|
+
|
|
360
|
+
def __init__(self, rings: List[AnnotationComparerRequestSchema]) -> None:
|
|
361
|
+
self.rings = rings
|
|
362
|
+
|
|
363
|
+
@staticmethod
|
|
364
|
+
def from_dict(obj: Any) -> 'Polygon':
|
|
365
|
+
assert isinstance(obj, dict)
|
|
366
|
+
rings = from_list(AnnotationComparerRequestSchema.from_dict, obj.get("rings"))
|
|
367
|
+
return Polygon(rings)
|
|
368
|
+
|
|
369
|
+
def to_dict(self) -> dict:
|
|
370
|
+
result: dict = {}
|
|
371
|
+
result["rings"] = from_list(lambda x: to_class(AnnotationComparerRequestSchema, x), self.rings)
|
|
372
|
+
return result
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
class OcrMarkupAnnotation:
|
|
376
|
+
bounding_box: Optional[BoundingBox]
|
|
377
|
+
id: UUID
|
|
378
|
+
label_id: UUID
|
|
379
|
+
polygon: Optional[Polygon]
|
|
380
|
+
text: str
|
|
381
|
+
|
|
382
|
+
def __init__(self, bounding_box: Optional[BoundingBox], id: UUID, label_id: UUID, polygon: Optional[Polygon], text: str) -> None:
|
|
383
|
+
self.bounding_box = bounding_box
|
|
384
|
+
self.id = id
|
|
385
|
+
self.label_id = label_id
|
|
386
|
+
self.polygon = polygon
|
|
387
|
+
self.text = text
|
|
388
|
+
|
|
389
|
+
@staticmethod
|
|
390
|
+
def from_dict(obj: Any) -> 'OcrMarkupAnnotation':
|
|
391
|
+
assert isinstance(obj, dict)
|
|
392
|
+
bounding_box = from_union([BoundingBox.from_dict, from_none], obj.get("bounding_box"))
|
|
393
|
+
id = UUID(obj.get("id"))
|
|
394
|
+
label_id = UUID(obj.get("label_id"))
|
|
395
|
+
polygon = from_union([Polygon.from_dict, from_none], obj.get("polygon"))
|
|
396
|
+
text = from_str(obj.get("text"))
|
|
397
|
+
return OcrMarkupAnnotation(bounding_box, id, label_id, polygon, text)
|
|
398
|
+
|
|
399
|
+
def to_dict(self) -> dict:
|
|
400
|
+
result: dict = {}
|
|
401
|
+
if self.bounding_box is not None:
|
|
402
|
+
result["bounding_box"] = from_union([lambda x: to_class(BoundingBox, x), from_none], self.bounding_box)
|
|
403
|
+
result["id"] = str(self.id)
|
|
404
|
+
result["label_id"] = str(self.label_id)
|
|
405
|
+
if self.polygon is not None:
|
|
406
|
+
result["polygon"] = from_union([lambda x: to_class(Polygon, x), from_none], self.polygon)
|
|
407
|
+
result["text"] = from_str(self.text)
|
|
408
|
+
return result
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
class OcrMarkup:
|
|
412
|
+
annotations: List[OcrMarkupAnnotation]
|
|
413
|
+
average_object_widths: List[float]
|
|
414
|
+
height: int
|
|
415
|
+
width: int
|
|
416
|
+
|
|
417
|
+
def __init__(self, annotations: List[OcrMarkupAnnotation], average_object_widths: List[float], height: int, width: int) -> None:
|
|
418
|
+
self.annotations = annotations
|
|
419
|
+
self.average_object_widths = average_object_widths
|
|
420
|
+
self.height = height
|
|
421
|
+
self.width = width
|
|
422
|
+
|
|
423
|
+
@staticmethod
|
|
424
|
+
def from_dict(obj: Any) -> 'OcrMarkup':
|
|
425
|
+
assert isinstance(obj, dict)
|
|
426
|
+
annotations = from_list(OcrMarkupAnnotation.from_dict, obj.get("annotations"))
|
|
427
|
+
average_object_widths = from_list(from_float, obj.get("average_object_widths"))
|
|
428
|
+
height = from_int(obj.get("height"))
|
|
429
|
+
width = from_int(obj.get("width"))
|
|
430
|
+
return OcrMarkup(annotations, average_object_widths, height, width)
|
|
431
|
+
|
|
432
|
+
def to_dict(self) -> dict:
|
|
433
|
+
result: dict = {}
|
|
434
|
+
result["annotations"] = from_list(lambda x: to_class(OcrMarkupAnnotation, x), self.annotations)
|
|
435
|
+
result["average_object_widths"] = from_list(to_float, self.average_object_widths)
|
|
436
|
+
result["height"] = from_int(self.height)
|
|
437
|
+
result["width"] = from_int(self.width)
|
|
438
|
+
return result
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
class CircleAnnotation:
|
|
442
|
+
center_x: float
|
|
443
|
+
center_y: float
|
|
444
|
+
radius: float
|
|
445
|
+
|
|
446
|
+
def __init__(self, center_x: float, center_y: float, radius: float) -> None:
|
|
447
|
+
self.center_x = center_x
|
|
448
|
+
self.center_y = center_y
|
|
449
|
+
self.radius = radius
|
|
450
|
+
|
|
451
|
+
@staticmethod
|
|
452
|
+
def from_dict(obj: Any) -> 'CircleAnnotation':
|
|
453
|
+
assert isinstance(obj, dict)
|
|
454
|
+
center_x = from_float(obj.get("center_x"))
|
|
455
|
+
center_y = from_float(obj.get("center_y"))
|
|
456
|
+
radius = from_float(obj.get("radius"))
|
|
457
|
+
return CircleAnnotation(center_x, center_y, radius)
|
|
458
|
+
|
|
459
|
+
def to_dict(self) -> dict:
|
|
460
|
+
result: dict = {}
|
|
461
|
+
result["center_x"] = to_float(self.center_x)
|
|
462
|
+
result["center_y"] = to_float(self.center_y)
|
|
463
|
+
result["radius"] = to_float(self.radius)
|
|
464
|
+
return result
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
class MagicwandAnnotationPoint:
|
|
468
|
+
x: float
|
|
469
|
+
y: float
|
|
470
|
+
|
|
471
|
+
def __init__(self, x: float, y: float) -> None:
|
|
472
|
+
self.x = x
|
|
473
|
+
self.y = y
|
|
474
|
+
|
|
475
|
+
@staticmethod
|
|
476
|
+
def from_dict(obj: Any) -> 'MagicwandAnnotationPoint':
|
|
477
|
+
assert isinstance(obj, dict)
|
|
478
|
+
x = from_float(obj.get("x"))
|
|
479
|
+
y = from_float(obj.get("y"))
|
|
480
|
+
return MagicwandAnnotationPoint(x, y)
|
|
481
|
+
|
|
482
|
+
def to_dict(self) -> dict:
|
|
483
|
+
result: dict = {}
|
|
484
|
+
result["x"] = to_float(self.x)
|
|
485
|
+
result["y"] = to_float(self.y)
|
|
486
|
+
return result
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
class MagicwandAnnotation:
|
|
490
|
+
bottom_right_x: float
|
|
491
|
+
bottom_right_y: float
|
|
492
|
+
center_x: float
|
|
493
|
+
center_y: float
|
|
494
|
+
data_url: str
|
|
495
|
+
points: List[MagicwandAnnotationPoint]
|
|
496
|
+
threshold: int
|
|
497
|
+
top_left_x: float
|
|
498
|
+
top_left_y: float
|
|
499
|
+
|
|
500
|
+
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:
|
|
501
|
+
self.bottom_right_x = bottom_right_x
|
|
502
|
+
self.bottom_right_y = bottom_right_y
|
|
503
|
+
self.center_x = center_x
|
|
504
|
+
self.center_y = center_y
|
|
505
|
+
self.data_url = data_url
|
|
506
|
+
self.points = points
|
|
507
|
+
self.threshold = threshold
|
|
508
|
+
self.top_left_x = top_left_x
|
|
509
|
+
self.top_left_y = top_left_y
|
|
510
|
+
|
|
511
|
+
@staticmethod
|
|
512
|
+
def from_dict(obj: Any) -> 'MagicwandAnnotation':
|
|
513
|
+
assert isinstance(obj, dict)
|
|
514
|
+
bottom_right_x = from_float(obj.get("bottom_right_x"))
|
|
515
|
+
bottom_right_y = from_float(obj.get("bottom_right_y"))
|
|
516
|
+
center_x = from_float(obj.get("center_x"))
|
|
517
|
+
center_y = from_float(obj.get("center_y"))
|
|
518
|
+
data_url = from_str(obj.get("dataURL"))
|
|
519
|
+
points = from_list(MagicwandAnnotationPoint.from_dict, obj.get("points"))
|
|
520
|
+
threshold = from_int(obj.get("threshold"))
|
|
521
|
+
top_left_x = from_float(obj.get("top_left_x"))
|
|
522
|
+
top_left_y = from_float(obj.get("top_left_y"))
|
|
523
|
+
return MagicwandAnnotation(bottom_right_x, bottom_right_y, center_x, center_y, data_url, points, threshold, top_left_x, top_left_y)
|
|
524
|
+
|
|
525
|
+
def to_dict(self) -> dict:
|
|
526
|
+
result: dict = {}
|
|
527
|
+
result["bottom_right_x"] = to_float(self.bottom_right_x)
|
|
528
|
+
result["bottom_right_y"] = to_float(self.bottom_right_y)
|
|
529
|
+
result["center_x"] = to_float(self.center_x)
|
|
530
|
+
result["center_y"] = to_float(self.center_y)
|
|
531
|
+
result["dataURL"] = from_str(self.data_url)
|
|
532
|
+
result["points"] = from_list(lambda x: to_class(MagicwandAnnotationPoint, x), self.points)
|
|
533
|
+
result["threshold"] = from_int(self.threshold)
|
|
534
|
+
result["top_left_x"] = to_float(self.top_left_x)
|
|
535
|
+
result["top_left_y"] = to_float(self.top_left_y)
|
|
536
|
+
return result
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
class PenAnnotationPoint:
|
|
540
|
+
x: float
|
|
541
|
+
y: float
|
|
542
|
+
|
|
543
|
+
def __init__(self, x: float, y: float) -> None:
|
|
544
|
+
self.x = x
|
|
545
|
+
self.y = y
|
|
546
|
+
|
|
547
|
+
@staticmethod
|
|
548
|
+
def from_dict(obj: Any) -> 'PenAnnotationPoint':
|
|
549
|
+
assert isinstance(obj, dict)
|
|
550
|
+
x = from_float(obj.get("x"))
|
|
551
|
+
y = from_float(obj.get("y"))
|
|
552
|
+
return PenAnnotationPoint(x, y)
|
|
553
|
+
|
|
554
|
+
def to_dict(self) -> dict:
|
|
555
|
+
result: dict = {}
|
|
556
|
+
result["x"] = to_float(self.x)
|
|
557
|
+
result["y"] = to_float(self.y)
|
|
558
|
+
return result
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
class PenAnnotation:
|
|
562
|
+
bottom_right_x: float
|
|
563
|
+
bottom_right_y: float
|
|
564
|
+
data_url: str
|
|
565
|
+
points: List[PenAnnotationPoint]
|
|
566
|
+
thickness: float
|
|
567
|
+
top_left_x: float
|
|
568
|
+
top_left_y: float
|
|
569
|
+
|
|
570
|
+
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:
|
|
571
|
+
self.bottom_right_x = bottom_right_x
|
|
572
|
+
self.bottom_right_y = bottom_right_y
|
|
573
|
+
self.data_url = data_url
|
|
574
|
+
self.points = points
|
|
575
|
+
self.thickness = thickness
|
|
576
|
+
self.top_left_x = top_left_x
|
|
577
|
+
self.top_left_y = top_left_y
|
|
578
|
+
|
|
579
|
+
@staticmethod
|
|
580
|
+
def from_dict(obj: Any) -> 'PenAnnotation':
|
|
581
|
+
assert isinstance(obj, dict)
|
|
582
|
+
bottom_right_x = from_float(obj.get("bottom_right_x"))
|
|
583
|
+
bottom_right_y = from_float(obj.get("bottom_right_y"))
|
|
584
|
+
data_url = from_str(obj.get("dataURL"))
|
|
585
|
+
points = from_list(PenAnnotationPoint.from_dict, obj.get("points"))
|
|
586
|
+
thickness = from_float(obj.get("thickness"))
|
|
587
|
+
top_left_x = from_float(obj.get("top_left_x"))
|
|
588
|
+
top_left_y = from_float(obj.get("top_left_y"))
|
|
589
|
+
return PenAnnotation(bottom_right_x, bottom_right_y, data_url, points, thickness, top_left_x, top_left_y)
|
|
590
|
+
|
|
591
|
+
def to_dict(self) -> dict:
|
|
592
|
+
result: dict = {}
|
|
593
|
+
result["bottom_right_x"] = to_float(self.bottom_right_x)
|
|
594
|
+
result["bottom_right_y"] = to_float(self.bottom_right_y)
|
|
595
|
+
result["dataURL"] = from_str(self.data_url)
|
|
596
|
+
result["points"] = from_list(lambda x: to_class(PenAnnotationPoint, x), self.points)
|
|
597
|
+
result["thickness"] = to_float(self.thickness)
|
|
598
|
+
result["top_left_x"] = to_float(self.top_left_x)
|
|
599
|
+
result["top_left_y"] = to_float(self.top_left_y)
|
|
600
|
+
return result
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+
class PixelAnnotation:
|
|
604
|
+
blob_id: UUID
|
|
605
|
+
bottom_right_x: float
|
|
606
|
+
bottom_right_y: float
|
|
607
|
+
top_left_x: float
|
|
608
|
+
top_left_y: float
|
|
609
|
+
|
|
610
|
+
def __init__(self, blob_id: UUID, bottom_right_x: float, bottom_right_y: float, top_left_x: float, top_left_y: float) -> None:
|
|
611
|
+
self.blob_id = blob_id
|
|
612
|
+
self.bottom_right_x = bottom_right_x
|
|
613
|
+
self.bottom_right_y = bottom_right_y
|
|
614
|
+
self.top_left_x = top_left_x
|
|
615
|
+
self.top_left_y = top_left_y
|
|
616
|
+
|
|
617
|
+
@staticmethod
|
|
618
|
+
def from_dict(obj: Any) -> 'PixelAnnotation':
|
|
619
|
+
assert isinstance(obj, dict)
|
|
620
|
+
blob_id = UUID(obj.get("blob_id"))
|
|
621
|
+
bottom_right_x = from_float(obj.get("bottom_right_x"))
|
|
622
|
+
bottom_right_y = from_float(obj.get("bottom_right_y"))
|
|
623
|
+
top_left_x = from_float(obj.get("top_left_x"))
|
|
624
|
+
top_left_y = from_float(obj.get("top_left_y"))
|
|
625
|
+
return PixelAnnotation(blob_id, bottom_right_x, bottom_right_y, top_left_x, top_left_y)
|
|
626
|
+
|
|
627
|
+
def to_dict(self) -> dict:
|
|
628
|
+
result: dict = {}
|
|
629
|
+
result["blob_id"] = str(self.blob_id)
|
|
630
|
+
result["bottom_right_x"] = to_float(self.bottom_right_x)
|
|
631
|
+
result["bottom_right_y"] = to_float(self.bottom_right_y)
|
|
632
|
+
result["top_left_x"] = to_float(self.top_left_x)
|
|
633
|
+
result["top_left_y"] = to_float(self.top_left_y)
|
|
634
|
+
return result
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
class PolygonAnnotation:
|
|
638
|
+
rings: List[AnnotationComparerRequestSchema]
|
|
639
|
+
|
|
640
|
+
def __init__(self, rings: List[AnnotationComparerRequestSchema]) -> None:
|
|
641
|
+
self.rings = rings
|
|
642
|
+
|
|
643
|
+
@staticmethod
|
|
644
|
+
def from_dict(obj: Any) -> 'PolygonAnnotation':
|
|
645
|
+
assert isinstance(obj, dict)
|
|
646
|
+
rings = from_list(AnnotationComparerRequestSchema.from_dict, obj.get("rings"))
|
|
647
|
+
return PolygonAnnotation(rings)
|
|
648
|
+
|
|
649
|
+
def to_dict(self) -> dict:
|
|
650
|
+
result: dict = {}
|
|
651
|
+
result["rings"] = from_list(lambda x: to_class(AnnotationComparerRequestSchema, x), self.rings)
|
|
652
|
+
return result
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
class RectangleAnnotation:
|
|
656
|
+
bottom_right_x: float
|
|
657
|
+
bottom_right_y: float
|
|
658
|
+
top_left_x: float
|
|
659
|
+
top_left_y: float
|
|
660
|
+
|
|
661
|
+
def __init__(self, bottom_right_x: float, bottom_right_y: float, top_left_x: float, top_left_y: float) -> None:
|
|
662
|
+
self.bottom_right_x = bottom_right_x
|
|
663
|
+
self.bottom_right_y = bottom_right_y
|
|
664
|
+
self.top_left_x = top_left_x
|
|
665
|
+
self.top_left_y = top_left_y
|
|
666
|
+
|
|
667
|
+
@staticmethod
|
|
668
|
+
def from_dict(obj: Any) -> 'RectangleAnnotation':
|
|
669
|
+
assert isinstance(obj, dict)
|
|
670
|
+
bottom_right_x = from_float(obj.get("bottom_right_x"))
|
|
671
|
+
bottom_right_y = from_float(obj.get("bottom_right_y"))
|
|
672
|
+
top_left_x = from_float(obj.get("top_left_x"))
|
|
673
|
+
top_left_y = from_float(obj.get("top_left_y"))
|
|
674
|
+
return RectangleAnnotation(bottom_right_x, bottom_right_y, top_left_x, top_left_y)
|
|
675
|
+
|
|
676
|
+
def to_dict(self) -> dict:
|
|
677
|
+
result: dict = {}
|
|
678
|
+
result["bottom_right_x"] = to_float(self.bottom_right_x)
|
|
679
|
+
result["bottom_right_y"] = to_float(self.bottom_right_y)
|
|
680
|
+
result["top_left_x"] = to_float(self.top_left_x)
|
|
681
|
+
result["top_left_y"] = to_float(self.top_left_y)
|
|
682
|
+
return result
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
class SausageAnnotationPoint:
|
|
686
|
+
x: float
|
|
687
|
+
y: float
|
|
688
|
+
|
|
689
|
+
def __init__(self, x: float, y: float) -> None:
|
|
690
|
+
self.x = x
|
|
691
|
+
self.y = y
|
|
692
|
+
|
|
693
|
+
@staticmethod
|
|
694
|
+
def from_dict(obj: Any) -> 'SausageAnnotationPoint':
|
|
695
|
+
assert isinstance(obj, dict)
|
|
696
|
+
x = from_float(obj.get("x"))
|
|
697
|
+
y = from_float(obj.get("y"))
|
|
698
|
+
return SausageAnnotationPoint(x, y)
|
|
699
|
+
|
|
700
|
+
def to_dict(self) -> dict:
|
|
701
|
+
result: dict = {}
|
|
702
|
+
result["x"] = to_float(self.x)
|
|
703
|
+
result["y"] = to_float(self.y)
|
|
704
|
+
return result
|
|
705
|
+
|
|
706
|
+
|
|
707
|
+
class SausageAnnotation:
|
|
708
|
+
bottom_right_x: float
|
|
709
|
+
bottom_right_y: float
|
|
710
|
+
data_url: str
|
|
711
|
+
points: List[SausageAnnotationPoint]
|
|
712
|
+
radius: float
|
|
713
|
+
top_left_x: float
|
|
714
|
+
top_left_y: float
|
|
715
|
+
|
|
716
|
+
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:
|
|
717
|
+
self.bottom_right_x = bottom_right_x
|
|
718
|
+
self.bottom_right_y = bottom_right_y
|
|
719
|
+
self.data_url = data_url
|
|
720
|
+
self.points = points
|
|
721
|
+
self.radius = radius
|
|
722
|
+
self.top_left_x = top_left_x
|
|
723
|
+
self.top_left_y = top_left_y
|
|
724
|
+
|
|
725
|
+
@staticmethod
|
|
726
|
+
def from_dict(obj: Any) -> 'SausageAnnotation':
|
|
727
|
+
assert isinstance(obj, dict)
|
|
728
|
+
bottom_right_x = from_float(obj.get("bottom_right_x"))
|
|
729
|
+
bottom_right_y = from_float(obj.get("bottom_right_y"))
|
|
730
|
+
data_url = from_str(obj.get("dataURL"))
|
|
731
|
+
points = from_list(SausageAnnotationPoint.from_dict, obj.get("points"))
|
|
732
|
+
radius = from_float(obj.get("radius"))
|
|
733
|
+
top_left_x = from_float(obj.get("top_left_x"))
|
|
734
|
+
top_left_y = from_float(obj.get("top_left_y"))
|
|
735
|
+
return SausageAnnotation(bottom_right_x, bottom_right_y, data_url, points, radius, top_left_x, top_left_y)
|
|
736
|
+
|
|
737
|
+
def to_dict(self) -> dict:
|
|
738
|
+
result: dict = {}
|
|
739
|
+
result["bottom_right_x"] = to_float(self.bottom_right_x)
|
|
740
|
+
result["bottom_right_y"] = to_float(self.bottom_right_y)
|
|
741
|
+
result["dataURL"] = from_str(self.data_url)
|
|
742
|
+
result["points"] = from_list(lambda x: to_class(SausageAnnotationPoint, x), self.points)
|
|
743
|
+
result["radius"] = to_float(self.radius)
|
|
744
|
+
result["top_left_x"] = to_float(self.top_left_x)
|
|
745
|
+
result["top_left_y"] = to_float(self.top_left_y)
|
|
746
|
+
return result
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
class SegmentationMarkupAnnotation:
|
|
750
|
+
annotation_type: AnnotationType
|
|
751
|
+
average_width: float
|
|
752
|
+
circle_annotation: Optional[CircleAnnotation]
|
|
753
|
+
id: UUID
|
|
754
|
+
label_id: UUID
|
|
755
|
+
magicwand_annotation: Optional[MagicwandAnnotation]
|
|
756
|
+
pen_annotation: Optional[PenAnnotation]
|
|
757
|
+
pixel_annotation: Optional[PixelAnnotation]
|
|
758
|
+
polygon_annotation: Optional[PolygonAnnotation]
|
|
759
|
+
rectangle_annotation: Optional[RectangleAnnotation]
|
|
760
|
+
sausage_annotation: Optional[SausageAnnotation]
|
|
761
|
+
|
|
762
|
+
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:
|
|
763
|
+
self.annotation_type = annotation_type
|
|
764
|
+
self.average_width = average_width
|
|
765
|
+
self.circle_annotation = circle_annotation
|
|
766
|
+
self.id = id
|
|
767
|
+
self.label_id = label_id
|
|
768
|
+
self.magicwand_annotation = magicwand_annotation
|
|
769
|
+
self.pen_annotation = pen_annotation
|
|
770
|
+
self.pixel_annotation = pixel_annotation
|
|
771
|
+
self.polygon_annotation = polygon_annotation
|
|
772
|
+
self.rectangle_annotation = rectangle_annotation
|
|
773
|
+
self.sausage_annotation = sausage_annotation
|
|
774
|
+
|
|
775
|
+
@staticmethod
|
|
776
|
+
def from_dict(obj: Any) -> 'SegmentationMarkupAnnotation':
|
|
777
|
+
assert isinstance(obj, dict)
|
|
778
|
+
annotation_type = AnnotationType(obj.get("annotation_type"))
|
|
779
|
+
average_width = from_float(obj.get("average_width"))
|
|
780
|
+
circle_annotation = from_union([CircleAnnotation.from_dict, from_none], obj.get("circle_annotation"))
|
|
781
|
+
id = UUID(obj.get("id"))
|
|
782
|
+
label_id = UUID(obj.get("label_id"))
|
|
783
|
+
magicwand_annotation = from_union([MagicwandAnnotation.from_dict, from_none], obj.get("magicwand_annotation"))
|
|
784
|
+
pen_annotation = from_union([PenAnnotation.from_dict, from_none], obj.get("pen_annotation"))
|
|
785
|
+
pixel_annotation = from_union([PixelAnnotation.from_dict, from_none], obj.get("pixel_annotation"))
|
|
786
|
+
polygon_annotation = from_union([PolygonAnnotation.from_dict, from_none], obj.get("polygon_annotation"))
|
|
787
|
+
rectangle_annotation = from_union([RectangleAnnotation.from_dict, from_none], obj.get("rectangle_annotation"))
|
|
788
|
+
sausage_annotation = from_union([SausageAnnotation.from_dict, from_none], obj.get("sausage_annotation"))
|
|
789
|
+
return SegmentationMarkupAnnotation(annotation_type, average_width, circle_annotation, id, label_id, magicwand_annotation, pen_annotation, pixel_annotation, polygon_annotation, rectangle_annotation, sausage_annotation)
|
|
790
|
+
|
|
791
|
+
def to_dict(self) -> dict:
|
|
792
|
+
result: dict = {}
|
|
793
|
+
result["annotation_type"] = to_enum(AnnotationType, self.annotation_type)
|
|
794
|
+
result["average_width"] = to_float(self.average_width)
|
|
795
|
+
if self.circle_annotation is not None:
|
|
796
|
+
result["circle_annotation"] = from_union([lambda x: to_class(CircleAnnotation, x), from_none], self.circle_annotation)
|
|
797
|
+
result["id"] = str(self.id)
|
|
798
|
+
result["label_id"] = str(self.label_id)
|
|
799
|
+
if self.magicwand_annotation is not None:
|
|
800
|
+
result["magicwand_annotation"] = from_union([lambda x: to_class(MagicwandAnnotation, x), from_none], self.magicwand_annotation)
|
|
801
|
+
if self.pen_annotation is not None:
|
|
802
|
+
result["pen_annotation"] = from_union([lambda x: to_class(PenAnnotation, x), from_none], self.pen_annotation)
|
|
803
|
+
if self.pixel_annotation is not None:
|
|
804
|
+
result["pixel_annotation"] = from_union([lambda x: to_class(PixelAnnotation, x), from_none], self.pixel_annotation)
|
|
805
|
+
if self.polygon_annotation is not None:
|
|
806
|
+
result["polygon_annotation"] = from_union([lambda x: to_class(PolygonAnnotation, x), from_none], self.polygon_annotation)
|
|
807
|
+
if self.rectangle_annotation is not None:
|
|
808
|
+
result["rectangle_annotation"] = from_union([lambda x: to_class(RectangleAnnotation, x), from_none], self.rectangle_annotation)
|
|
809
|
+
if self.sausage_annotation is not None:
|
|
810
|
+
result["sausage_annotation"] = from_union([lambda x: to_class(SausageAnnotation, x), from_none], self.sausage_annotation)
|
|
811
|
+
return result
|
|
812
|
+
|
|
813
|
+
|
|
814
|
+
class Blob:
|
|
815
|
+
id: UUID
|
|
816
|
+
owned_by_group_id: UUID
|
|
817
|
+
|
|
818
|
+
def __init__(self, id: UUID, owned_by_group_id: UUID) -> None:
|
|
819
|
+
self.id = id
|
|
820
|
+
self.owned_by_group_id = owned_by_group_id
|
|
821
|
+
|
|
822
|
+
@staticmethod
|
|
823
|
+
def from_dict(obj: Any) -> 'Blob':
|
|
824
|
+
assert isinstance(obj, dict)
|
|
825
|
+
id = UUID(obj.get("id"))
|
|
826
|
+
owned_by_group_id = UUID(obj.get("owned_by_group_id"))
|
|
827
|
+
return Blob(id, owned_by_group_id)
|
|
828
|
+
|
|
829
|
+
def to_dict(self) -> dict:
|
|
830
|
+
result: dict = {}
|
|
831
|
+
result["id"] = str(self.id)
|
|
832
|
+
result["owned_by_group_id"] = str(self.owned_by_group_id)
|
|
833
|
+
return result
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
class SegmentationMapClassLabel:
|
|
837
|
+
id: UUID
|
|
838
|
+
idx: int
|
|
839
|
+
|
|
840
|
+
def __init__(self, id: UUID, idx: int) -> None:
|
|
841
|
+
self.id = id
|
|
842
|
+
self.idx = idx
|
|
843
|
+
|
|
844
|
+
@staticmethod
|
|
845
|
+
def from_dict(obj: Any) -> 'SegmentationMapClassLabel':
|
|
846
|
+
assert isinstance(obj, dict)
|
|
847
|
+
id = UUID(obj.get("id"))
|
|
848
|
+
idx = from_int(obj.get("idx"))
|
|
849
|
+
return SegmentationMapClassLabel(id, idx)
|
|
850
|
+
|
|
851
|
+
def to_dict(self) -> dict:
|
|
852
|
+
result: dict = {}
|
|
853
|
+
result["id"] = str(self.id)
|
|
854
|
+
result["idx"] = from_int(self.idx)
|
|
855
|
+
return result
|
|
856
|
+
|
|
857
|
+
|
|
858
|
+
class SegmentationMap:
|
|
859
|
+
blob: Blob
|
|
860
|
+
class_label: SegmentationMapClassLabel
|
|
861
|
+
|
|
862
|
+
def __init__(self, blob: Blob, class_label: SegmentationMapClassLabel) -> None:
|
|
863
|
+
self.blob = blob
|
|
864
|
+
self.class_label = class_label
|
|
865
|
+
|
|
866
|
+
@staticmethod
|
|
867
|
+
def from_dict(obj: Any) -> 'SegmentationMap':
|
|
868
|
+
assert isinstance(obj, dict)
|
|
869
|
+
blob = Blob.from_dict(obj.get("blob"))
|
|
870
|
+
class_label = SegmentationMapClassLabel.from_dict(obj.get("class_label"))
|
|
871
|
+
return SegmentationMap(blob, class_label)
|
|
872
|
+
|
|
873
|
+
def to_dict(self) -> dict:
|
|
874
|
+
result: dict = {}
|
|
875
|
+
result["blob"] = to_class(Blob, self.blob)
|
|
876
|
+
result["class_label"] = to_class(SegmentationMapClassLabel, self.class_label)
|
|
877
|
+
return result
|
|
878
|
+
|
|
879
|
+
|
|
880
|
+
class SegmentationMarkup:
|
|
881
|
+
annotations: Optional[List[SegmentationMarkupAnnotation]]
|
|
882
|
+
average_object_widths: Optional[List[float]]
|
|
883
|
+
height: Optional[int]
|
|
884
|
+
width: Optional[int]
|
|
885
|
+
segmentation_maps: Optional[List[SegmentationMap]]
|
|
886
|
+
|
|
887
|
+
def __init__(self, annotations: Optional[List[SegmentationMarkupAnnotation]], average_object_widths: Optional[List[float]], height: Optional[int], width: Optional[int], segmentation_maps: Optional[List[SegmentationMap]]) -> None:
|
|
888
|
+
self.annotations = annotations
|
|
889
|
+
self.average_object_widths = average_object_widths
|
|
890
|
+
self.height = height
|
|
891
|
+
self.width = width
|
|
892
|
+
self.segmentation_maps = segmentation_maps
|
|
893
|
+
|
|
894
|
+
@staticmethod
|
|
895
|
+
def from_dict(obj: Any) -> 'SegmentationMarkup':
|
|
896
|
+
assert isinstance(obj, dict)
|
|
897
|
+
annotations = from_union([lambda x: from_list(SegmentationMarkupAnnotation.from_dict, x), from_none], obj.get("annotations"))
|
|
898
|
+
average_object_widths = from_union([lambda x: from_list(from_float, x), from_none], obj.get("average_object_widths"))
|
|
899
|
+
height = from_union([from_int, from_none], obj.get("height"))
|
|
900
|
+
width = from_union([from_int, from_none], obj.get("width"))
|
|
901
|
+
segmentation_maps = from_union([lambda x: from_list(SegmentationMap.from_dict, x), from_none], obj.get("segmentation_maps"))
|
|
902
|
+
return SegmentationMarkup(annotations, average_object_widths, height, width, segmentation_maps)
|
|
903
|
+
|
|
904
|
+
def to_dict(self) -> dict:
|
|
905
|
+
result: dict = {}
|
|
906
|
+
if self.annotations is not None:
|
|
907
|
+
result["annotations"] = from_union([lambda x: from_list(lambda x: to_class(SegmentationMarkupAnnotation, x), x), from_none], self.annotations)
|
|
908
|
+
if self.average_object_widths is not None:
|
|
909
|
+
result["average_object_widths"] = from_union([lambda x: from_list(to_float, x), from_none], self.average_object_widths)
|
|
910
|
+
if self.height is not None:
|
|
911
|
+
result["height"] = from_union([from_int, from_none], self.height)
|
|
912
|
+
if self.width is not None:
|
|
913
|
+
result["width"] = from_union([from_int, from_none], self.width)
|
|
914
|
+
if self.segmentation_maps is not None:
|
|
915
|
+
result["segmentation_maps"] = from_union([lambda x: from_list(lambda x: to_class(SegmentationMap, x), x), from_none], self.segmentation_maps)
|
|
916
|
+
return result
|
|
917
|
+
|
|
918
|
+
|
|
919
|
+
class Source:
|
|
920
|
+
classification_markup: Optional[ClassificationMarkup]
|
|
921
|
+
object_detection_markup: Optional[ObjectDetectionMarkup]
|
|
922
|
+
ocr_markup: Optional[OcrMarkup]
|
|
923
|
+
segmentation_markup: Optional[SegmentationMarkup]
|
|
924
|
+
|
|
925
|
+
def __init__(self, classification_markup: Optional[ClassificationMarkup], object_detection_markup: Optional[ObjectDetectionMarkup], ocr_markup: Optional[OcrMarkup], segmentation_markup: Optional[SegmentationMarkup]) -> None:
|
|
926
|
+
self.classification_markup = classification_markup
|
|
927
|
+
self.object_detection_markup = object_detection_markup
|
|
928
|
+
self.ocr_markup = ocr_markup
|
|
929
|
+
self.segmentation_markup = segmentation_markup
|
|
930
|
+
|
|
931
|
+
@staticmethod
|
|
932
|
+
def from_dict(obj: Any) -> 'Source':
|
|
933
|
+
assert isinstance(obj, dict)
|
|
934
|
+
classification_markup = from_union([ClassificationMarkup.from_dict, from_none], obj.get("classification_markup"))
|
|
935
|
+
object_detection_markup = from_union([ObjectDetectionMarkup.from_dict, from_none], obj.get("object_detection_markup"))
|
|
936
|
+
ocr_markup = from_union([OcrMarkup.from_dict, from_none], obj.get("ocr_markup"))
|
|
937
|
+
segmentation_markup = from_union([SegmentationMarkup.from_dict, from_none], obj.get("segmentation_markup"))
|
|
938
|
+
return Source(classification_markup, object_detection_markup, ocr_markup, segmentation_markup)
|
|
939
|
+
|
|
940
|
+
def to_dict(self) -> dict:
|
|
941
|
+
result: dict = {}
|
|
942
|
+
if self.classification_markup is not None:
|
|
943
|
+
result["classification_markup"] = from_union([lambda x: to_class(ClassificationMarkup, x), from_none], self.classification_markup)
|
|
944
|
+
if self.object_detection_markup is not None:
|
|
945
|
+
result["object_detection_markup"] = from_union([lambda x: to_class(ObjectDetectionMarkup, x), from_none], self.object_detection_markup)
|
|
946
|
+
if self.ocr_markup is not None:
|
|
947
|
+
result["ocr_markup"] = from_union([lambda x: to_class(OcrMarkup, x), from_none], self.ocr_markup)
|
|
948
|
+
if self.segmentation_markup is not None:
|
|
949
|
+
result["segmentation_markup"] = from_union([lambda x: to_class(SegmentationMarkup, x), from_none], self.segmentation_markup)
|
|
950
|
+
return result
|
|
951
|
+
|
|
952
|
+
|
|
953
|
+
class AnnotationComparerRequest:
|
|
954
|
+
created_by_user_id: UUID
|
|
955
|
+
hasura_url: str
|
|
956
|
+
id: UUID
|
|
957
|
+
image: Image
|
|
958
|
+
network_experiment: NetworkExperiment
|
|
959
|
+
owned_by_group_id: UUID
|
|
960
|
+
source: Source
|
|
961
|
+
target: Source
|
|
962
|
+
user1_id: Optional[UUID]
|
|
963
|
+
user2_id: Optional[UUID]
|
|
964
|
+
|
|
965
|
+
def __init__(self, created_by_user_id: UUID, hasura_url: str, id: UUID, image: Image, network_experiment: NetworkExperiment, owned_by_group_id: UUID, source: Source, target: Source, user1_id: Optional[UUID], user2_id: Optional[UUID]) -> None:
|
|
966
|
+
self.created_by_user_id = created_by_user_id
|
|
967
|
+
self.hasura_url = hasura_url
|
|
968
|
+
self.id = id
|
|
969
|
+
self.image = image
|
|
970
|
+
self.network_experiment = network_experiment
|
|
971
|
+
self.owned_by_group_id = owned_by_group_id
|
|
972
|
+
self.source = source
|
|
973
|
+
self.target = target
|
|
974
|
+
self.user1_id = user1_id
|
|
975
|
+
self.user2_id = user2_id
|
|
976
|
+
|
|
977
|
+
@staticmethod
|
|
978
|
+
def from_dict(obj: Any) -> 'AnnotationComparerRequest':
|
|
979
|
+
assert isinstance(obj, dict)
|
|
980
|
+
created_by_user_id = UUID(obj.get("created_by_user_id"))
|
|
981
|
+
hasura_url = from_str(obj.get("hasura_url"))
|
|
982
|
+
id = UUID(obj.get("id"))
|
|
983
|
+
image = Image.from_dict(obj.get("image"))
|
|
984
|
+
network_experiment = NetworkExperiment.from_dict(obj.get("network_experiment"))
|
|
985
|
+
owned_by_group_id = UUID(obj.get("owned_by_group_id"))
|
|
986
|
+
source = Source.from_dict(obj.get("source"))
|
|
987
|
+
target = Source.from_dict(obj.get("target"))
|
|
988
|
+
user1_id = from_union([from_none, lambda x: UUID(x)], obj.get("user1_id"))
|
|
989
|
+
user2_id = from_union([from_none, lambda x: UUID(x)], obj.get("user2_id"))
|
|
990
|
+
return AnnotationComparerRequest(created_by_user_id, hasura_url, id, image, network_experiment, owned_by_group_id, source, target, user1_id, user2_id)
|
|
991
|
+
|
|
992
|
+
def to_dict(self) -> dict:
|
|
993
|
+
result: dict = {}
|
|
994
|
+
result["created_by_user_id"] = str(self.created_by_user_id)
|
|
995
|
+
result["hasura_url"] = from_str(self.hasura_url)
|
|
996
|
+
result["id"] = str(self.id)
|
|
997
|
+
result["image"] = to_class(Image, self.image)
|
|
998
|
+
result["network_experiment"] = to_class(NetworkExperiment, self.network_experiment)
|
|
999
|
+
result["owned_by_group_id"] = str(self.owned_by_group_id)
|
|
1000
|
+
result["source"] = to_class(Source, self.source)
|
|
1001
|
+
result["target"] = to_class(Source, self.target)
|
|
1002
|
+
if self.user1_id is not None:
|
|
1003
|
+
result["user1_id"] = from_union([from_none, lambda x: str(x)], self.user1_id)
|
|
1004
|
+
if self.user2_id is not None:
|
|
1005
|
+
result["user2_id"] = from_union([from_none, lambda x: str(x)], self.user2_id)
|
|
1006
|
+
return result
|
|
1007
|
+
|
|
1008
|
+
|
|
1009
|
+
def annotation_comparer_request_from_dict(s: Any) -> AnnotationComparerRequest:
|
|
1010
|
+
return AnnotationComparerRequest.from_dict(s)
|
|
1011
|
+
|
|
1012
|
+
|
|
1013
|
+
def annotation_comparer_request_to_dict(x: AnnotationComparerRequest) -> Any:
|
|
1014
|
+
return to_class(AnnotationComparerRequest, x)
|