valor-lite 0.37.1__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.
- valor_lite/LICENSE +21 -0
- valor_lite/__init__.py +0 -0
- valor_lite/cache/__init__.py +11 -0
- valor_lite/cache/compute.py +154 -0
- valor_lite/cache/ephemeral.py +302 -0
- valor_lite/cache/persistent.py +529 -0
- valor_lite/classification/__init__.py +14 -0
- valor_lite/classification/annotation.py +45 -0
- valor_lite/classification/computation.py +378 -0
- valor_lite/classification/evaluator.py +879 -0
- valor_lite/classification/loader.py +97 -0
- valor_lite/classification/metric.py +535 -0
- valor_lite/classification/numpy_compatibility.py +13 -0
- valor_lite/classification/shared.py +184 -0
- valor_lite/classification/utilities.py +314 -0
- valor_lite/exceptions.py +20 -0
- valor_lite/object_detection/__init__.py +17 -0
- valor_lite/object_detection/annotation.py +238 -0
- valor_lite/object_detection/computation.py +841 -0
- valor_lite/object_detection/evaluator.py +805 -0
- valor_lite/object_detection/loader.py +292 -0
- valor_lite/object_detection/metric.py +850 -0
- valor_lite/object_detection/shared.py +185 -0
- valor_lite/object_detection/utilities.py +396 -0
- valor_lite/schemas.py +11 -0
- valor_lite/semantic_segmentation/__init__.py +15 -0
- valor_lite/semantic_segmentation/annotation.py +123 -0
- valor_lite/semantic_segmentation/computation.py +165 -0
- valor_lite/semantic_segmentation/evaluator.py +414 -0
- valor_lite/semantic_segmentation/loader.py +205 -0
- valor_lite/semantic_segmentation/metric.py +275 -0
- valor_lite/semantic_segmentation/shared.py +149 -0
- valor_lite/semantic_segmentation/utilities.py +88 -0
- valor_lite/text_generation/__init__.py +15 -0
- valor_lite/text_generation/annotation.py +56 -0
- valor_lite/text_generation/computation.py +611 -0
- valor_lite/text_generation/llm/__init__.py +0 -0
- valor_lite/text_generation/llm/exceptions.py +14 -0
- valor_lite/text_generation/llm/generation.py +903 -0
- valor_lite/text_generation/llm/instructions.py +814 -0
- valor_lite/text_generation/llm/integrations.py +226 -0
- valor_lite/text_generation/llm/utilities.py +43 -0
- valor_lite/text_generation/llm/validators.py +68 -0
- valor_lite/text_generation/manager.py +697 -0
- valor_lite/text_generation/metric.py +381 -0
- valor_lite-0.37.1.dist-info/METADATA +174 -0
- valor_lite-0.37.1.dist-info/RECORD +49 -0
- valor_lite-0.37.1.dist-info/WHEEL +5 -0
- valor_lite-0.37.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from enum import Enum
|
|
3
|
+
|
|
4
|
+
from valor_lite.schemas import BaseMetric
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class MetricType(str, Enum):
|
|
8
|
+
AnswerCorrectness = "AnswerCorrectness"
|
|
9
|
+
AnswerRelevance = "AnswerRelevance"
|
|
10
|
+
Bias = "Bias"
|
|
11
|
+
BLEU = "BLEU"
|
|
12
|
+
ContextPrecision = "ContextPrecision"
|
|
13
|
+
ContextRecall = "ContextRecall"
|
|
14
|
+
ContextRelevance = "ContextRelevance"
|
|
15
|
+
Faithfulness = "Faithfulness"
|
|
16
|
+
Hallucination = "Hallucination"
|
|
17
|
+
ROUGE = "ROUGE"
|
|
18
|
+
SummaryCoherence = "SummaryCoherence"
|
|
19
|
+
Toxicity = "Toxicity"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclass
|
|
23
|
+
class Metric(BaseMetric):
|
|
24
|
+
"""
|
|
25
|
+
Text Generation Metric.
|
|
26
|
+
|
|
27
|
+
Attributes
|
|
28
|
+
----------
|
|
29
|
+
type : str
|
|
30
|
+
The metric type.
|
|
31
|
+
value : int | float | dict
|
|
32
|
+
The metric value.
|
|
33
|
+
parameters : dict[str, Any]
|
|
34
|
+
A dictionary containing metric parameters.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
def __post_init__(self):
|
|
38
|
+
if not isinstance(self.type, str):
|
|
39
|
+
raise TypeError(
|
|
40
|
+
f"Metric type should be of type 'str': {self.type}"
|
|
41
|
+
)
|
|
42
|
+
elif not isinstance(self.value, (int, float, dict)):
|
|
43
|
+
raise TypeError(
|
|
44
|
+
f"Metric value must be of type 'int', 'float' or 'dict': {self.value}"
|
|
45
|
+
)
|
|
46
|
+
elif not isinstance(self.parameters, dict):
|
|
47
|
+
raise TypeError(
|
|
48
|
+
f"Metric parameters must be of type 'dict[str, Any]': {self.parameters}"
|
|
49
|
+
)
|
|
50
|
+
elif not all([isinstance(k, str) for k in self.parameters.keys()]):
|
|
51
|
+
raise TypeError(
|
|
52
|
+
f"Metric parameter dictionary should only have keys with type 'str': {self.parameters}"
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
@classmethod
|
|
56
|
+
def error(
|
|
57
|
+
cls,
|
|
58
|
+
error_type: str,
|
|
59
|
+
error_message: str,
|
|
60
|
+
model_name: str,
|
|
61
|
+
retries: int,
|
|
62
|
+
):
|
|
63
|
+
return cls(
|
|
64
|
+
type="Error",
|
|
65
|
+
value={
|
|
66
|
+
"type": error_type,
|
|
67
|
+
"message": error_message,
|
|
68
|
+
},
|
|
69
|
+
parameters={
|
|
70
|
+
"evaluator": model_name,
|
|
71
|
+
"retries": retries,
|
|
72
|
+
},
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
@classmethod
|
|
76
|
+
def answer_correctness(
|
|
77
|
+
cls,
|
|
78
|
+
value: float,
|
|
79
|
+
model_name: str,
|
|
80
|
+
retries: int,
|
|
81
|
+
):
|
|
82
|
+
"""
|
|
83
|
+
Defines an answer correctness metric.
|
|
84
|
+
|
|
85
|
+
Parameters
|
|
86
|
+
----------
|
|
87
|
+
value : float
|
|
88
|
+
The answer correctness score between 0 and 1, with higher values indicating that the answer
|
|
89
|
+
is more correct. A score of 1 indicates that all statements in the prediction are supported
|
|
90
|
+
by the ground truth and all statements in the ground truth are present in the prediction.
|
|
91
|
+
"""
|
|
92
|
+
return cls(
|
|
93
|
+
type=MetricType.AnswerCorrectness,
|
|
94
|
+
value=value,
|
|
95
|
+
parameters={
|
|
96
|
+
"evaluator": model_name,
|
|
97
|
+
"retries": retries,
|
|
98
|
+
},
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
@classmethod
|
|
102
|
+
def answer_relevance(
|
|
103
|
+
cls,
|
|
104
|
+
value: float,
|
|
105
|
+
model_name: str,
|
|
106
|
+
retries: int,
|
|
107
|
+
):
|
|
108
|
+
"""
|
|
109
|
+
Defines an answer relevance metric.
|
|
110
|
+
|
|
111
|
+
Parameters
|
|
112
|
+
----------
|
|
113
|
+
value : float
|
|
114
|
+
The number of statements in the answer that are relevant to the query divided by the total
|
|
115
|
+
number of statements in the answer.
|
|
116
|
+
"""
|
|
117
|
+
return cls(
|
|
118
|
+
type=MetricType.AnswerRelevance,
|
|
119
|
+
value=value,
|
|
120
|
+
parameters={
|
|
121
|
+
"evaluator": model_name,
|
|
122
|
+
"retries": retries,
|
|
123
|
+
},
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
@classmethod
|
|
127
|
+
def bleu(
|
|
128
|
+
cls,
|
|
129
|
+
value: float,
|
|
130
|
+
weights: list[float],
|
|
131
|
+
):
|
|
132
|
+
"""
|
|
133
|
+
Defines a BLEU metric.
|
|
134
|
+
|
|
135
|
+
Parameters
|
|
136
|
+
----------
|
|
137
|
+
value : float
|
|
138
|
+
The BLEU score for an individual datapoint.
|
|
139
|
+
weights : list[float]
|
|
140
|
+
The list of weights that the score was calculated with.
|
|
141
|
+
"""
|
|
142
|
+
return cls(
|
|
143
|
+
type=MetricType.BLEU,
|
|
144
|
+
value=value,
|
|
145
|
+
parameters={
|
|
146
|
+
"weights": weights,
|
|
147
|
+
},
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
@classmethod
|
|
151
|
+
def bias(
|
|
152
|
+
cls,
|
|
153
|
+
value: float,
|
|
154
|
+
model_name: str,
|
|
155
|
+
retries: int,
|
|
156
|
+
):
|
|
157
|
+
"""
|
|
158
|
+
Defines a bias metric.
|
|
159
|
+
|
|
160
|
+
Parameters
|
|
161
|
+
----------
|
|
162
|
+
value : float
|
|
163
|
+
The bias score for a datum. This is a float between 0 and 1, with 1 indicating that all
|
|
164
|
+
opinions in the datum text are biased and 0 indicating that there is no bias.
|
|
165
|
+
"""
|
|
166
|
+
return cls(
|
|
167
|
+
type=MetricType.Bias,
|
|
168
|
+
value=value,
|
|
169
|
+
parameters={
|
|
170
|
+
"evaluator": model_name,
|
|
171
|
+
"retries": retries,
|
|
172
|
+
},
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
@classmethod
|
|
176
|
+
def context_precision(
|
|
177
|
+
cls,
|
|
178
|
+
value: float,
|
|
179
|
+
model_name: str,
|
|
180
|
+
retries: int,
|
|
181
|
+
):
|
|
182
|
+
"""
|
|
183
|
+
Defines a context precision metric.
|
|
184
|
+
|
|
185
|
+
Parameters
|
|
186
|
+
----------
|
|
187
|
+
value : float
|
|
188
|
+
The context precision score for a datum. This is a float between 0 and 1, with 0 indicating
|
|
189
|
+
that none of the contexts are useful to arrive at the ground truth answer to the query
|
|
190
|
+
and 1 indicating that all contexts are useful to arrive at the ground truth answer to the
|
|
191
|
+
query. The score is more heavily influenced by earlier contexts in the list of contexts
|
|
192
|
+
than later contexts.
|
|
193
|
+
"""
|
|
194
|
+
return cls(
|
|
195
|
+
type=MetricType.ContextPrecision,
|
|
196
|
+
value=value,
|
|
197
|
+
parameters={
|
|
198
|
+
"evaluator": model_name,
|
|
199
|
+
"retries": retries,
|
|
200
|
+
},
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
@classmethod
|
|
204
|
+
def context_recall(
|
|
205
|
+
cls,
|
|
206
|
+
value: float,
|
|
207
|
+
model_name: str,
|
|
208
|
+
retries: int,
|
|
209
|
+
):
|
|
210
|
+
"""
|
|
211
|
+
Defines a context recall metric.
|
|
212
|
+
|
|
213
|
+
Parameters
|
|
214
|
+
----------
|
|
215
|
+
value : float
|
|
216
|
+
The context recall score for a datum. This is a float between 0 and 1, with 1 indicating
|
|
217
|
+
that all ground truth statements are attributable to the context list.
|
|
218
|
+
"""
|
|
219
|
+
return cls(
|
|
220
|
+
type=MetricType.ContextRecall,
|
|
221
|
+
value=value,
|
|
222
|
+
parameters={
|
|
223
|
+
"evaluator": model_name,
|
|
224
|
+
"retries": retries,
|
|
225
|
+
},
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
@classmethod
|
|
229
|
+
def context_relevance(
|
|
230
|
+
cls,
|
|
231
|
+
value: float,
|
|
232
|
+
model_name: str,
|
|
233
|
+
retries: int,
|
|
234
|
+
):
|
|
235
|
+
"""
|
|
236
|
+
Defines a context relevance metric.
|
|
237
|
+
|
|
238
|
+
Parameters
|
|
239
|
+
----------
|
|
240
|
+
value : float
|
|
241
|
+
The context relevance score for a datum. This is a float between 0 and 1, with 0 indicating
|
|
242
|
+
that none of the contexts are relevant and 1 indicating that all of the contexts are relevant.
|
|
243
|
+
"""
|
|
244
|
+
return cls(
|
|
245
|
+
type=MetricType.ContextRelevance,
|
|
246
|
+
value=value,
|
|
247
|
+
parameters={
|
|
248
|
+
"evaluator": model_name,
|
|
249
|
+
"retries": retries,
|
|
250
|
+
},
|
|
251
|
+
)
|
|
252
|
+
|
|
253
|
+
@classmethod
|
|
254
|
+
def faithfulness(
|
|
255
|
+
cls,
|
|
256
|
+
value: float,
|
|
257
|
+
model_name: str,
|
|
258
|
+
retries: int,
|
|
259
|
+
):
|
|
260
|
+
"""
|
|
261
|
+
Defines a faithfulness metric.
|
|
262
|
+
|
|
263
|
+
Parameters
|
|
264
|
+
----------
|
|
265
|
+
value : float
|
|
266
|
+
The faithfulness score for a datum. This is a float between 0 and 1, with 1 indicating that
|
|
267
|
+
all claims in the text are implied by the contexts.
|
|
268
|
+
"""
|
|
269
|
+
return cls(
|
|
270
|
+
type=MetricType.Faithfulness,
|
|
271
|
+
value=value,
|
|
272
|
+
parameters={
|
|
273
|
+
"evaluator": model_name,
|
|
274
|
+
"retries": retries,
|
|
275
|
+
},
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
@classmethod
|
|
279
|
+
def hallucination(
|
|
280
|
+
cls,
|
|
281
|
+
value: float,
|
|
282
|
+
model_name: str,
|
|
283
|
+
retries: int,
|
|
284
|
+
):
|
|
285
|
+
"""
|
|
286
|
+
Defines a hallucination metric.
|
|
287
|
+
|
|
288
|
+
Parameters
|
|
289
|
+
----------
|
|
290
|
+
value : float
|
|
291
|
+
The hallucination score for a datum. This is a float between 0 and 1, with 1 indicating that
|
|
292
|
+
all contexts are contradicted by the text.
|
|
293
|
+
"""
|
|
294
|
+
return cls(
|
|
295
|
+
type=MetricType.Hallucination,
|
|
296
|
+
value=value,
|
|
297
|
+
parameters={
|
|
298
|
+
"evaluator": model_name,
|
|
299
|
+
"retries": retries,
|
|
300
|
+
},
|
|
301
|
+
)
|
|
302
|
+
|
|
303
|
+
@classmethod
|
|
304
|
+
def rouge(
|
|
305
|
+
cls,
|
|
306
|
+
value: float,
|
|
307
|
+
rouge_type: str,
|
|
308
|
+
use_stemmer: bool,
|
|
309
|
+
):
|
|
310
|
+
"""
|
|
311
|
+
Defines a ROUGE metric.
|
|
312
|
+
|
|
313
|
+
Parameters
|
|
314
|
+
----------
|
|
315
|
+
value : float
|
|
316
|
+
A ROUGE score.
|
|
317
|
+
rouge_type : ROUGEType
|
|
318
|
+
The ROUGE variation used to compute the value. `rouge1` is unigram-based scoring, `rouge2` is bigram-based
|
|
319
|
+
scoring, `rougeL` is scoring based on sentences (i.e., splitting on "." and ignoring "\n"), and `rougeLsum`
|
|
320
|
+
is scoring based on splitting the text using "\n".
|
|
321
|
+
use_stemmer: bool, default=False
|
|
322
|
+
If True, uses Porter stemmer to strip word suffixes. Defaults to False.
|
|
323
|
+
"""
|
|
324
|
+
return cls(
|
|
325
|
+
type=MetricType.ROUGE,
|
|
326
|
+
value=value,
|
|
327
|
+
parameters={
|
|
328
|
+
"rouge_type": rouge_type,
|
|
329
|
+
"use_stemmer": use_stemmer,
|
|
330
|
+
},
|
|
331
|
+
)
|
|
332
|
+
|
|
333
|
+
@classmethod
|
|
334
|
+
def summary_coherence(
|
|
335
|
+
cls,
|
|
336
|
+
value: int,
|
|
337
|
+
model_name: str,
|
|
338
|
+
retries: int,
|
|
339
|
+
):
|
|
340
|
+
"""
|
|
341
|
+
Defines a summary coherence metric.
|
|
342
|
+
|
|
343
|
+
Parameters
|
|
344
|
+
----------
|
|
345
|
+
value : int
|
|
346
|
+
The summary coherence score for a datum. This is an integer with 1 being the lowest summary coherence
|
|
347
|
+
and 5 the highest summary coherence.
|
|
348
|
+
"""
|
|
349
|
+
return cls(
|
|
350
|
+
type=MetricType.SummaryCoherence,
|
|
351
|
+
value=value,
|
|
352
|
+
parameters={
|
|
353
|
+
"evaluator": model_name,
|
|
354
|
+
"retries": retries,
|
|
355
|
+
},
|
|
356
|
+
)
|
|
357
|
+
|
|
358
|
+
@classmethod
|
|
359
|
+
def toxicity(
|
|
360
|
+
cls,
|
|
361
|
+
value: float,
|
|
362
|
+
model_name: str,
|
|
363
|
+
retries: int,
|
|
364
|
+
):
|
|
365
|
+
"""
|
|
366
|
+
Defines a toxicity metric.
|
|
367
|
+
|
|
368
|
+
Parameters
|
|
369
|
+
----------
|
|
370
|
+
value : float
|
|
371
|
+
The toxicity score for a datum. This is a value between 0 and 1, with 1 indicating that all opinions
|
|
372
|
+
in the datum text are toxic and 0 indicating that there is no toxicity.
|
|
373
|
+
"""
|
|
374
|
+
return cls(
|
|
375
|
+
type=MetricType.Toxicity,
|
|
376
|
+
value=value,
|
|
377
|
+
parameters={
|
|
378
|
+
"evaluator": model_name,
|
|
379
|
+
"retries": retries,
|
|
380
|
+
},
|
|
381
|
+
)
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: valor-lite
|
|
3
|
+
Version: 0.37.1
|
|
4
|
+
Summary: Evaluate machine learning models.
|
|
5
|
+
Project-URL: homepage, https://www.striveworks.com
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: numpy
|
|
9
|
+
Requires-Dist: tqdm
|
|
10
|
+
Requires-Dist: shapely
|
|
11
|
+
Requires-Dist: pyarrow
|
|
12
|
+
Provides-Extra: nlp
|
|
13
|
+
Requires-Dist: evaluate; extra == "nlp"
|
|
14
|
+
Requires-Dist: nltk; extra == "nlp"
|
|
15
|
+
Requires-Dist: rouge_score; extra == "nlp"
|
|
16
|
+
Provides-Extra: mistral
|
|
17
|
+
Requires-Dist: mistralai<1.8.0,>=1.0.0; extra == "mistral"
|
|
18
|
+
Provides-Extra: openai
|
|
19
|
+
Requires-Dist: openai; extra == "openai"
|
|
20
|
+
Provides-Extra: docs
|
|
21
|
+
Requires-Dist: mkdocs; extra == "docs"
|
|
22
|
+
Requires-Dist: mkdocs-material; extra == "docs"
|
|
23
|
+
Requires-Dist: mkdocstrings; extra == "docs"
|
|
24
|
+
Requires-Dist: mkdocstrings-python; extra == "docs"
|
|
25
|
+
Requires-Dist: mkdocs-include-dir-to-nav; extra == "docs"
|
|
26
|
+
Requires-Dist: mkdocs-swagger-ui-tag; extra == "docs"
|
|
27
|
+
Provides-Extra: test
|
|
28
|
+
Requires-Dist: pytest; extra == "test"
|
|
29
|
+
Requires-Dist: coverage; extra == "test"
|
|
30
|
+
Requires-Dist: pre-commit; extra == "test"
|
|
31
|
+
Provides-Extra: benchmark
|
|
32
|
+
Requires-Dist: requests; extra == "benchmark"
|
|
33
|
+
Provides-Extra: dev
|
|
34
|
+
Requires-Dist: valor-lite[benchmark,docs,mistral,nlp,openai,test]; extra == "dev"
|
|
35
|
+
|
|
36
|
+
# valor-lite: Fast, local machine learning evaluation.
|
|
37
|
+
|
|
38
|
+
valor-lite is a lightweight, numpy-based library designed for fast and seamless evaluation of machine learning models. It is optimized for environments where quick, responsive evaluations are essential, whether as part of a larger service or embedded within user-facing tools.
|
|
39
|
+
|
|
40
|
+
valor-lite is maintained by Striveworks, a cutting-edge MLOps company based in Austin, Texas. If you'd like to learn more or have questions, we invite you to connect with us on [Slack](https://striveworks-public.slack.com/join/shared_invite/zt-1a0jx768y-2J1fffN~b4fXYM8GecvOhA#/shared-invite/email) or explore our [GitHub repository](https://github.com/striveworks/valor).
|
|
41
|
+
|
|
42
|
+
For additional details, be sure to check out our user [documentation](https://striveworks.github.io/valor/). We're excited to support you in making the most of Valor!
|
|
43
|
+
|
|
44
|
+
## Usage
|
|
45
|
+
|
|
46
|
+
### Classification
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from valor_lite.classification import DataLoader, Classification, MetricType
|
|
50
|
+
|
|
51
|
+
classifications = [
|
|
52
|
+
Classification(
|
|
53
|
+
uid="uid0",
|
|
54
|
+
groundtruth="dog",
|
|
55
|
+
predictions=["dog", "cat", "bird"],
|
|
56
|
+
scores=[0.75, 0.2, 0.05],
|
|
57
|
+
),
|
|
58
|
+
Classification(
|
|
59
|
+
uid="uid1",
|
|
60
|
+
groundtruth="cat",
|
|
61
|
+
predictions=["dog", "cat", "bird"],
|
|
62
|
+
scores=[0.41, 0.39, 0.1],
|
|
63
|
+
),
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
loader = DataLoader()
|
|
67
|
+
loader.add_data(classifications)
|
|
68
|
+
evaluator = loader.finalize()
|
|
69
|
+
|
|
70
|
+
metrics = evaluator.evaluate()
|
|
71
|
+
|
|
72
|
+
assert metrics[MetricType.Precision][0].to_dict() == {
|
|
73
|
+
'type': 'Precision',
|
|
74
|
+
'value': [0.5],
|
|
75
|
+
'parameters': {
|
|
76
|
+
'score_thresholds': [0.0],
|
|
77
|
+
'hardmax': True,
|
|
78
|
+
'label': 'dog'
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Object Detection
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
from valor_lite.object_detection import DataLoader, Detection, BoundingBox, MetricType
|
|
87
|
+
|
|
88
|
+
detections = [
|
|
89
|
+
Detection(
|
|
90
|
+
uid="uid0",
|
|
91
|
+
groundtruths=[
|
|
92
|
+
BoundingBox(
|
|
93
|
+
xmin=0, xmax=10,
|
|
94
|
+
ymin=0, ymax=10,
|
|
95
|
+
labels=["dog"]
|
|
96
|
+
),
|
|
97
|
+
BoundingBox(
|
|
98
|
+
xmin=20, xmax=30,
|
|
99
|
+
ymin=20, ymax=30,
|
|
100
|
+
labels=["cat"]
|
|
101
|
+
),
|
|
102
|
+
],
|
|
103
|
+
predictions=[
|
|
104
|
+
BoundingBox(
|
|
105
|
+
xmin=1, xmax=11,
|
|
106
|
+
ymin=1, ymax=11,
|
|
107
|
+
labels=["dog", "cat", "bird"],
|
|
108
|
+
scores=[0.85, 0.1, 0.05]
|
|
109
|
+
),
|
|
110
|
+
BoundingBox(
|
|
111
|
+
xmin=21, xmax=31,
|
|
112
|
+
ymin=21, ymax=31,
|
|
113
|
+
labels=["dog", "cat", "bird"],
|
|
114
|
+
scores=[0.34, 0.33, 0.33]
|
|
115
|
+
),
|
|
116
|
+
],
|
|
117
|
+
),
|
|
118
|
+
]
|
|
119
|
+
|
|
120
|
+
loader = DataLoader()
|
|
121
|
+
loader.add_bounding_boxes(detections)
|
|
122
|
+
evaluator = loader.finalize()
|
|
123
|
+
|
|
124
|
+
metrics = evaluator.evaluate()
|
|
125
|
+
|
|
126
|
+
assert metrics[MetricType.Precision][0].to_dict() == {
|
|
127
|
+
'type': 'Precision',
|
|
128
|
+
'value': 0.5,
|
|
129
|
+
'parameters': {
|
|
130
|
+
'iou_threshold': 0.5,
|
|
131
|
+
'score_threshold': 0.5,
|
|
132
|
+
'label': 'dog'
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Semantic Segmentation
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
import numpy as np
|
|
141
|
+
from valor_lite.semantic_segmentation import DataLoader, Segmentation, Bitmask, MetricType
|
|
142
|
+
|
|
143
|
+
segmentations = [
|
|
144
|
+
Segmentation(
|
|
145
|
+
uid="uid0",
|
|
146
|
+
groundtruths=[
|
|
147
|
+
Bitmask(
|
|
148
|
+
mask=np.random.randint(2, size=(10,10), dtype=np.bool_),
|
|
149
|
+
label="sky",
|
|
150
|
+
),
|
|
151
|
+
Bitmask(
|
|
152
|
+
mask=np.random.randint(2, size=(10,10), dtype=np.bool_),
|
|
153
|
+
label="ground",
|
|
154
|
+
)
|
|
155
|
+
],
|
|
156
|
+
predictions=[
|
|
157
|
+
Bitmask(
|
|
158
|
+
mask=np.random.randint(2, size=(10,10), dtype=np.bool_),
|
|
159
|
+
label="sky",
|
|
160
|
+
),
|
|
161
|
+
Bitmask(
|
|
162
|
+
mask=np.random.randint(2, size=(10,10), dtype=np.bool_),
|
|
163
|
+
label="ground",
|
|
164
|
+
)
|
|
165
|
+
]
|
|
166
|
+
),
|
|
167
|
+
]
|
|
168
|
+
|
|
169
|
+
loader = DataLoader()
|
|
170
|
+
loader.add_data(segmentations)
|
|
171
|
+
evaluator = loader.finalize()
|
|
172
|
+
|
|
173
|
+
print(metrics[MetricType.Precision][0])
|
|
174
|
+
```
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
valor_lite/LICENSE,sha256=M0L53VuwfEEqezhHb7NPeYcO_glw7-k4DMLZQ3eRN64,1068
|
|
2
|
+
valor_lite/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
valor_lite/exceptions.py,sha256=Odg4m7VfTYtGunzA-JpNWGoDwvXFvCamkQu8WLncE-A,496
|
|
4
|
+
valor_lite/schemas.py,sha256=pB0MrPx5qFLbwBWDiOUUm-vmXdWvbJLFCBmKgbcbI5g,198
|
|
5
|
+
valor_lite/cache/__init__.py,sha256=OzVJq6WMXOmhJPQLOVu9y0xEui41PDpwGnkrU6A3-dA,266
|
|
6
|
+
valor_lite/cache/compute.py,sha256=WR1qPMx7MtdhQSrYbAI9LIHkaEDuzX3na2Cv_aO0W1A,5183
|
|
7
|
+
valor_lite/cache/ephemeral.py,sha256=4TT7ruk8GG0DxIjAFcNEBkpJ5sIdky2eLTS7NwAO758,8149
|
|
8
|
+
valor_lite/cache/persistent.py,sha256=OMXrhfYuleTsCaG1e5aue9Juxaz6kDFVinlCqOX5lPA,15023
|
|
9
|
+
valor_lite/classification/__init__.py,sha256=5cAK1exDJGGhZWFcswj977-qVtEafUTsNIg7stJV2oc,293
|
|
10
|
+
valor_lite/classification/annotation.py,sha256=93NzpfpBhkyLq33gLtAqkCl0TTmraDGy03cSjAxMWec,1304
|
|
11
|
+
valor_lite/classification/computation.py,sha256=x2IINIDHP_52GTCdkTgu8ujx3o3HGosdWE0_oQvNZuU,11498
|
|
12
|
+
valor_lite/classification/evaluator.py,sha256=eoT4_FfR76dUlL-AXqjx7boHA9oCfSAmHwSOIhkW_ug,28855
|
|
13
|
+
valor_lite/classification/loader.py,sha256=t976u0XGBuQGrG6VgxPViu-Ipbj5sUm_ShW8FV0YGxg,3355
|
|
14
|
+
valor_lite/classification/metric.py,sha256=4ZoP9f36DqKnDOif40kjwznJc0fw93F1yx3gvX_lnz8,16104
|
|
15
|
+
valor_lite/classification/numpy_compatibility.py,sha256=roqtTetsm1_HxuaejrthQdydjsRIy-FpXpGb86cLh_E,365
|
|
16
|
+
valor_lite/classification/shared.py,sha256=J3lrcJQrSSEXc1qv7s9CIU3UF_XEZxd6flki1I0nhfA,5653
|
|
17
|
+
valor_lite/classification/utilities.py,sha256=NZP830x0noKSZCC6-Hc_K34JzxLsHgU8Zcq0YjTlH90,10218
|
|
18
|
+
valor_lite/object_detection/__init__.py,sha256=GARztCi3rYlq3gltJ0lDBQK0bVYr5Upwc_M3_Cl_RMg,363
|
|
19
|
+
valor_lite/object_detection/annotation.py,sha256=--uvHOS7vPIz3cqArp8dZM4Ax9_lzW0HCaz626ZULDM,7684
|
|
20
|
+
valor_lite/object_detection/computation.py,sha256=EREV5OokVez70eGNbbuzrJo-PXANKh0XrUqpF8PKHPU,25505
|
|
21
|
+
valor_lite/object_detection/evaluator.py,sha256=2ytNGsizQfnK9ehHE7R1QNxYSzPIRQV4fmmvtMP3FMM,27780
|
|
22
|
+
valor_lite/object_detection/loader.py,sha256=kPGG8UXCBDZl10qfDv3YqailgdHk3O4DyZQ8pqkVhJc,11428
|
|
23
|
+
valor_lite/object_detection/metric.py,sha256=-bcupJvS_BSWNPN2trkO8EWD-z7TDFGGim7fIHpzPzw,27924
|
|
24
|
+
valor_lite/object_detection/shared.py,sha256=y9sNZIKtLLVVGec8aPKH_nuVf-pXXt05BhTJG-WP0yY,5672
|
|
25
|
+
valor_lite/object_detection/utilities.py,sha256=zoez6MaBx0IwxJf-zDQMkCh80lQf0zB4Fl1xluFTtnY,14526
|
|
26
|
+
valor_lite/semantic_segmentation/__init__.py,sha256=OeAKuANM2mvw3JX4pi-eudc82YMqsXJwK1DIjgl2oeI,318
|
|
27
|
+
valor_lite/semantic_segmentation/annotation.py,sha256=XB54BcBu_soQvbP3DrbXCruw-sypJBC6KhLqRWX1Vmw,4384
|
|
28
|
+
valor_lite/semantic_segmentation/computation.py,sha256=dhbwybDe5kQGXzUSOjm15UGjDoGGt5zPtvPyvp8kFc4,4690
|
|
29
|
+
valor_lite/semantic_segmentation/evaluator.py,sha256=jXFBPv_pmIOj85wJFFikbNNWDq8wPG2rcLiaWrgDcUs,13569
|
|
30
|
+
valor_lite/semantic_segmentation/loader.py,sha256=rDtbeGhQEDhGjcjx9RHiSATQM25uftF13c1pm09axUM,7582
|
|
31
|
+
valor_lite/semantic_segmentation/metric.py,sha256=T9RfPJf4WgqGQTXYvSy08vJG5bjXXJnyYZeW0mlxMa8,7132
|
|
32
|
+
valor_lite/semantic_segmentation/shared.py,sha256=i9F7nAoH9Yhabqj-SVtnQfm2ST0xkVFUcQVBVLabPeE,4539
|
|
33
|
+
valor_lite/semantic_segmentation/utilities.py,sha256=MjqSlS1wy0RwJGiuUpZrT3AUMXEahO7-lh2oeNeqGV8,2470
|
|
34
|
+
valor_lite/text_generation/__init__.py,sha256=pGhpWCSZjLM0pPHCtPykAfos55B8ie3mi9EzbNxfj-U,356
|
|
35
|
+
valor_lite/text_generation/annotation.py,sha256=O5aXiwCS4WjA-fqn4ly-O0MsTHoIOmqxqCaAp9IeI3M,1270
|
|
36
|
+
valor_lite/text_generation/computation.py,sha256=hGDkPfzWY9SDTdozd-nArexJ3ZSNlCIWqHGoD8vO2Cc,18652
|
|
37
|
+
valor_lite/text_generation/manager.py,sha256=C4QwvronGHXmYSkaRmUGy7TN0C0aeyDx9Hb-ClNYXK4,24810
|
|
38
|
+
valor_lite/text_generation/metric.py,sha256=C9gbWejjOJ23JVLecuUhYW5rkx30NUCfRtgsM46uMds,10409
|
|
39
|
+
valor_lite/text_generation/llm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
40
|
+
valor_lite/text_generation/llm/exceptions.py,sha256=w4eYSJIJQ_jWuCmquCB6ETr_st_LzbDRlhnlPeqwmfo,349
|
|
41
|
+
valor_lite/text_generation/llm/generation.py,sha256=XKPjCxPUZHiWInQSO7wLOb0YtMFLu50s8rHZe1Yz0s0,28954
|
|
42
|
+
valor_lite/text_generation/llm/instructions.py,sha256=fz2onBZZWcl5W8iy7zEWkPGU9N07ez6O7SxZA5M2xe4,34056
|
|
43
|
+
valor_lite/text_generation/llm/integrations.py,sha256=-rTfdAjq1zH-4ixwYuMQEOQ80pIFzMTe0BYfroVx3Pg,6974
|
|
44
|
+
valor_lite/text_generation/llm/utilities.py,sha256=bjqatGgtVTcl1PrMwiDKTYPGJXKrBrx7PDtzIblGSys,1178
|
|
45
|
+
valor_lite/text_generation/llm/validators.py,sha256=Wzr5RlfF58_2wOU-uTw7C8skan_fYdhy4Gfn0jSJ8HM,2700
|
|
46
|
+
valor_lite-0.37.1.dist-info/METADATA,sha256=y8qWyMI-Q0GKjbxePQJSuB9sCP4vsVlnECghZb-8YfI,5094
|
|
47
|
+
valor_lite-0.37.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
48
|
+
valor_lite-0.37.1.dist-info/top_level.txt,sha256=9ujykxSwpl2Hu0_R95UQTR_l07k9UUTSdrpiqmq6zc4,11
|
|
49
|
+
valor_lite-0.37.1.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
valor_lite
|