superiorvision 0.30.0.dev0__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.
Files changed (96) hide show
  1. superiorvision/__init__.py +19 -0
  2. superiorvision-0.30.0.dev0.dist-info/METADATA +398 -0
  3. superiorvision-0.30.0.dev0.dist-info/RECORD +96 -0
  4. superiorvision-0.30.0.dev0.dist-info/WHEEL +5 -0
  5. superiorvision-0.30.0.dev0.dist-info/licenses/LICENSE.md +9 -0
  6. superiorvision-0.30.0.dev0.dist-info/top_level.txt +2 -0
  7. supervision/__init__.py +318 -0
  8. supervision/annotators/__init__.py +0 -0
  9. supervision/annotators/base.py +21 -0
  10. supervision/annotators/core.py +3551 -0
  11. supervision/annotators/utils.py +541 -0
  12. supervision/assets/__init__.py +4 -0
  13. supervision/assets/downloader.py +166 -0
  14. supervision/assets/list.py +84 -0
  15. supervision/classification/__init__.py +0 -0
  16. supervision/classification/core.py +216 -0
  17. supervision/config.py +13 -0
  18. supervision/dataset/__init__.py +0 -0
  19. supervision/dataset/core.py +1313 -0
  20. supervision/dataset/formats/__init__.py +0 -0
  21. supervision/dataset/formats/coco.py +708 -0
  22. supervision/dataset/formats/createml.py +331 -0
  23. supervision/dataset/formats/labelme.py +405 -0
  24. supervision/dataset/formats/pascal_voc.py +449 -0
  25. supervision/dataset/formats/yolo.py +502 -0
  26. supervision/dataset/utils.py +265 -0
  27. supervision/detection/__init__.py +0 -0
  28. supervision/detection/compact_mask.py +1927 -0
  29. supervision/detection/core.py +3864 -0
  30. supervision/detection/line_zone.py +924 -0
  31. supervision/detection/overlap_filter.py +426 -0
  32. supervision/detection/tensor_utils.py +1596 -0
  33. supervision/detection/tensor_views.py +48 -0
  34. supervision/detection/tools/__init__.py +0 -0
  35. supervision/detection/tools/csv_sink.py +242 -0
  36. supervision/detection/tools/inference_slicer.py +776 -0
  37. supervision/detection/tools/json_sink.py +215 -0
  38. supervision/detection/tools/polygon_zone.py +266 -0
  39. supervision/detection/tools/smoother.py +218 -0
  40. supervision/detection/tools/transformers.py +265 -0
  41. supervision/detection/utils/__init__.py +12 -0
  42. supervision/detection/utils/_typing.py +11 -0
  43. supervision/detection/utils/boxes.py +510 -0
  44. supervision/detection/utils/converters.py +830 -0
  45. supervision/detection/utils/internal.py +806 -0
  46. supervision/detection/utils/iou_and_nms.py +1606 -0
  47. supervision/detection/utils/masks.py +625 -0
  48. supervision/detection/utils/polygons.py +128 -0
  49. supervision/detection/utils/vlms.py +97 -0
  50. supervision/detection/vlm.py +945 -0
  51. supervision/draw/__init__.py +0 -0
  52. supervision/draw/base.py +14 -0
  53. supervision/draw/color.py +598 -0
  54. supervision/draw/utils.py +527 -0
  55. supervision/geometry/__init__.py +0 -0
  56. supervision/geometry/core.py +208 -0
  57. supervision/geometry/utils.py +54 -0
  58. supervision/key_points/__init__.py +0 -0
  59. supervision/key_points/annotators.py +997 -0
  60. supervision/key_points/core.py +1506 -0
  61. supervision/key_points/skeletons.py +2646 -0
  62. supervision/keypoint/__init__.py +13 -0
  63. supervision/keypoint/annotators.py +13 -0
  64. supervision/keypoint/core.py +8 -0
  65. supervision/metrics/__init__.py +40 -0
  66. supervision/metrics/core.py +74 -0
  67. supervision/metrics/detection.py +1632 -0
  68. supervision/metrics/f1_score.py +815 -0
  69. supervision/metrics/mean_average_precision.py +1723 -0
  70. supervision/metrics/mean_average_recall.py +734 -0
  71. supervision/metrics/precision.py +815 -0
  72. supervision/metrics/recall.py +774 -0
  73. supervision/metrics/utils/__init__.py +0 -0
  74. supervision/metrics/utils/matching.py +56 -0
  75. supervision/metrics/utils/object_size.py +256 -0
  76. supervision/metrics/utils/utils.py +9 -0
  77. supervision/py.typed +0 -0
  78. supervision/tracker/__init__.py +5 -0
  79. supervision/tracker/byte_tracker/__init__.py +0 -0
  80. supervision/tracker/byte_tracker/core.py +448 -0
  81. supervision/tracker/byte_tracker/kalman_filter.py +186 -0
  82. supervision/tracker/byte_tracker/matching.py +211 -0
  83. supervision/tracker/byte_tracker/single_object_track.py +194 -0
  84. supervision/tracker/byte_tracker/utils.py +34 -0
  85. supervision/utils/__init__.py +0 -0
  86. supervision/utils/conversion.py +223 -0
  87. supervision/utils/deprecate.py +54 -0
  88. supervision/utils/file.py +209 -0
  89. supervision/utils/image.py +988 -0
  90. supervision/utils/internal.py +209 -0
  91. supervision/utils/iterables.py +103 -0
  92. supervision/utils/logger.py +61 -0
  93. supervision/utils/notebook.py +124 -0
  94. supervision/utils/tensor.py +362 -0
  95. supervision/utils/video.py +533 -0
  96. supervision/validators/__init__.py +379 -0
@@ -0,0 +1,318 @@
1
+ import importlib.metadata as importlib_metadata
2
+ from typing import TYPE_CHECKING, Any
3
+
4
+ try:
5
+ # This will read version from pyproject.toml
6
+ __version__ = importlib_metadata.version("superiorvision")
7
+ except importlib_metadata.PackageNotFoundError:
8
+ __version__ = "development"
9
+
10
+ from supervision.annotators.core import (
11
+ BackgroundOverlayAnnotator,
12
+ BlurAnnotator,
13
+ BoxAnnotator,
14
+ BoxCornerAnnotator,
15
+ CircleAnnotator,
16
+ ColorAnnotator,
17
+ ComparisonAnnotator,
18
+ CropAnnotator,
19
+ DotAnnotator,
20
+ EllipseAnnotator,
21
+ HaloAnnotator,
22
+ HeatMapAnnotator,
23
+ IconAnnotator,
24
+ LabelAnnotator,
25
+ MaskAnnotator,
26
+ OrientedBoxAnnotator,
27
+ PercentageBarAnnotator,
28
+ PixelateAnnotator,
29
+ PolygonAnnotator,
30
+ RichLabelAnnotator,
31
+ RoundBoxAnnotator,
32
+ TraceAnnotator,
33
+ TriangleAnnotator,
34
+ )
35
+ from supervision.annotators.utils import (
36
+ ColorLookup,
37
+ hex_to_rgba,
38
+ is_valid_hex,
39
+ rgba_to_hex,
40
+ )
41
+ from supervision.classification.core import Classifications
42
+ from supervision.dataset.core import (
43
+ BaseDataset,
44
+ ClassificationDataset,
45
+ DetectionDataset,
46
+ )
47
+ from supervision.dataset.formats.coco import get_coco_class_index_mapping
48
+ from supervision.detection.compact_mask import CompactMask
49
+ from supervision.detection.core import Detections
50
+ from supervision.detection.line_zone import (
51
+ LineZone,
52
+ LineZoneAnnotator,
53
+ LineZoneAnnotatorMulticlass,
54
+ )
55
+ from supervision.detection.overlap_filter import (
56
+ box_non_max_merge,
57
+ box_non_max_suppression,
58
+ mask_non_max_merge,
59
+ mask_non_max_suppression,
60
+ )
61
+ from supervision.detection.tensor_utils import (
62
+ box_iou_batch,
63
+ calculate_masks_centroids,
64
+ clip_boxes,
65
+ mask_iou_batch,
66
+ mask_to_polygons,
67
+ mask_to_xyxy,
68
+ move_boxes,
69
+ move_masks,
70
+ oriented_box_iou_batch,
71
+ pad_boxes,
72
+ polygon_to_mask,
73
+ polygon_to_xyxy,
74
+ scale_boxes,
75
+ xcycwh_to_xyxy,
76
+ xywh_to_xyxy,
77
+ xyxy_to_polygons,
78
+ )
79
+ from supervision.detection.tools.csv_sink import CSVSink
80
+ from supervision.detection.tools.inference_slicer import (
81
+ InferenceSlicer,
82
+ WindowedRasterDataset,
83
+ )
84
+ from supervision.detection.tools.json_sink import JSONSink
85
+ from supervision.detection.tools.polygon_zone import PolygonZone, PolygonZoneAnnotator
86
+ from supervision.detection.tools.smoother import DetectionsSmoother
87
+ from supervision.detection.utils.boxes import (
88
+ denormalize_boxes,
89
+ xyxyxyxy_to_xyxy,
90
+ )
91
+ from supervision.detection.utils.converters import (
92
+ is_compressed_rle,
93
+ mask_to_rle,
94
+ rle_to_mask,
95
+ xyxy_to_mask,
96
+ xyxy_to_xcycarh,
97
+ xyxy_to_xywh,
98
+ )
99
+ from supervision.detection.utils.iou_and_nms import (
100
+ OverlapFilter,
101
+ OverlapMetric,
102
+ box_iou,
103
+ box_iou_batch_with_jaccard,
104
+ oriented_box_non_max_merge,
105
+ oriented_box_non_max_suppression,
106
+ )
107
+ from supervision.detection.utils.masks import (
108
+ contains_holes,
109
+ contains_multiple_segments,
110
+ filter_segments_by_distance,
111
+ mask_to_roi,
112
+ )
113
+ from supervision.detection.utils.polygons import (
114
+ approximate_polygon,
115
+ filter_polygons_by_area,
116
+ )
117
+ from supervision.detection.utils.vlms import edit_distance, fuzzy_match_index
118
+ from supervision.detection.vlm import LMM, VLM
119
+ from supervision.draw.color import Color, ColorPalette
120
+ from supervision.draw.utils import (
121
+ calculate_optimal_line_thickness,
122
+ calculate_optimal_text_scale,
123
+ draw_filled_polygon,
124
+ draw_filled_rectangle,
125
+ draw_image,
126
+ draw_line,
127
+ draw_polygon,
128
+ draw_rectangle,
129
+ draw_text,
130
+ )
131
+ from supervision.geometry.core import Point, Position, Rect
132
+ from supervision.geometry.utils import get_polygon_center
133
+ from supervision.key_points.annotators import (
134
+ EdgeAnnotator,
135
+ VertexAnnotator,
136
+ VertexEllipseAnnotator,
137
+ VertexEllipseAreaAnnotator,
138
+ VertexEllipseHaloAnnotator,
139
+ VertexEllipseOutlineAnnotator,
140
+ VertexLabelAnnotator,
141
+ )
142
+ from supervision.key_points.core import KeyPoints
143
+ from supervision.metrics.detection import ConfusionMatrix, MeanAveragePrecision
144
+ from supervision.utils.conversion import cv2_to_pillow, pillow_to_cv2
145
+ from supervision.utils.file import list_files_with_extensions
146
+ from supervision.utils.image import (
147
+ ImageSink,
148
+ crop_image,
149
+ get_image_resolution_wh,
150
+ grayscale_image,
151
+ letterbox_image,
152
+ overlay_image,
153
+ resize_image,
154
+ scale_image,
155
+ tint_image,
156
+ )
157
+ from supervision.utils.notebook import plot_image, plot_images_grid
158
+ from supervision.utils.video import (
159
+ FPSMonitor,
160
+ VideoInfo,
161
+ VideoSink,
162
+ get_video_frames_generator,
163
+ process_video,
164
+ )
165
+
166
+ # Inference still imports the pre-0.30 name. The implementation was renamed
167
+ # upstream without changing its constructor or annotation contract.
168
+ BackgroundColorAnnotator = BackgroundOverlayAnnotator
169
+
170
+ if TYPE_CHECKING:
171
+ from supervision.tracker.byte_tracker.core import ByteTrack
172
+
173
+ __all__ = [
174
+ "LMM",
175
+ "VLM",
176
+ "BackgroundColorAnnotator",
177
+ "BackgroundOverlayAnnotator",
178
+ "BaseDataset",
179
+ "BlurAnnotator",
180
+ "BoxAnnotator",
181
+ "BoxCornerAnnotator",
182
+ "ByteTrack",
183
+ "CSVSink",
184
+ "CircleAnnotator",
185
+ "ClassificationDataset",
186
+ "Classifications",
187
+ "Color",
188
+ "ColorAnnotator",
189
+ "ColorLookup",
190
+ "ColorPalette",
191
+ "CompactMask",
192
+ "ComparisonAnnotator",
193
+ "ConfusionMatrix",
194
+ "CropAnnotator",
195
+ "DetectionDataset",
196
+ "Detections",
197
+ "DetectionsSmoother",
198
+ "DotAnnotator",
199
+ "EdgeAnnotator",
200
+ "EllipseAnnotator",
201
+ "FPSMonitor",
202
+ "HaloAnnotator",
203
+ "HeatMapAnnotator",
204
+ "IconAnnotator",
205
+ "ImageSink",
206
+ "InferenceSlicer",
207
+ "JSONSink",
208
+ "KeyPoints",
209
+ "LabelAnnotator",
210
+ "LineZone",
211
+ "LineZoneAnnotator",
212
+ "LineZoneAnnotatorMulticlass",
213
+ "MaskAnnotator",
214
+ "MeanAveragePrecision",
215
+ "OrientedBoxAnnotator",
216
+ "OverlapFilter",
217
+ "OverlapMetric",
218
+ "PercentageBarAnnotator",
219
+ "PixelateAnnotator",
220
+ "Point",
221
+ "PolygonAnnotator",
222
+ "PolygonZone",
223
+ "PolygonZoneAnnotator",
224
+ "Position",
225
+ "Rect",
226
+ "RichLabelAnnotator",
227
+ "RoundBoxAnnotator",
228
+ "TraceAnnotator",
229
+ "TriangleAnnotator",
230
+ "VertexAnnotator",
231
+ "VertexEllipseAnnotator",
232
+ "VertexEllipseAreaAnnotator",
233
+ "VertexEllipseHaloAnnotator",
234
+ "VertexEllipseOutlineAnnotator",
235
+ "VertexLabelAnnotator",
236
+ "VideoInfo",
237
+ "VideoSink",
238
+ "WindowedRasterDataset",
239
+ "approximate_polygon",
240
+ "box_iou",
241
+ "box_iou_batch",
242
+ "box_iou_batch_with_jaccard",
243
+ "box_non_max_merge",
244
+ "box_non_max_suppression",
245
+ "calculate_masks_centroids",
246
+ "calculate_optimal_line_thickness",
247
+ "calculate_optimal_text_scale",
248
+ "clip_boxes",
249
+ "contains_holes",
250
+ "contains_multiple_segments",
251
+ "crop_image",
252
+ "cv2_to_pillow",
253
+ "denormalize_boxes",
254
+ "draw_filled_polygon",
255
+ "draw_filled_rectangle",
256
+ "draw_image",
257
+ "draw_line",
258
+ "draw_polygon",
259
+ "draw_rectangle",
260
+ "draw_text",
261
+ "edit_distance",
262
+ "filter_polygons_by_area",
263
+ "filter_segments_by_distance",
264
+ "fuzzy_match_index",
265
+ "get_coco_class_index_mapping",
266
+ "get_image_resolution_wh",
267
+ "get_polygon_center",
268
+ "get_video_frames_generator",
269
+ "grayscale_image",
270
+ "hex_to_rgba",
271
+ "is_compressed_rle",
272
+ "is_valid_hex",
273
+ "letterbox_image",
274
+ "list_files_with_extensions",
275
+ "mask_iou_batch",
276
+ "mask_non_max_merge",
277
+ "mask_non_max_suppression",
278
+ "mask_to_polygons",
279
+ "mask_to_rle",
280
+ "mask_to_roi",
281
+ "mask_to_xyxy",
282
+ "move_boxes",
283
+ "move_masks",
284
+ "oriented_box_iou_batch",
285
+ "oriented_box_non_max_merge",
286
+ "oriented_box_non_max_suppression",
287
+ "overlay_image",
288
+ "pad_boxes",
289
+ "pillow_to_cv2",
290
+ "plot_image",
291
+ "plot_images_grid",
292
+ "polygon_to_mask",
293
+ "polygon_to_xyxy",
294
+ "process_video",
295
+ "resize_image",
296
+ "rgba_to_hex",
297
+ "rle_to_mask",
298
+ "scale_boxes",
299
+ "scale_image",
300
+ "tint_image",
301
+ "xcycwh_to_xyxy",
302
+ "xywh_to_xyxy",
303
+ "xyxy_to_mask",
304
+ "xyxy_to_polygons",
305
+ "xyxy_to_xcycarh",
306
+ "xyxy_to_xywh",
307
+ "xyxyxyxy_to_xyxy",
308
+ ]
309
+
310
+
311
+ def __getattr__(name: str) -> Any:
312
+ """Lazily resolve deprecated compatibility exports."""
313
+ if name == "ByteTrack":
314
+ from supervision.tracker.byte_tracker.core import ByteTrack as byte_track
315
+
316
+ globals()[name] = byte_track
317
+ return byte_track
318
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
File without changes
@@ -0,0 +1,21 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import Any
3
+
4
+ from supervision.detection.core import Detections
5
+
6
+
7
+ class BaseAnnotator(ABC):
8
+ """Base class for annotators that consume :class:`Detections`.
9
+
10
+ Attributes:
11
+ requires_mask: Whether integrations must provide ``Detections.mask`` for
12
+ this annotator. Check this before materializing expensive mask payloads.
13
+ """
14
+
15
+ requires_mask: bool = False
16
+
17
+ @abstractmethod
18
+ def annotate(
19
+ self, scene: Any, detections: Detections, *args: Any, **kwargs: Any
20
+ ) -> Any:
21
+ pass