valor-lite 0.32.2a2__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 valor-lite might be problematic. Click here for more details.

@@ -0,0 +1,357 @@
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
+ DetailedPrecisionRecallCurve = "DetailedPrecisionRecallCurve"
23
+
24
+
25
+ @dataclass
26
+ class Counts:
27
+ tp: int
28
+ fp: int
29
+ fn: int
30
+ label: tuple[str, str]
31
+ iou: float
32
+ score: float
33
+
34
+ @property
35
+ def metric(self) -> Metric:
36
+ return Metric(
37
+ type=type(self).__name__,
38
+ value={
39
+ "tp": self.tp,
40
+ "fp": self.fp,
41
+ "fn": self.fn,
42
+ },
43
+ parameters={
44
+ "iou": self.iou,
45
+ "score": self.score,
46
+ "label": {
47
+ "key": self.label[0],
48
+ "value": self.label[1],
49
+ },
50
+ },
51
+ )
52
+
53
+ def to_dict(self) -> dict:
54
+ return self.metric.to_dict()
55
+
56
+
57
+ @dataclass
58
+ class ClassMetric:
59
+ value: float
60
+ label: tuple[str, str]
61
+ iou: float
62
+ score: float
63
+
64
+ @property
65
+ def metric(self) -> Metric:
66
+ return Metric(
67
+ type=type(self).__name__,
68
+ value=self.value,
69
+ parameters={
70
+ "iou": self.iou,
71
+ "score": self.score,
72
+ "label": {
73
+ "key": self.label[0],
74
+ "value": self.label[1],
75
+ },
76
+ },
77
+ )
78
+
79
+ def to_dict(self) -> dict:
80
+ return self.metric.to_dict()
81
+
82
+
83
+ class Precision(ClassMetric):
84
+ pass
85
+
86
+
87
+ class Recall(ClassMetric):
88
+ pass
89
+
90
+
91
+ class Accuracy(ClassMetric):
92
+ pass
93
+
94
+
95
+ class F1(ClassMetric):
96
+ pass
97
+
98
+
99
+ @dataclass
100
+ class AP:
101
+ value: float
102
+ iou: float
103
+ label: tuple[str, str]
104
+
105
+ @property
106
+ def metric(self) -> Metric:
107
+ return Metric(
108
+ type=type(self).__name__,
109
+ value=self.value,
110
+ parameters={
111
+ "iou": self.iou,
112
+ "label": {
113
+ "key": self.label[0],
114
+ "value": self.label[1],
115
+ },
116
+ },
117
+ )
118
+
119
+ def to_dict(self) -> dict:
120
+ return self.metric.to_dict()
121
+
122
+
123
+ @dataclass
124
+ class mAP:
125
+ value: float
126
+ iou: float
127
+ label_key: str
128
+
129
+ @property
130
+ def metric(self) -> Metric:
131
+ return Metric(
132
+ type=type(self).__name__,
133
+ value=self.value,
134
+ parameters={
135
+ "iou": self.iou,
136
+ "label_key": self.label_key,
137
+ },
138
+ )
139
+
140
+ def to_dict(self) -> dict:
141
+ return self.metric.to_dict()
142
+
143
+
144
+ @dataclass
145
+ class APAveragedOverIOUs:
146
+ value: float
147
+ ious: list[float]
148
+ label: tuple[str, str]
149
+
150
+ @property
151
+ def metric(self) -> Metric:
152
+ return Metric(
153
+ type=type(self).__name__,
154
+ value=self.value,
155
+ parameters={
156
+ "ious": self.ious,
157
+ "label": {
158
+ "key": self.label[0],
159
+ "value": self.label[1],
160
+ },
161
+ },
162
+ )
163
+
164
+ def to_dict(self) -> dict:
165
+ return self.metric.to_dict()
166
+
167
+
168
+ @dataclass
169
+ class mAPAveragedOverIOUs:
170
+ value: float
171
+ ious: list[float]
172
+ label_key: str
173
+
174
+ @property
175
+ def metric(self) -> Metric:
176
+ return Metric(
177
+ type=type(self).__name__,
178
+ value=self.value,
179
+ parameters={
180
+ "ious": self.ious,
181
+ "label_key": self.label_key,
182
+ },
183
+ )
184
+
185
+ def to_dict(self) -> dict:
186
+ return self.metric.to_dict()
187
+
188
+
189
+ @dataclass
190
+ class AR:
191
+ value: float
192
+ score: float
193
+ ious: list[float]
194
+ label: tuple[str, str]
195
+
196
+ @property
197
+ def metric(self) -> Metric:
198
+ return Metric(
199
+ type=type(self).__name__,
200
+ value=self.value,
201
+ parameters={
202
+ "score": self.score,
203
+ "ious": self.ious,
204
+ "label": {
205
+ "key": self.label[0],
206
+ "value": self.label[1],
207
+ },
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: float
219
+ ious: list[float]
220
+ label_key: str
221
+
222
+ @property
223
+ def metric(self) -> Metric:
224
+ return Metric(
225
+ type=type(self).__name__,
226
+ value=self.value,
227
+ parameters={
228
+ "score": self.score,
229
+ "ious": self.ious,
230
+ "label_key": self.label_key,
231
+ },
232
+ )
233
+
234
+ def to_dict(self) -> dict:
235
+ return self.metric.to_dict()
236
+
237
+
238
+ @dataclass
239
+ class ARAveragedOverScores:
240
+ value: float
241
+ scores: list[float]
242
+ ious: list[float]
243
+ label: tuple[str, str]
244
+
245
+ @property
246
+ def metric(self) -> Metric:
247
+ return Metric(
248
+ type=type(self).__name__,
249
+ value=self.value,
250
+ parameters={
251
+ "scores": self.scores,
252
+ "ious": self.ious,
253
+ "label": {
254
+ "key": self.label[0],
255
+ "value": self.label[1],
256
+ },
257
+ },
258
+ )
259
+
260
+ def to_dict(self) -> dict:
261
+ return self.metric.to_dict()
262
+
263
+
264
+ @dataclass
265
+ class mARAveragedOverScores:
266
+ value: float
267
+ scores: list[float]
268
+ ious: list[float]
269
+ label_key: str
270
+
271
+ @property
272
+ def metric(self) -> Metric:
273
+ return Metric(
274
+ type=type(self).__name__,
275
+ value=self.value,
276
+ parameters={
277
+ "scores": self.scores,
278
+ "ious": self.ious,
279
+ "label_key": self.label_key,
280
+ },
281
+ )
282
+
283
+ def to_dict(self) -> dict:
284
+ return self.metric.to_dict()
285
+
286
+
287
+ @dataclass
288
+ class PrecisionRecallCurve:
289
+ """
290
+ Interpolated over recalls 0.0, 0.01, ..., 1.0.
291
+ """
292
+
293
+ precision: list[float]
294
+ iou: float
295
+ label: tuple[str, str]
296
+
297
+ @property
298
+ def metric(self) -> Metric:
299
+ return Metric(
300
+ type=type(self).__name__,
301
+ value=self.precision,
302
+ parameters={
303
+ "iou": self.iou,
304
+ "label": {"key": self.label[0], "value": self.label[1]},
305
+ },
306
+ )
307
+
308
+ def to_dict(self) -> dict:
309
+ return self.metric.to_dict()
310
+
311
+
312
+ @dataclass
313
+ class DetailedPrecisionRecallPoint:
314
+ score: float
315
+ tp: int
316
+ fp_misclassification: int
317
+ fp_hallucination: int
318
+ fn_misclassification: int
319
+ fn_missing_prediction: int
320
+ tp_examples: list[str]
321
+ fp_misclassification_examples: list[str]
322
+ fp_hallucination_examples: list[str]
323
+ fn_misclassification_examples: list[str]
324
+ fn_missing_prediction_examples: list[str]
325
+
326
+ def to_dict(self) -> dict:
327
+ return {
328
+ "score": self.score,
329
+ "tp": self.tp,
330
+ "fp_misclassification": self.fp_misclassification,
331
+ "fp_hallucination": self.fp_hallucination,
332
+ "fn_misclassification": self.fn_misclassification,
333
+ "fn_missing_prediction": self.fn_missing_prediction,
334
+ "tp_examples": self.tp_examples,
335
+ "fp_misclassification_examples": self.fp_misclassification_examples,
336
+ "fp_hallucination_examples": self.fp_hallucination_examples,
337
+ "fn_misclassification_examples": self.fn_misclassification_examples,
338
+ "fn_missing_prediction_examples": self.fn_missing_prediction_examples,
339
+ }
340
+
341
+
342
+ @dataclass
343
+ class DetailedPrecisionRecallCurve:
344
+ iou: float
345
+ value: list[DetailedPrecisionRecallPoint]
346
+ label: tuple[str, str]
347
+
348
+ def to_dict(self) -> dict:
349
+ return {
350
+ "value": [pt.to_dict() for pt in self.value],
351
+ "iou": self.iou,
352
+ "label": {
353
+ "key": self.label[0],
354
+ "value": self.label[1],
355
+ },
356
+ "type": "DetailedPrecisionRecallCurve",
357
+ }
valor_lite/schemas.py ADDED
@@ -0,0 +1,15 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass
5
+ class Metric:
6
+ type: str
7
+ value: float | dict | list
8
+ parameters: dict
9
+
10
+ def to_dict(self) -> dict:
11
+ return {
12
+ "type": self.type,
13
+ "value": self.value,
14
+ "parameters": self.parameters,
15
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Striveworks
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,40 @@
1
+ Metadata-Version: 2.1
2
+ Name: valor-lite
3
+ Version: 0.32.2a2
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: importlib-metadata ; python_version < "3.8"
36
+ Provides-Extra: test
37
+ Requires-Dist: pytest ; extra == 'test'
38
+ Requires-Dist: coverage ; extra == 'test'
39
+
40
+ # valor-lite: Compute classification, object detection, and segmentation metrics locally.
@@ -0,0 +1,12 @@
1
+ valor_lite/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ valor_lite/schemas.py,sha256=r4cC10w1xYsA785KmGE4ePeOX3wzEs846vT7QAiVg_I,293
3
+ valor_lite/detection/__init__.py,sha256=vkV907Sjx09tgOHpDaLyR_-aFGfu2c1Kpb7hg220vBY,1099
4
+ valor_lite/detection/annotation.py,sha256=ON9iVa33pxysUmZVTCb0wNz-eFX6MDOqDhGDz-ouymc,1466
5
+ valor_lite/detection/computation.py,sha256=VIYZUeBd3KpwCPDBQCKCa0cY0hVb4mq_yGtY2ZP9gGE,16512
6
+ valor_lite/detection/manager.py,sha256=i-C72aQfuakeYFWsERQX-KoOGdGsDMrKMVQsqN82TnY,31527
7
+ valor_lite/detection/metric.py,sha256=wn9JAZMNbUIXUvH2C79jNKJswca1QEyXrCfs7isi1hU,8144
8
+ valor_lite-0.32.2a2.dist-info/LICENSE,sha256=M0L53VuwfEEqezhHb7NPeYcO_glw7-k4DMLZQ3eRN64,1068
9
+ valor_lite-0.32.2a2.dist-info/METADATA,sha256=1Q-jyOmW3wUs4NUYCbvqEt0suQfYRbTSrx5TkkWzbHA,1844
10
+ valor_lite-0.32.2a2.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
11
+ valor_lite-0.32.2a2.dist-info/top_level.txt,sha256=9ujykxSwpl2Hu0_R95UQTR_l07k9UUTSdrpiqmq6zc4,11
12
+ valor_lite-0.32.2a2.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.1.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ valor_lite