valor-lite 0.33.7__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.
- valor_lite/LICENSE +21 -0
- valor_lite/classification/annotation.py +30 -2
- valor_lite/classification/computation.py +31 -52
- valor_lite/classification/manager.py +230 -323
- valor_lite/classification/metric.py +273 -50
- valor_lite/object_detection/annotation.py +274 -0
- valor_lite/{detection → object_detection}/computation.py +130 -92
- valor_lite/{detection → object_detection}/manager.py +425 -769
- valor_lite/object_detection/metric.py +789 -0
- valor_lite/semantic_segmentation/__init__.py +27 -0
- valor_lite/semantic_segmentation/annotation.py +96 -0
- valor_lite/semantic_segmentation/computation.py +186 -0
- valor_lite/semantic_segmentation/manager.py +549 -0
- valor_lite/semantic_segmentation/metric.py +278 -0
- valor_lite/text_generation/__init__.py +0 -0
- valor_lite-0.33.9.dist-info/METADATA +179 -0
- valor_lite-0.33.9.dist-info/RECORD +24 -0
- valor_lite/detection/annotation.py +0 -98
- valor_lite/detection/metric.py +0 -408
- valor_lite-0.33.7.dist-info/METADATA +0 -41
- valor_lite-0.33.7.dist-info/RECORD +0 -17
- /valor_lite/{detection → object_detection}/__init__.py +0 -0
- {valor_lite-0.33.7.dist-info → valor_lite-0.33.9.dist-info}/LICENSE +0 -0
- {valor_lite-0.33.7.dist-info → valor_lite-0.33.9.dist-info}/WHEEL +0 -0
- {valor_lite-0.33.7.dist-info → valor_lite-0.33.9.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,278 @@
|
|
|
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
|
+
def to_metric(self) -> Metric:
|
|
35
|
+
return Metric(
|
|
36
|
+
type=type(self).__name__,
|
|
37
|
+
value=self.value,
|
|
38
|
+
parameters={
|
|
39
|
+
"label": self.label,
|
|
40
|
+
},
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
def to_dict(self) -> dict:
|
|
44
|
+
return self.to_metric().to_dict()
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class Precision(_LabelValue):
|
|
48
|
+
"""
|
|
49
|
+
Precision metric for a specific class label.
|
|
50
|
+
|
|
51
|
+
Precision is calulated using the number of true-positive pixels divided by
|
|
52
|
+
the sum of all true-positive and false-positive pixels.
|
|
53
|
+
|
|
54
|
+
Attributes
|
|
55
|
+
----------
|
|
56
|
+
value : float
|
|
57
|
+
The computed precision value.
|
|
58
|
+
label : str
|
|
59
|
+
The label for which the precision is calculated.
|
|
60
|
+
|
|
61
|
+
Methods
|
|
62
|
+
-------
|
|
63
|
+
to_metric()
|
|
64
|
+
Converts the instance to a generic `Metric` object.
|
|
65
|
+
to_dict()
|
|
66
|
+
Converts the instance to a dictionary representation.
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
pass
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class Recall(_LabelValue):
|
|
73
|
+
"""
|
|
74
|
+
Recall metric for a specific class label.
|
|
75
|
+
|
|
76
|
+
Recall is calulated using the number of true-positive pixels divided by
|
|
77
|
+
the sum of all true-positive and false-negative pixels.
|
|
78
|
+
|
|
79
|
+
Attributes
|
|
80
|
+
----------
|
|
81
|
+
value : float
|
|
82
|
+
The computed recall value.
|
|
83
|
+
label : str
|
|
84
|
+
The label for which the recall is calculated.
|
|
85
|
+
|
|
86
|
+
Methods
|
|
87
|
+
-------
|
|
88
|
+
to_metric()
|
|
89
|
+
Converts the instance to a generic `Metric` object.
|
|
90
|
+
to_dict()
|
|
91
|
+
Converts the instance to a dictionary representation.
|
|
92
|
+
"""
|
|
93
|
+
|
|
94
|
+
pass
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
class F1(_LabelValue):
|
|
98
|
+
"""
|
|
99
|
+
F1 score for a specific class label.
|
|
100
|
+
|
|
101
|
+
Attributes
|
|
102
|
+
----------
|
|
103
|
+
value : float
|
|
104
|
+
The computed F1 score.
|
|
105
|
+
label : str
|
|
106
|
+
The label for which the F1 score is calculated.
|
|
107
|
+
|
|
108
|
+
Methods
|
|
109
|
+
-------
|
|
110
|
+
to_metric()
|
|
111
|
+
Converts the instance to a generic `Metric` object.
|
|
112
|
+
to_dict()
|
|
113
|
+
Converts the instance to a dictionary representation.
|
|
114
|
+
"""
|
|
115
|
+
|
|
116
|
+
pass
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
class IoU(_LabelValue):
|
|
120
|
+
"""
|
|
121
|
+
Intersection over Union (IoU) ratio for a specific class label.
|
|
122
|
+
|
|
123
|
+
Attributes
|
|
124
|
+
----------
|
|
125
|
+
value : float
|
|
126
|
+
The computed IoU ratio.
|
|
127
|
+
label : str
|
|
128
|
+
The label for which the IoU is calculated.
|
|
129
|
+
|
|
130
|
+
Methods
|
|
131
|
+
-------
|
|
132
|
+
to_metric()
|
|
133
|
+
Converts the instance to a generic `Metric` object.
|
|
134
|
+
to_dict()
|
|
135
|
+
Converts the instance to a dictionary representation.
|
|
136
|
+
"""
|
|
137
|
+
|
|
138
|
+
pass
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
@dataclass
|
|
142
|
+
class _Value:
|
|
143
|
+
value: float
|
|
144
|
+
|
|
145
|
+
def to_metric(self) -> Metric:
|
|
146
|
+
return Metric(
|
|
147
|
+
type=type(self).__name__,
|
|
148
|
+
value=self.value,
|
|
149
|
+
parameters={},
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
def to_dict(self) -> dict:
|
|
153
|
+
return self.to_metric().to_dict()
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
class Accuracy(_Value):
|
|
157
|
+
"""
|
|
158
|
+
Accuracy metric computed over all labels.
|
|
159
|
+
|
|
160
|
+
Attributes
|
|
161
|
+
----------
|
|
162
|
+
value : float
|
|
163
|
+
The accuracy value.
|
|
164
|
+
|
|
165
|
+
Methods
|
|
166
|
+
-------
|
|
167
|
+
to_metric()
|
|
168
|
+
Converts the instance to a generic `Metric` object.
|
|
169
|
+
to_dict()
|
|
170
|
+
Converts the instance to a dictionary representation.
|
|
171
|
+
"""
|
|
172
|
+
|
|
173
|
+
pass
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
class mIoU(_Value):
|
|
177
|
+
"""
|
|
178
|
+
Mean Intersection over Union (mIoU) ratio.
|
|
179
|
+
|
|
180
|
+
The mIoU value is computed by averaging IoU over all labels.
|
|
181
|
+
|
|
182
|
+
Attributes
|
|
183
|
+
----------
|
|
184
|
+
value : float
|
|
185
|
+
The mIoU value.
|
|
186
|
+
|
|
187
|
+
Methods
|
|
188
|
+
-------
|
|
189
|
+
to_metric()
|
|
190
|
+
Converts the instance to a generic `Metric` object.
|
|
191
|
+
to_dict()
|
|
192
|
+
Converts the instance to a dictionary representation.
|
|
193
|
+
"""
|
|
194
|
+
|
|
195
|
+
pass
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
@dataclass
|
|
199
|
+
class ConfusionMatrix:
|
|
200
|
+
"""
|
|
201
|
+
The confusion matrix and related metrics for semantic segmentation tasks.
|
|
202
|
+
|
|
203
|
+
This class encapsulates detailed information about the model's performance, including correct
|
|
204
|
+
predictions, misclassifications, hallucinations (false positives), and missing predictions
|
|
205
|
+
(false negatives). It provides counts for each category to facilitate in-depth analysis.
|
|
206
|
+
|
|
207
|
+
Confusion Matrix Format:
|
|
208
|
+
{
|
|
209
|
+
<ground truth label>: {
|
|
210
|
+
<prediction label>: {
|
|
211
|
+
'iou': <float>,
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
Hallucinations Format:
|
|
217
|
+
{
|
|
218
|
+
<prediction label>: {
|
|
219
|
+
'iou': <float>,
|
|
220
|
+
},
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
Missing Predictions Format:
|
|
224
|
+
{
|
|
225
|
+
<ground truth label>: {
|
|
226
|
+
'iou': <float>,
|
|
227
|
+
},
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
Attributes
|
|
231
|
+
----------
|
|
232
|
+
confusion_matrix : dict
|
|
233
|
+
Nested dictionaries representing the Intersection over Union (IoU) scores for each
|
|
234
|
+
ground truth label and prediction label pair.
|
|
235
|
+
hallucinations : dict
|
|
236
|
+
Dictionary representing the pixel ratios for predicted labels that do not correspond
|
|
237
|
+
to any ground truth labels (false positives).
|
|
238
|
+
missing_predictions : dict
|
|
239
|
+
Dictionary representing the pixel ratios for ground truth labels that were not predicted
|
|
240
|
+
(false negatives).
|
|
241
|
+
|
|
242
|
+
Methods
|
|
243
|
+
-------
|
|
244
|
+
to_metric()
|
|
245
|
+
Converts the instance to a generic `Metric` object.
|
|
246
|
+
to_dict()
|
|
247
|
+
Converts the instance to a dictionary representation.
|
|
248
|
+
"""
|
|
249
|
+
|
|
250
|
+
confusion_matrix: dict[
|
|
251
|
+
str, # ground truth label value
|
|
252
|
+
dict[
|
|
253
|
+
str, # prediction label value
|
|
254
|
+
dict[str, float], # iou
|
|
255
|
+
],
|
|
256
|
+
]
|
|
257
|
+
hallucinations: dict[
|
|
258
|
+
str, # prediction label value
|
|
259
|
+
dict[str, float], # pixel ratio
|
|
260
|
+
]
|
|
261
|
+
missing_predictions: dict[
|
|
262
|
+
str, # ground truth label value
|
|
263
|
+
dict[str, float], # pixel ratio
|
|
264
|
+
]
|
|
265
|
+
|
|
266
|
+
def to_metric(self) -> Metric:
|
|
267
|
+
return Metric(
|
|
268
|
+
type=type(self).__name__,
|
|
269
|
+
value={
|
|
270
|
+
"confusion_matrix": self.confusion_matrix,
|
|
271
|
+
"hallucinations": self.hallucinations,
|
|
272
|
+
"missing_predictions": self.missing_predictions,
|
|
273
|
+
},
|
|
274
|
+
parameters={},
|
|
275
|
+
)
|
|
276
|
+
|
|
277
|
+
def to_dict(self) -> dict:
|
|
278
|
+
return self.to_metric().to_dict()
|
|
File without changes
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: valor-lite
|
|
3
|
+
Version: 0.33.9
|
|
4
|
+
Summary: Compute valor metrics locally.
|
|
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: Fast, local machine learning evaluation.
|
|
42
|
+
|
|
43
|
+
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.
|
|
44
|
+
|
|
45
|
+
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).
|
|
46
|
+
|
|
47
|
+
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!
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
### Classification
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from valor_lite.classification import DataLoader, Classification, MetricType
|
|
55
|
+
|
|
56
|
+
classifications = [
|
|
57
|
+
Classification(
|
|
58
|
+
uid="uid0",
|
|
59
|
+
groundtruth="dog",
|
|
60
|
+
predictions=["dog", "cat", "bird"],
|
|
61
|
+
scores=[0.75, 0.2, 0.05],
|
|
62
|
+
),
|
|
63
|
+
Classification(
|
|
64
|
+
uid="uid1",
|
|
65
|
+
groundtruth="cat",
|
|
66
|
+
predictions=["dog", "cat", "bird"],
|
|
67
|
+
scores=[0.41, 0.39, 0.1],
|
|
68
|
+
),
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
loader = DataLoader()
|
|
72
|
+
loader.add_data(classifications)
|
|
73
|
+
evaluator = loader.finalize()
|
|
74
|
+
|
|
75
|
+
metrics = evaluator.evaluate()
|
|
76
|
+
|
|
77
|
+
assert metrics[MetricType.Precision][0].to_dict() == {
|
|
78
|
+
'type': 'Precision',
|
|
79
|
+
'value': [0.5],
|
|
80
|
+
'parameters': {
|
|
81
|
+
'score_thresholds': [0.0],
|
|
82
|
+
'hardmax': True,
|
|
83
|
+
'label': 'dog'
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Object Detection
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
from valor_lite.object_detection import DataLoader, Detection, BoundingBox, MetricType
|
|
92
|
+
|
|
93
|
+
detections = [
|
|
94
|
+
Detection(
|
|
95
|
+
uid="uid0",
|
|
96
|
+
groundtruths=[
|
|
97
|
+
BoundingBox(
|
|
98
|
+
xmin=0, xmax=10,
|
|
99
|
+
ymin=0, ymax=10,
|
|
100
|
+
labels=["dog"]
|
|
101
|
+
),
|
|
102
|
+
BoundingBox(
|
|
103
|
+
xmin=20, xmax=30,
|
|
104
|
+
ymin=20, ymax=30,
|
|
105
|
+
labels=["cat"]
|
|
106
|
+
),
|
|
107
|
+
],
|
|
108
|
+
predictions=[
|
|
109
|
+
BoundingBox(
|
|
110
|
+
xmin=1, xmax=11,
|
|
111
|
+
ymin=1, ymax=11,
|
|
112
|
+
labels=["dog", "cat", "bird"],
|
|
113
|
+
scores=[0.85, 0.1, 0.05]
|
|
114
|
+
),
|
|
115
|
+
BoundingBox(
|
|
116
|
+
xmin=21, xmax=31,
|
|
117
|
+
ymin=21, ymax=31,
|
|
118
|
+
labels=["dog", "cat", "bird"],
|
|
119
|
+
scores=[0.34, 0.33, 0.33]
|
|
120
|
+
),
|
|
121
|
+
],
|
|
122
|
+
),
|
|
123
|
+
]
|
|
124
|
+
|
|
125
|
+
loader = DataLoader()
|
|
126
|
+
loader.add_bounding_boxes(detections)
|
|
127
|
+
evaluator = loader.finalize()
|
|
128
|
+
|
|
129
|
+
metrics = evaluator.evaluate()
|
|
130
|
+
|
|
131
|
+
assert metrics[MetricType.Precision][0].to_dict() == {
|
|
132
|
+
'type': 'Precision',
|
|
133
|
+
'value': 0.5,
|
|
134
|
+
'parameters': {
|
|
135
|
+
'iou_threshold': 0.5,
|
|
136
|
+
'score_threshold': 0.5,
|
|
137
|
+
'label': 'dog'
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Semantic Segmentation
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
import numpy as np
|
|
146
|
+
from valor_lite.semantic_segmentation import DataLoader, Segmentation, Bitmask, MetricType
|
|
147
|
+
|
|
148
|
+
segmentations = [
|
|
149
|
+
Segmentation(
|
|
150
|
+
uid="uid0",
|
|
151
|
+
groundtruths=[
|
|
152
|
+
Bitmask(
|
|
153
|
+
mask=np.random.randint(2, size=(10,10), dtype=np.bool_),
|
|
154
|
+
label="sky",
|
|
155
|
+
),
|
|
156
|
+
Bitmask(
|
|
157
|
+
mask=np.random.randint(2, size=(10,10), dtype=np.bool_),
|
|
158
|
+
label="ground",
|
|
159
|
+
)
|
|
160
|
+
],
|
|
161
|
+
predictions=[
|
|
162
|
+
Bitmask(
|
|
163
|
+
mask=np.random.randint(2, size=(10,10), dtype=np.bool_),
|
|
164
|
+
label="sky",
|
|
165
|
+
),
|
|
166
|
+
Bitmask(
|
|
167
|
+
mask=np.random.randint(2, size=(10,10), dtype=np.bool_),
|
|
168
|
+
label="ground",
|
|
169
|
+
)
|
|
170
|
+
]
|
|
171
|
+
),
|
|
172
|
+
]
|
|
173
|
+
|
|
174
|
+
loader = DataLoader()
|
|
175
|
+
loader.add_data(segmentations)
|
|
176
|
+
evaluator = loader.finalize()
|
|
177
|
+
|
|
178
|
+
print(metrics[MetricType.Precision][0])
|
|
179
|
+
```
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
valor_lite/LICENSE,sha256=M0L53VuwfEEqezhHb7NPeYcO_glw7-k4DMLZQ3eRN64,1068
|
|
2
|
+
valor_lite/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
valor_lite/schemas.py,sha256=r4cC10w1xYsA785KmGE4ePeOX3wzEs846vT7QAiVg_I,293
|
|
4
|
+
valor_lite/classification/__init__.py,sha256=2wmmziIzUATm7MbmAcPNLXrEX5l4oeD7XBwPd9bWM3Q,506
|
|
5
|
+
valor_lite/classification/annotation.py,sha256=0aUOvcwBAZgiNOJuyh-pXyNTG7vP7r8CUfnU3OmpUwQ,1113
|
|
6
|
+
valor_lite/classification/computation.py,sha256=qd9K7CcSGmMm_7shfX47_ZIuB-uE2LLiLMZSS_3NJTk,12093
|
|
7
|
+
valor_lite/classification/manager.py,sha256=7NKk4syQHH5hBEUDWTD0zIFkJSNdOMzJn8a8GzfBnDc,23205
|
|
8
|
+
valor_lite/classification/metric.py,sha256=m9_zD82YGl0QhuMql943YNKg67NZ6bsrR8ggs6_JZms,11728
|
|
9
|
+
valor_lite/object_detection/__init__.py,sha256=PiKfemo8FkZRzBhPSjhil8ahGURLy0Vk_iV25CB4UBU,1139
|
|
10
|
+
valor_lite/object_detection/annotation.py,sha256=o6VfiRobiB0ljqsNBLAYMXgi32RSIR7uTA-dgxq6zBI,8248
|
|
11
|
+
valor_lite/object_detection/computation.py,sha256=7rOfVlYDadXcJ1_S0FJRF3IPigcsR7guk_0rXeIdAOE,26919
|
|
12
|
+
valor_lite/object_detection/manager.py,sha256=k8VRqmlfWGKj1IuijbG49jXkMelE8v59pTQTCwkSMKk,38833
|
|
13
|
+
valor_lite/object_detection/metric.py,sha256=nWSqIQSBQrpl3Stz_xe2-AYoo2nrATeMuFVFmREjSNA,23833
|
|
14
|
+
valor_lite/semantic_segmentation/__init__.py,sha256=IdarTHKUuUMDvMBmInQu12Mm_NMCbql6Hf0nL5b56Ak,424
|
|
15
|
+
valor_lite/semantic_segmentation/annotation.py,sha256=CujYFdHS3fgr4Y7mEDs_u1XBmbPJzNU2CdqvjCT_d_A,2938
|
|
16
|
+
valor_lite/semantic_segmentation/computation.py,sha256=iJkEmTNmw9HwQCxSnpJkQsAdVcFriGhhu_WMks6D7tU,5122
|
|
17
|
+
valor_lite/semantic_segmentation/manager.py,sha256=aJk6edWZWKqrzl6hVmEUSZVYhHLuyihxWgAIXsCXkZ0,17361
|
|
18
|
+
valor_lite/semantic_segmentation/metric.py,sha256=Y8M3z92SaABEe9TwBUN37TFsh9DR5WoIxO-TfXVwz8I,6289
|
|
19
|
+
valor_lite/text_generation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
|
+
valor_lite-0.33.9.dist-info/LICENSE,sha256=M0L53VuwfEEqezhHb7NPeYcO_glw7-k4DMLZQ3eRN64,1068
|
|
21
|
+
valor_lite-0.33.9.dist-info/METADATA,sha256=dXS7Nt_WHKBaIARWZ3Ek27i26-pWyatewb3eFEnYor8,5631
|
|
22
|
+
valor_lite-0.33.9.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
23
|
+
valor_lite-0.33.9.dist-info/top_level.txt,sha256=9ujykxSwpl2Hu0_R95UQTR_l07k9UUTSdrpiqmq6zc4,11
|
|
24
|
+
valor_lite-0.33.9.dist-info/RECORD,,
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
from dataclasses import dataclass, field
|
|
2
|
-
|
|
3
|
-
import numpy as np
|
|
4
|
-
from numpy.typing import NDArray
|
|
5
|
-
from shapely.geometry import Polygon as ShapelyPolygon
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
@dataclass
|
|
9
|
-
class BoundingBox:
|
|
10
|
-
xmin: float
|
|
11
|
-
xmax: float
|
|
12
|
-
ymin: float
|
|
13
|
-
ymax: float
|
|
14
|
-
labels: list[tuple[str, str]]
|
|
15
|
-
scores: list[float] = field(default_factory=list)
|
|
16
|
-
|
|
17
|
-
def __post_init__(self):
|
|
18
|
-
if len(self.scores) > 0 and len(self.labels) != len(self.scores):
|
|
19
|
-
raise ValueError(
|
|
20
|
-
"If scores are defined, there must be a 1:1 pairing with labels."
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
@property
|
|
24
|
-
def extrema(self) -> tuple[float, float, float, float]:
|
|
25
|
-
return (self.xmin, self.xmax, self.ymin, self.ymax)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
@dataclass
|
|
29
|
-
class Polygon:
|
|
30
|
-
shape: ShapelyPolygon
|
|
31
|
-
labels: list[tuple[str, str]]
|
|
32
|
-
scores: list[float] = field(default_factory=list)
|
|
33
|
-
|
|
34
|
-
def __post_init__(self):
|
|
35
|
-
if not isinstance(self.shape, ShapelyPolygon):
|
|
36
|
-
raise TypeError("shape must be of type shapely.geometry.Polygon.")
|
|
37
|
-
if len(self.scores) > 0 and len(self.labels) != len(self.scores):
|
|
38
|
-
raise ValueError(
|
|
39
|
-
"If scores are defined, there must be a 1:1 pairing with labels."
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
def to_box(self) -> BoundingBox | None:
|
|
43
|
-
|
|
44
|
-
if self.shape.is_empty:
|
|
45
|
-
return None
|
|
46
|
-
|
|
47
|
-
xmin, ymin, xmax, ymax = self.shape.bounds
|
|
48
|
-
|
|
49
|
-
return BoundingBox(
|
|
50
|
-
xmin=xmin,
|
|
51
|
-
xmax=xmax,
|
|
52
|
-
ymin=ymin,
|
|
53
|
-
ymax=ymax,
|
|
54
|
-
labels=self.labels,
|
|
55
|
-
scores=self.scores,
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
@dataclass
|
|
60
|
-
class Bitmask:
|
|
61
|
-
mask: NDArray[np.bool_]
|
|
62
|
-
labels: list[tuple[str, str]]
|
|
63
|
-
scores: list[float] = field(default_factory=list)
|
|
64
|
-
|
|
65
|
-
def __post_init__(self):
|
|
66
|
-
if len(self.scores) > 0 and len(self.labels) != len(self.scores):
|
|
67
|
-
raise ValueError(
|
|
68
|
-
"If scores are defined, there must be a 1:1 pairing with labels."
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
def to_box(self) -> BoundingBox | None:
|
|
72
|
-
|
|
73
|
-
if not self.mask.any():
|
|
74
|
-
return None
|
|
75
|
-
|
|
76
|
-
rows, cols = np.nonzero(self.mask)
|
|
77
|
-
return BoundingBox(
|
|
78
|
-
xmin=cols.min(),
|
|
79
|
-
xmax=cols.max(),
|
|
80
|
-
ymin=rows.min(),
|
|
81
|
-
ymax=rows.max(),
|
|
82
|
-
labels=self.labels,
|
|
83
|
-
scores=self.scores,
|
|
84
|
-
)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
@dataclass
|
|
88
|
-
class Detection:
|
|
89
|
-
uid: str
|
|
90
|
-
groundtruths: list[BoundingBox] | list[Bitmask] | list[Polygon]
|
|
91
|
-
predictions: list[BoundingBox] | list[Bitmask] | list[Polygon]
|
|
92
|
-
|
|
93
|
-
def __post_init__(self):
|
|
94
|
-
for prediction in self.predictions:
|
|
95
|
-
if len(prediction.scores) != len(prediction.labels):
|
|
96
|
-
raise ValueError(
|
|
97
|
-
"Predictions must provide a score for every label."
|
|
98
|
-
)
|