valor-lite 0.33.8__py3-none-any.whl → 0.33.9__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.
@@ -1,380 +0,0 @@
1
- from dataclasses import dataclass
2
- from enum import Enum
3
-
4
- from valor_lite.schemas import Metric
5
-
6
-
7
- class MetricType(str, Enum):
8
- Counts = "Counts"
9
- Accuracy = "Accuracy"
10
- Precision = "Precision"
11
- Recall = "Recall"
12
- F1 = "F1"
13
- AP = "AP"
14
- AR = "AR"
15
- mAP = "mAP"
16
- mAR = "mAR"
17
- APAveragedOverIOUs = "APAveragedOverIOUs"
18
- mAPAveragedOverIOUs = "mAPAveragedOverIOUs"
19
- ARAveragedOverScores = "ARAveragedOverScores"
20
- mARAveragedOverScores = "mARAveragedOverScores"
21
- PrecisionRecallCurve = "PrecisionRecallCurve"
22
- ConfusionMatrix = "ConfusionMatrix"
23
-
24
- @classmethod
25
- def base_metrics(cls):
26
- return [
27
- cls.Counts,
28
- cls.Accuracy,
29
- cls.Precision,
30
- cls.Recall,
31
- cls.F1,
32
- cls.AP,
33
- cls.AR,
34
- cls.mAP,
35
- cls.mAR,
36
- cls.APAveragedOverIOUs,
37
- cls.mAPAveragedOverIOUs,
38
- cls.ARAveragedOverScores,
39
- cls.mARAveragedOverScores,
40
- cls.PrecisionRecallCurve,
41
- ]
42
-
43
-
44
- @dataclass
45
- class Counts:
46
- tp: int
47
- fp: int
48
- fn: int
49
- label: str
50
- iou_threshold: float
51
- score_threshold: float
52
-
53
- @property
54
- def metric(self) -> Metric:
55
- return Metric(
56
- type=type(self).__name__,
57
- value={
58
- "tp": self.tp,
59
- "fp": self.fp,
60
- "fn": self.fn,
61
- },
62
- parameters={
63
- "iou_threshold": self.iou_threshold,
64
- "score_threshold": self.score_threshold,
65
- "label": self.label,
66
- },
67
- )
68
-
69
- def to_dict(self) -> dict:
70
- return self.metric.to_dict()
71
-
72
-
73
- @dataclass
74
- class ClassMetric:
75
- value: float
76
- label: str
77
- iou_threshold: float
78
- score_threshold: float
79
-
80
- @property
81
- def metric(self) -> Metric:
82
- return Metric(
83
- type=type(self).__name__,
84
- value=self.value,
85
- parameters={
86
- "iou_threshold": self.iou_threshold,
87
- "score_threshold": self.score_threshold,
88
- "label": self.label,
89
- },
90
- )
91
-
92
- def to_dict(self) -> dict:
93
- return self.metric.to_dict()
94
-
95
-
96
- class Precision(ClassMetric):
97
- pass
98
-
99
-
100
- class Recall(ClassMetric):
101
- pass
102
-
103
-
104
- class Accuracy(ClassMetric):
105
- pass
106
-
107
-
108
- class F1(ClassMetric):
109
- pass
110
-
111
-
112
- @dataclass
113
- class AP:
114
- value: float
115
- iou_threshold: float
116
- label: str
117
-
118
- @property
119
- def metric(self) -> Metric:
120
- return Metric(
121
- type=type(self).__name__,
122
- value=self.value,
123
- parameters={
124
- "iou_threshold": self.iou_threshold,
125
- "label": self.label,
126
- },
127
- )
128
-
129
- def to_dict(self) -> dict:
130
- return self.metric.to_dict()
131
-
132
-
133
- @dataclass
134
- class mAP:
135
- value: float
136
- iou_threshold: float
137
-
138
- @property
139
- def metric(self) -> Metric:
140
- return Metric(
141
- type=type(self).__name__,
142
- value=self.value,
143
- parameters={
144
- "iou_threshold": self.iou_threshold,
145
- },
146
- )
147
-
148
- def to_dict(self) -> dict:
149
- return self.metric.to_dict()
150
-
151
-
152
- @dataclass
153
- class APAveragedOverIOUs:
154
- value: float
155
- iou_thresholds: list[float]
156
- label: str
157
-
158
- @property
159
- def metric(self) -> Metric:
160
- return Metric(
161
- type=type(self).__name__,
162
- value=self.value,
163
- parameters={
164
- "iou_thresholds": self.iou_thresholds,
165
- "label": self.label,
166
- },
167
- )
168
-
169
- def to_dict(self) -> dict:
170
- return self.metric.to_dict()
171
-
172
-
173
- @dataclass
174
- class mAPAveragedOverIOUs:
175
- value: float
176
- iou_thresholds: list[float]
177
-
178
- @property
179
- def metric(self) -> Metric:
180
- return Metric(
181
- type=type(self).__name__,
182
- value=self.value,
183
- parameters={
184
- "iou_thresholds": self.iou_thresholds,
185
- },
186
- )
187
-
188
- def to_dict(self) -> dict:
189
- return self.metric.to_dict()
190
-
191
-
192
- @dataclass
193
- class AR:
194
- value: float
195
- score_threshold: float
196
- iou_thresholds: list[float]
197
- label: str
198
-
199
- @property
200
- def metric(self) -> Metric:
201
- return Metric(
202
- type=type(self).__name__,
203
- value=self.value,
204
- parameters={
205
- "score_threshold": self.score_threshold,
206
- "iou_thresholds": self.iou_thresholds,
207
- "label": self.label,
208
- },
209
- )
210
-
211
- def to_dict(self) -> dict:
212
- return self.metric.to_dict()
213
-
214
-
215
- @dataclass
216
- class mAR:
217
- value: float
218
- score_threshold: float
219
- iou_thresholds: list[float]
220
-
221
- @property
222
- def metric(self) -> Metric:
223
- return Metric(
224
- type=type(self).__name__,
225
- value=self.value,
226
- parameters={
227
- "score_threshold": self.score_threshold,
228
- "iou_thresholds": self.iou_thresholds,
229
- },
230
- )
231
-
232
- def to_dict(self) -> dict:
233
- return self.metric.to_dict()
234
-
235
-
236
- @dataclass
237
- class ARAveragedOverScores:
238
- value: float
239
- score_thresholds: list[float]
240
- iou_thresholds: list[float]
241
- label: str
242
-
243
- @property
244
- def metric(self) -> Metric:
245
- return Metric(
246
- type=type(self).__name__,
247
- value=self.value,
248
- parameters={
249
- "score_thresholds": self.score_thresholds,
250
- "iou_thresholds": self.iou_thresholds,
251
- "label": self.label,
252
- },
253
- )
254
-
255
- def to_dict(self) -> dict:
256
- return self.metric.to_dict()
257
-
258
-
259
- @dataclass
260
- class mARAveragedOverScores:
261
- value: float
262
- score_thresholds: list[float]
263
- iou_thresholds: list[float]
264
-
265
- @property
266
- def metric(self) -> Metric:
267
- return Metric(
268
- type=type(self).__name__,
269
- value=self.value,
270
- parameters={
271
- "score_thresholds": self.score_thresholds,
272
- "iou_thresholds": self.iou_thresholds,
273
- },
274
- )
275
-
276
- def to_dict(self) -> dict:
277
- return self.metric.to_dict()
278
-
279
-
280
- @dataclass
281
- class PrecisionRecallCurve:
282
- """
283
- Interpolated over recalls 0.0, 0.01, ..., 1.0.
284
- """
285
-
286
- precision: list[float]
287
- iou_threshold: float
288
- label: str
289
-
290
- @property
291
- def metric(self) -> Metric:
292
- return Metric(
293
- type=type(self).__name__,
294
- value=self.precision,
295
- parameters={
296
- "iou_threshold": self.iou_threshold,
297
- "label": self.label,
298
- },
299
- )
300
-
301
- def to_dict(self) -> dict:
302
- return self.metric.to_dict()
303
-
304
-
305
- @dataclass
306
- class ConfusionMatrix:
307
- confusion_matrix: dict[
308
- str, # ground truth label value
309
- dict[
310
- str, # prediction label value
311
- dict[
312
- str, # either `count` or `examples`
313
- int
314
- | list[
315
- dict[
316
- str, # either `datum`, `groundtruth`, `prediction` or score
317
- str # datum uid
318
- | dict[
319
- str, float
320
- ] # bounding box (xmin, xmax, ymin, ymax)
321
- | float, # prediction score
322
- ]
323
- ],
324
- ],
325
- ],
326
- ]
327
- hallucinations: dict[
328
- str, # prediction label value
329
- dict[
330
- str, # either `count` or `examples`
331
- int
332
- | list[
333
- dict[
334
- str, # either `datum`, `prediction` or score
335
- str # datum uid
336
- | float # prediction score
337
- | dict[
338
- str, float
339
- ], # bounding box (xmin, xmax, ymin, ymax)
340
- ]
341
- ],
342
- ],
343
- ]
344
- missing_predictions: dict[
345
- str, # ground truth label value
346
- dict[
347
- str, # either `count` or `examples`
348
- int
349
- | list[
350
- dict[
351
- str, # either `datum` or `groundtruth`
352
- str # datum uid
353
- | dict[
354
- str, float
355
- ], # bounding box (xmin, xmax, ymin, ymax)
356
- ]
357
- ],
358
- ],
359
- ]
360
- score_threshold: float
361
- iou_threshold: float
362
- number_of_examples: int
363
-
364
- @property
365
- def metric(self) -> Metric:
366
- return Metric(
367
- type=type(self).__name__,
368
- value={
369
- "confusion_matrix": self.confusion_matrix,
370
- "hallucinations": self.hallucinations,
371
- "missing_predictions": self.missing_predictions,
372
- },
373
- parameters={
374
- "score_threshold": self.score_threshold,
375
- "iou_threshold": self.iou_threshold,
376
- },
377
- )
378
-
379
- def to_dict(self) -> dict:
380
- return self.metric.to_dict()
@@ -1,49 +0,0 @@
1
- from dataclasses import dataclass, field
2
-
3
- import numpy as np
4
- from numpy.typing import NDArray
5
-
6
-
7
- @dataclass
8
- class Bitmask:
9
- mask: NDArray[np.bool_]
10
- label: str
11
-
12
- def __post_init__(self):
13
- if self.mask.dtype != np.bool_:
14
- raise ValueError(
15
- f"Bitmask recieved mask with dtype `{self.mask.dtype}`."
16
- )
17
-
18
-
19
- @dataclass
20
- class Segmentation:
21
- uid: str
22
- groundtruths: list[Bitmask]
23
- predictions: list[Bitmask]
24
- shape: tuple[int, ...] = field(default_factory=lambda: (0, 0))
25
- size: int = field(default=0)
26
-
27
- def __post_init__(self):
28
-
29
- groundtruth_shape = {
30
- groundtruth.mask.shape for groundtruth in self.groundtruths
31
- }
32
- prediction_shape = {
33
- prediction.mask.shape for prediction in self.predictions
34
- }
35
- if len(groundtruth_shape) == 0:
36
- raise ValueError("The segmenation is missing ground truths.")
37
- elif len(prediction_shape) == 0:
38
- raise ValueError("The segmenation is missing predictions.")
39
- elif (
40
- len(groundtruth_shape) != 1
41
- or len(prediction_shape) != 1
42
- or groundtruth_shape != prediction_shape
43
- ):
44
- raise ValueError(
45
- "A shape mismatch exists within the segmentation."
46
- )
47
-
48
- self.shape = groundtruth_shape.pop()
49
- self.size = int(np.prod(np.array(self.shape)))
@@ -1,119 +0,0 @@
1
- from dataclasses import dataclass
2
- from enum import Enum
3
-
4
- from valor_lite.schemas import Metric
5
-
6
-
7
- class MetricType(Enum):
8
- Precision = "Precision"
9
- Recall = "Recall"
10
- Accuracy = "Accuracy"
11
- F1 = "F1"
12
- IoU = "IoU"
13
- mIoU = "mIoU"
14
- ConfusionMatrix = "ConfusionMatrix"
15
-
16
- @classmethod
17
- def base(cls):
18
- return [
19
- cls.Precision,
20
- cls.Recall,
21
- cls.Accuracy,
22
- cls.F1,
23
- cls.IoU,
24
- cls.mIoU,
25
- cls.ConfusionMatrix,
26
- ]
27
-
28
-
29
- @dataclass
30
- class _LabelValue:
31
- value: float
32
- label: str
33
-
34
- @property
35
- def metric(self) -> Metric:
36
- return Metric(
37
- type=type(self).__name__,
38
- value=self.value,
39
- parameters={
40
- "label": self.label,
41
- },
42
- )
43
-
44
- def to_dict(self) -> dict:
45
- return self.metric.to_dict()
46
-
47
-
48
- class Precision(_LabelValue):
49
- pass
50
-
51
-
52
- class Recall(_LabelValue):
53
- pass
54
-
55
-
56
- class F1(_LabelValue):
57
- pass
58
-
59
-
60
- class IoU(_LabelValue):
61
- pass
62
-
63
-
64
- @dataclass
65
- class _Value:
66
- value: float
67
-
68
- @property
69
- def metric(self) -> Metric:
70
- return Metric(
71
- type=type(self).__name__,
72
- value=self.value,
73
- parameters={},
74
- )
75
-
76
- def to_dict(self) -> dict:
77
- return self.metric.to_dict()
78
-
79
-
80
- class Accuracy(_Value):
81
- pass
82
-
83
-
84
- class mIoU(_Value):
85
- pass
86
-
87
-
88
- @dataclass
89
- class ConfusionMatrix:
90
- confusion_matrix: dict[
91
- str, # ground truth label value
92
- dict[
93
- str, # prediction label value
94
- dict[str, float], # iou
95
- ],
96
- ]
97
- hallucinations: dict[
98
- str, # prediction label value
99
- dict[str, float], # percentage of pixels
100
- ]
101
- missing_predictions: dict[
102
- str, # ground truth label value
103
- dict[str, float], # percentage of pixels
104
- ]
105
-
106
- @property
107
- def metric(self) -> Metric:
108
- return Metric(
109
- type=type(self).__name__,
110
- value={
111
- "confusion_matrix": self.confusion_matrix,
112
- "hallucinations": self.hallucinations,
113
- "missing_predictions": self.missing_predictions,
114
- },
115
- parameters={},
116
- )
117
-
118
- def to_dict(self) -> dict:
119
- return self.metric.to_dict()
@@ -1,41 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: valor-lite
3
- Version: 0.33.8
4
- Summary: Compute valor metrics directly in your client.
5
- License: MIT License
6
-
7
- Copyright (c) 2023 Striveworks
8
-
9
- Permission is hereby granted, free of charge, to any person obtaining a copy
10
- of this software and associated documentation files (the "Software"), to deal
11
- in the Software without restriction, including without limitation the rights
12
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
- copies of the Software, and to permit persons to whom the Software is
14
- furnished to do so, subject to the following conditions:
15
-
16
- The above copyright notice and this permission notice shall be included in all
17
- copies or substantial portions of the Software.
18
-
19
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
- SOFTWARE.
26
-
27
- Project-URL: homepage, https://www.striveworks.com
28
- Requires-Python: >=3.10
29
- Description-Content-Type: text/markdown
30
- License-File: LICENSE
31
- Requires-Dist: Pillow >=9.1.0
32
- Requires-Dist: tqdm
33
- Requires-Dist: requests
34
- Requires-Dist: numpy
35
- Requires-Dist: shapely
36
- Requires-Dist: importlib-metadata ; python_version < "3.8"
37
- Provides-Extra: test
38
- Requires-Dist: pytest ; extra == 'test'
39
- Requires-Dist: coverage ; extra == 'test'
40
-
41
- # valor-lite: Compute classification, object detection, and segmentation metrics locally.
@@ -1,22 +0,0 @@
1
- valor_lite/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- valor_lite/schemas.py,sha256=r4cC10w1xYsA785KmGE4ePeOX3wzEs846vT7QAiVg_I,293
3
- valor_lite/classification/__init__.py,sha256=2wmmziIzUATm7MbmAcPNLXrEX5l4oeD7XBwPd9bWM3Q,506
4
- valor_lite/classification/annotation.py,sha256=efgwbkOYoujkg9r0CuzMIRfl93DuZV2ldQeW0CBVfeU,478
5
- valor_lite/classification/computation.py,sha256=qd9K7CcSGmMm_7shfX47_ZIuB-uE2LLiLMZSS_3NJTk,12093
6
- valor_lite/classification/manager.py,sha256=6YlkqCwuTcAoa40LU0EfXQyZFTwPyRnt5W19qs-T3Xk,24718
7
- valor_lite/classification/metric.py,sha256=tAxeuTvO5M9gsQWk47hT_Yea6lbfExe16FgkWYmjKGw,3763
8
- valor_lite/detection/__init__.py,sha256=PiKfemo8FkZRzBhPSjhil8ahGURLy0Vk_iV25CB4UBU,1139
9
- valor_lite/detection/annotation.py,sha256=kuW8PF4bitPA6cd5Unr5zqgw8nLnvM4BY0jZW14WFAI,4396
10
- valor_lite/detection/computation.py,sha256=7rOfVlYDadXcJ1_S0FJRF3IPigcsR7guk_0rXeIdAOE,26919
11
- valor_lite/detection/manager.py,sha256=QzSkiGUYJ4Z6o1QZKPe36Yc74u052h8g36-fUowRlv0,42620
12
- valor_lite/detection/metric.py,sha256=Wz4xHg0A7E7BFdUPMnrKnz63P6sD7pwHYM1UQ9_dsgY,8872
13
- valor_lite/segmentation/__init__.py,sha256=IdarTHKUuUMDvMBmInQu12Mm_NMCbql6Hf0nL5b56Ak,424
14
- valor_lite/segmentation/annotation.py,sha256=8m5ZsRAcDwQVEvn576Ec1DiNwvtxdKQJXpYoToRugfk,1412
15
- valor_lite/segmentation/computation.py,sha256=iJkEmTNmw9HwQCxSnpJkQsAdVcFriGhhu_WMks6D7tU,5122
16
- valor_lite/segmentation/manager.py,sha256=zn-l5NyrkaRck8dq5VOKCJFOtylSXsWuiQ_eBV8m8JM,16921
17
- valor_lite/segmentation/metric.py,sha256=hNn3lB-XJK5YW3itOWvvRMl6hZyWHMlC6smyeVhxeJE,2275
18
- valor_lite-0.33.8.dist-info/LICENSE,sha256=M0L53VuwfEEqezhHb7NPeYcO_glw7-k4DMLZQ3eRN64,1068
19
- valor_lite-0.33.8.dist-info/METADATA,sha256=MRi4I1Bu8ojuc9aUSWzkaaH9l5JMRUmenvHdo6bh50o,1865
20
- valor_lite-0.33.8.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
21
- valor_lite-0.33.8.dist-info/top_level.txt,sha256=9ujykxSwpl2Hu0_R95UQTR_l07k9UUTSdrpiqmq6zc4,11
22
- valor_lite-0.33.8.dist-info/RECORD,,
File without changes