denkproto 1.0.55__py3-none-any.whl → 1.0.56__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.55"
1
+ __version__ = "1.0.56"
@@ -15,6 +15,11 @@ def to_float(x: Any) -> float:
15
15
  return x
16
16
 
17
17
 
18
+ def from_int(x: Any) -> int:
19
+ assert isinstance(x, int) and not isinstance(x, bool)
20
+ return x
21
+
22
+
18
23
  def from_list(f: Callable[[Any], T], x: Any) -> List[T]:
19
24
  assert isinstance(x, list)
20
25
  return [f(y) for y in x]
@@ -44,11 +49,6 @@ def from_str(x: Any) -> str:
44
49
  return x
45
50
 
46
51
 
47
- def from_int(x: Any) -> int:
48
- assert isinstance(x, int) and not isinstance(x, bool)
49
- return x
50
-
51
-
52
52
  class BoundingBox:
53
53
  bottom_right_x: float
54
54
  bottom_right_y: float
@@ -101,29 +101,64 @@ class Point:
101
101
  return result
102
102
 
103
103
 
104
- class Polygon:
104
+ class OcrMarkupSchema:
105
+ """A single closed loop (ring) of a polygon, defining either an outer boundary or a hole."""
106
+
107
+ hierarchy: int
108
+ """Nesting level: 0=outer, 1=hole in level 0, 2=poly in level 1 hole, etc. Even levels are
109
+ filled areas, odd levels are holes.
110
+ """
105
111
  points: List[Point]
112
+ """Vertices of the ring."""
106
113
 
107
- def __init__(self, points: List[Point]) -> None:
114
+ def __init__(self, hierarchy: int, points: List[Point]) -> None:
115
+ self.hierarchy = hierarchy
108
116
  self.points = points
109
117
 
110
118
  @staticmethod
111
- def from_dict(obj: Any) -> 'Polygon':
119
+ def from_dict(obj: Any) -> 'OcrMarkupSchema':
112
120
  assert isinstance(obj, dict)
121
+ hierarchy = from_int(obj.get("hierarchy"))
113
122
  points = from_list(Point.from_dict, obj.get("points"))
114
- return Polygon(points)
123
+ return OcrMarkupSchema(hierarchy, points)
115
124
 
116
125
  def to_dict(self) -> dict:
117
126
  result: dict = {}
127
+ result["hierarchy"] = from_int(self.hierarchy)
118
128
  result["points"] = from_list(lambda x: to_class(Point, x), self.points)
119
129
  return result
120
130
 
121
131
 
132
+ class Polygon:
133
+ """A polygon defined by one or more rings, allowing for holes and nested structures."""
134
+
135
+ rings: List[OcrMarkupSchema]
136
+ """Array of polygon rings. The hierarchy field within each ring determines nesting and
137
+ fill/hole status.
138
+ """
139
+
140
+ def __init__(self, rings: List[OcrMarkupSchema]) -> None:
141
+ self.rings = rings
142
+
143
+ @staticmethod
144
+ def from_dict(obj: Any) -> 'Polygon':
145
+ assert isinstance(obj, dict)
146
+ rings = from_list(OcrMarkupSchema.from_dict, obj.get("rings"))
147
+ return Polygon(rings)
148
+
149
+ def to_dict(self) -> dict:
150
+ result: dict = {}
151
+ result["rings"] = from_list(lambda x: to_class(OcrMarkupSchema, x), self.rings)
152
+ return result
153
+
154
+
122
155
  class Annotation:
123
156
  bounding_box: Optional[BoundingBox]
124
157
  id: UUID
125
158
  label_id: UUID
126
159
  polygon: Optional[Polygon]
160
+ """A polygon defined by one or more rings, allowing for holes and nested structures."""
161
+
127
162
  text: str
128
163
 
129
164
  def __init__(self, bounding_box: Optional[BoundingBox], id: UUID, label_id: UUID, polygon: Optional[Polygon], text: str) -> None:
@@ -259,7 +259,7 @@ class PixelAnnotation:
259
259
  return result
260
260
 
261
261
 
262
- class PolygonAnnotationPoint:
262
+ class RingPoint:
263
263
  x: float
264
264
  y: float
265
265
 
@@ -268,11 +268,11 @@ class PolygonAnnotationPoint:
268
268
  self.y = y
269
269
 
270
270
  @staticmethod
271
- def from_dict(obj: Any) -> 'PolygonAnnotationPoint':
271
+ def from_dict(obj: Any) -> 'RingPoint':
272
272
  assert isinstance(obj, dict)
273
273
  x = from_float(obj.get("x"))
274
274
  y = from_float(obj.get("y"))
275
- return PolygonAnnotationPoint(x, y)
275
+ return RingPoint(x, y)
276
276
 
277
277
  def to_dict(self) -> dict:
278
278
  result: dict = {}
@@ -281,21 +281,54 @@ class PolygonAnnotationPoint:
281
281
  return result
282
282
 
283
283
 
284
- class PolygonAnnotation:
285
- points: List[PolygonAnnotationPoint]
284
+ class SegmentationMarkupSchema:
285
+ """A single closed loop (ring) of a polygon, defining either an outer boundary or a hole."""
286
+
287
+ hierarchy: int
288
+ """Nesting level: 0=outer, 1=hole in level 0, 2=poly in level 1 hole, etc. Even levels are
289
+ filled areas, odd levels are holes.
290
+ """
291
+ points: List[RingPoint]
292
+ """Vertices of the ring."""
286
293
 
287
- def __init__(self, points: List[PolygonAnnotationPoint]) -> None:
294
+ def __init__(self, hierarchy: int, points: List[RingPoint]) -> None:
295
+ self.hierarchy = hierarchy
288
296
  self.points = points
289
297
 
298
+ @staticmethod
299
+ def from_dict(obj: Any) -> 'SegmentationMarkupSchema':
300
+ assert isinstance(obj, dict)
301
+ hierarchy = from_int(obj.get("hierarchy"))
302
+ points = from_list(RingPoint.from_dict, obj.get("points"))
303
+ return SegmentationMarkupSchema(hierarchy, points)
304
+
305
+ def to_dict(self) -> dict:
306
+ result: dict = {}
307
+ result["hierarchy"] = from_int(self.hierarchy)
308
+ result["points"] = from_list(lambda x: to_class(RingPoint, x), self.points)
309
+ return result
310
+
311
+
312
+ class PolygonAnnotation:
313
+ """A polygon defined by one or more rings, allowing for holes and nested structures."""
314
+
315
+ rings: List[SegmentationMarkupSchema]
316
+ """Array of polygon rings. The hierarchy field within each ring determines nesting and
317
+ fill/hole status.
318
+ """
319
+
320
+ def __init__(self, rings: List[SegmentationMarkupSchema]) -> None:
321
+ self.rings = rings
322
+
290
323
  @staticmethod
291
324
  def from_dict(obj: Any) -> 'PolygonAnnotation':
292
325
  assert isinstance(obj, dict)
293
- points = from_list(PolygonAnnotationPoint.from_dict, obj.get("points"))
294
- return PolygonAnnotation(points)
326
+ rings = from_list(SegmentationMarkupSchema.from_dict, obj.get("rings"))
327
+ return PolygonAnnotation(rings)
295
328
 
296
329
  def to_dict(self) -> dict:
297
330
  result: dict = {}
298
- result["points"] = from_list(lambda x: to_class(PolygonAnnotationPoint, x), self.points)
331
+ result["rings"] = from_list(lambda x: to_class(SegmentationMarkupSchema, x), self.rings)
299
332
  return result
300
333
 
301
334
 
@@ -1,5 +1,5 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: denkproto
3
- Version: 1.0.55
3
+ Version: 1.0.56
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=2DUObEwLNvKLYm4zUMNwCtyPL1NYz7E03pnCYA8NfhE,23
7
+ denkproto/__about__.py,sha256=AqHDp-M0PX88EV1MMkz1_IToW1VDYMDczL653bhq-uk,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
@@ -25,8 +25,8 @@ denkproto/results_pb2_grpc.py,sha256=z-4qcDMjjuPRy7lDtECTtReByVEyz3fjIPES9dMlO58
25
25
  denkproto/json/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
26
  denkproto/json/classification_markup.py,sha256=vTu0H7Cb3gU6UUUSg1vDTRlFUorZrjMbcp_yx6UssZA,2461
27
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.55.dist-info/METADATA,sha256=AFOKpt_vbco5lDLcaUQ-6974tk6VwqykEKJRz8sYQiU,110
31
- denkproto-1.0.55.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
32
- denkproto-1.0.55.dist-info/RECORD,,
28
+ denkproto/json/ocr_markup.py,sha256=KyOpth9evOekyhTJdZSnYyB9EIyoWbY33sqncb_jBgw,7069
29
+ denkproto/json/segmentation_markup.py,sha256=wB_aKia7MvwfWaamgyCZdxb3hmasLpIOdDiDntuIO2E,21070
30
+ denkproto-1.0.56.dist-info/METADATA,sha256=jzAqxFdZqZHn2haeSmDe6hn6TvWfUvwRsv4n8DIdqIE,110
31
+ denkproto-1.0.56.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
32
+ denkproto-1.0.56.dist-info/RECORD,,