edgefirst-validator 4.2.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.
Files changed (73) hide show
  1. deepview/modelpack/utils/argmax.py +16 -0
  2. edgefirst/validator/__init__.py +1 -0
  3. edgefirst/validator/__main__.py +375 -0
  4. edgefirst/validator/datasets/__init__.py +118 -0
  5. edgefirst/validator/datasets/cache.py +296 -0
  6. edgefirst/validator/datasets/core.py +250 -0
  7. edgefirst/validator/datasets/darknet.py +446 -0
  8. edgefirst/validator/datasets/database.py +1067 -0
  9. edgefirst/validator/datasets/instance/__init__.py +4 -0
  10. edgefirst/validator/datasets/instance/core.py +222 -0
  11. edgefirst/validator/datasets/instance/detection.py +145 -0
  12. edgefirst/validator/datasets/instance/multitask.py +80 -0
  13. edgefirst/validator/datasets/instance/segmentation.py +120 -0
  14. edgefirst/validator/datasets/utils/fetch.py +682 -0
  15. edgefirst/validator/datasets/utils/readers.py +425 -0
  16. edgefirst/validator/datasets/utils/transformations.py +1695 -0
  17. edgefirst/validator/evaluators/__init__.py +17 -0
  18. edgefirst/validator/evaluators/callbacks/__init__.py +3 -0
  19. edgefirst/validator/evaluators/callbacks/core.py +192 -0
  20. edgefirst/validator/evaluators/callbacks/plots.py +900 -0
  21. edgefirst/validator/evaluators/callbacks/studio.py +234 -0
  22. edgefirst/validator/evaluators/core.py +257 -0
  23. edgefirst/validator/evaluators/detection.py +749 -0
  24. edgefirst/validator/evaluators/multitask.py +270 -0
  25. edgefirst/validator/evaluators/parameters/__init__.py +53 -0
  26. edgefirst/validator/evaluators/parameters/core.py +554 -0
  27. edgefirst/validator/evaluators/parameters/dataset.py +239 -0
  28. edgefirst/validator/evaluators/parameters/model.py +338 -0
  29. edgefirst/validator/evaluators/parameters/validation.py +528 -0
  30. edgefirst/validator/evaluators/segmentation.py +729 -0
  31. edgefirst/validator/evaluators/utils/__init__.py +3 -0
  32. edgefirst/validator/evaluators/utils/classify.py +292 -0
  33. edgefirst/validator/evaluators/utils/match.py +262 -0
  34. edgefirst/validator/evaluators/utils/timer.py +132 -0
  35. edgefirst/validator/metrics/__init__.py +9 -0
  36. edgefirst/validator/metrics/data/__init__.py +7 -0
  37. edgefirst/validator/metrics/data/label.py +668 -0
  38. edgefirst/validator/metrics/data/metrics.py +759 -0
  39. edgefirst/validator/metrics/data/plots.py +476 -0
  40. edgefirst/validator/metrics/data/stats.py +507 -0
  41. edgefirst/validator/metrics/detection.py +595 -0
  42. edgefirst/validator/metrics/segmentation.py +173 -0
  43. edgefirst/validator/metrics/utils/math.py +717 -0
  44. edgefirst/validator/publishers/__init__.py +3 -0
  45. edgefirst/validator/publishers/console.py +147 -0
  46. edgefirst/validator/publishers/studio.py +128 -0
  47. edgefirst/validator/publishers/tensorboard.py +119 -0
  48. edgefirst/validator/publishers/utils/logger.py +111 -0
  49. edgefirst/validator/publishers/utils/table.py +403 -0
  50. edgefirst/validator/runners/__init__.py +8 -0
  51. edgefirst/validator/runners/core.py +727 -0
  52. edgefirst/validator/runners/deepviewrt.py +177 -0
  53. edgefirst/validator/runners/hailo.py +263 -0
  54. edgefirst/validator/runners/keras.py +150 -0
  55. edgefirst/validator/runners/kinara.py +265 -0
  56. edgefirst/validator/runners/offline.py +228 -0
  57. edgefirst/validator/runners/onnx.py +241 -0
  58. edgefirst/validator/runners/processing/decode.py +320 -0
  59. edgefirst/validator/runners/processing/dvapi.py +4192 -0
  60. edgefirst/validator/runners/processing/nms.py +637 -0
  61. edgefirst/validator/runners/processing/outputs.py +507 -0
  62. edgefirst/validator/runners/tensorrt.py +321 -0
  63. edgefirst/validator/runners/tflite.py +221 -0
  64. edgefirst/validator/validate.py +843 -0
  65. edgefirst/validator/visualize/__init__.py +3 -0
  66. edgefirst/validator/visualize/detection.py +623 -0
  67. edgefirst/validator/visualize/segmentation.py +281 -0
  68. edgefirst/validator/visualize/utils/plots.py +635 -0
  69. edgefirst_validator-4.2.1.dist-info/METADATA +111 -0
  70. edgefirst_validator-4.2.1.dist-info/RECORD +73 -0
  71. edgefirst_validator-4.2.1.dist-info/WHEEL +5 -0
  72. edgefirst_validator-4.2.1.dist-info/entry_points.txt +2 -0
  73. edgefirst_validator-4.2.1.dist-info/top_level.txt +2 -0
@@ -0,0 +1,476 @@
1
+ import numpy as np
2
+
3
+
4
+ class Plots:
5
+ """
6
+ Container used to store the data needed for
7
+ plotting the validation charts.
8
+
9
+ Parameters
10
+ ----------
11
+ labels: list
12
+ A list of unique string labels to
13
+ initialize the confusion matrix.
14
+ """
15
+
16
+ def __init__(self, labels: list = []):
17
+ self.labels = labels
18
+ self.reset()
19
+
20
+ @property
21
+ def class_histogram_data(self) -> dict:
22
+ """
23
+ Attribute to access the class histogram data.
24
+
25
+ Returns
26
+ -------
27
+ dict
28
+ This contains the data for the class histogram.
29
+ """
30
+ return self.__class_histogram_data
31
+
32
+ @class_histogram_data.setter
33
+ def class_histogram_data(self, data: dict):
34
+ """
35
+ Sets the data for the class histogram to a new value.
36
+
37
+ Parameters
38
+ ----------
39
+ data: dict
40
+ This is the class histogram data to set.
41
+ This should be a dictionary with the following keys.
42
+
43
+ .. code-block:: python
44
+
45
+ {
46
+ "precision": precision,
47
+ "recall": recall,
48
+ "accuracy": accuracy,
49
+ "tp": tp,
50
+ "fn": fn,
51
+ "fp": fp,
52
+ "gt": gt
53
+ }
54
+ """
55
+ self.__class_histogram_data = data
56
+
57
+ def append_class_histogram_data(self, label: str, data: dict):
58
+ """
59
+ This adds another key to the class histogram data indicated as the
60
+ class label and data contains the metrics of that label.
61
+
62
+ Parameters
63
+ ----------
64
+ label: str
65
+ This is the key of the dictionary that is the class label.
66
+ data: dict
67
+ This contains the metrics of the label. This should
68
+ be a dictionary with the following keys.
69
+
70
+ .. code-block:: python
71
+
72
+ {
73
+ "precision": precision,
74
+ "recall": recall,
75
+ "accuracy": accuracy,
76
+ "tp": tp,
77
+ "fn": fn,
78
+ "fp": fp,
79
+ "gt": gt
80
+ }
81
+ """
82
+ self.__class_histogram_data[label] = data
83
+
84
+ @property
85
+ def confusion_labels(self) -> list:
86
+ """
87
+ Attribute to access the confusion matrix unique labels.
88
+
89
+ Returns
90
+ -------
91
+ list
92
+ This contains the labels for the confusion matrix.
93
+ """
94
+ return self.__confusion_labels
95
+
96
+ @confusion_labels.setter
97
+ def confusion_labels(self, labels: list):
98
+ """
99
+ Sets the labels for the confusion matrix to a new value.
100
+
101
+ Parameters
102
+ ----------
103
+ labels: list
104
+ These are the confusion matrix labels to set.
105
+ """
106
+ self.__confusion_labels = labels
107
+
108
+ @property
109
+ def confusion_matrix(self) -> np.ndarray:
110
+ """
111
+ Attribute to access the confusion matrix.
112
+
113
+ Returns
114
+ -------
115
+ np.ndarray
116
+ This contains the confusion matrix.
117
+ """
118
+ return self.__confusion_matrix
119
+
120
+ @confusion_matrix.setter
121
+ def confusion_matrix(self, matrix: np.ndarray):
122
+ """
123
+ Sets the confusion matrix to a new value.
124
+
125
+ Parameters
126
+ ----------
127
+ matrix: :py:class:`np.ndarray`
128
+ This is the confusion matrix to set.
129
+ """
130
+ self.__confusion_matrix = matrix
131
+
132
+ def initialize_confusion_matrix(self):
133
+ """
134
+ Initialize the confusion matrix array.
135
+ """
136
+ labels = self.labels
137
+ # Insert the background class in the confusion matrix if it doesn't
138
+ # exist.
139
+ if not any(s.lower() == "background" for s in self.labels):
140
+ labels = ["background"] + self.labels
141
+
142
+ self.confusion_labels = labels
143
+ # Rows = predictions, columns = ground truth
144
+ self.confusion_matrix = np.zeros(
145
+ (len(labels), len(labels)), dtype=np.int32)
146
+
147
+ @property
148
+ def px(self) -> np.ndarray:
149
+ """
150
+ Attribute to access px.
151
+
152
+ Returns
153
+ -------
154
+ np.ndarray
155
+ Precision vs Recall Curve 1000-point interpolated px values
156
+ representing recall.
157
+ """
158
+ return self.__px
159
+
160
+ @px.setter
161
+ def px(self, this_px: np.ndarray):
162
+ """
163
+ Sets px to a new value.
164
+
165
+ Parameters
166
+ ----------
167
+ px: np.ndarray
168
+ The px values to set.
169
+ """
170
+ self.__px = this_px
171
+
172
+ @property
173
+ def py(self) -> np.ndarray:
174
+ """
175
+ Attribute to access py.
176
+
177
+ Returns
178
+ -------
179
+ np.ndarray
180
+ Precision vs Recall Curve 1000-point interpolated py values
181
+ representing precision.
182
+ """
183
+ return self.__py
184
+
185
+ @py.setter
186
+ def py(self, this_py: np.ndarray):
187
+ """
188
+ Sets py to a new value.
189
+
190
+ Parameters
191
+ ----------
192
+ py: np.ndarray
193
+ The py values to set.
194
+ """
195
+ self.__py = this_py
196
+
197
+ @property
198
+ def precision(self) -> np.ndarray:
199
+ """
200
+ Attribute to access the array of precision values.
201
+
202
+ Returns
203
+ -------
204
+ np.ndarray
205
+ This contains the data for the precision recall curve.
206
+ """
207
+ return self.__precision
208
+
209
+ @precision.setter
210
+ def precision(self, data: np.ndarray):
211
+ """
212
+ Sets the data for the precision values.
213
+
214
+ Parameters
215
+ ----------
216
+ data: :py:class:`np.ndarray`
217
+ These are the precision values to set.
218
+
219
+ This data should be formatted as the following:
220
+ (nc x thresholds) so each row are for a unique class and
221
+ each column is the precision value for each score threshold.
222
+ """
223
+ self.__precision = data
224
+
225
+ @property
226
+ def recall(self) -> np.ndarray:
227
+ """
228
+ Attribute to access the array of recall values.
229
+
230
+ Returns
231
+ -------
232
+ np.ndarray
233
+ This contains the data for the precision recall curve.
234
+ """
235
+ return self.__recall
236
+
237
+ @recall.setter
238
+ def recall(self, data: np.ndarray):
239
+ """
240
+ Sets the data for the recall values.
241
+
242
+ Parameters
243
+ ----------
244
+ data: np.ndarray
245
+ These are the recall values to set.
246
+
247
+ This data should be formatted as the following:
248
+ (nc x thresholds) so each row are for a unique class and
249
+ each column is the recall value for each score threshold.
250
+ """
251
+ self.__recall = data
252
+
253
+ @property
254
+ def f1(self) -> np.ndarray:
255
+ """
256
+ Attribute to access the array of F1 values.
257
+
258
+ Returns
259
+ -------
260
+ np.ndarray
261
+ This contains the data for the precision-f1 curve.
262
+ """
263
+ return self.__f1
264
+
265
+ @f1.setter
266
+ def f1(self, data: np.ndarray):
267
+ """
268
+ Sets the data for the F1 values.
269
+
270
+ Parameters
271
+ ----------
272
+ data: np.ndarray
273
+ These are the F1 values to set.
274
+
275
+ This data should be formatted as the following:
276
+ (nc x thresholds) so each row are for a unique class and
277
+ each column is the F1 value for each score threshold.
278
+ """
279
+ self.__f1 = data
280
+
281
+ @property
282
+ def average_precision(self) -> np.ndarray:
283
+ """
284
+ Attribute to access the array of average precision values.
285
+
286
+ Returns
287
+ -------
288
+ np.ndarray
289
+ This contains the data for the precision recall curve.
290
+ """
291
+ return self.__average_precision
292
+
293
+ @average_precision.setter
294
+ def average_precision(self, data: np.ndarray):
295
+ """
296
+ Sets the data for the average precision values.
297
+
298
+ Parameters
299
+ ----------
300
+ data: np.ndarray
301
+ These are the average precision values to set.
302
+
303
+ This data should be formatted as the following:
304
+ (nc x 10) so each row are for a unique class and
305
+ each column is the precision at 10 different IoU threshold from
306
+ 0.50 to 0.95 in 0.05 intervals with a static score threshold
307
+ set from the command line.
308
+ """
309
+ self.__average_precision = data
310
+
311
+ @property
312
+ def curve_labels(self) -> list:
313
+ """
314
+ Attribute to access the precision recall curve unique labels.
315
+
316
+ Returns
317
+ -------
318
+ list
319
+ This contains the labels for the precision recall curve.
320
+ """
321
+ return self.__curve_labels
322
+
323
+ @curve_labels.setter
324
+ def curve_labels(self, labels: list):
325
+ """
326
+ Sets the labels for the precision recall curve to a new value.
327
+
328
+ Parameters
329
+ ----------
330
+ labels: list
331
+ These are the precision recall curve labels to set.
332
+ """
333
+ self.__curve_labels = labels
334
+
335
+ @property
336
+ def tp_scores(self) -> list:
337
+ """
338
+ Attribute to access the confidence scores of true positive detections.
339
+
340
+ Returns
341
+ -------
342
+ list
343
+ A list containing the scores assigned to true positive detections.
344
+ """
345
+ return self.__tp_scores
346
+
347
+ @tp_scores.setter
348
+ def tp_scores(self, scores: list):
349
+ """
350
+ Sets the confidence scores for true positive detections.
351
+
352
+ Parameters
353
+ ----------
354
+ scores: list
355
+ A list of confidence scores to assign to true positive detections.
356
+ """
357
+ self.__tp_scores = scores
358
+
359
+ @property
360
+ def fp_scores(self) -> list:
361
+ """
362
+ Attribute to access the confidence scores of false positive detections.
363
+
364
+ Returns
365
+ -------
366
+ list
367
+ A list containing the scores assigned to false positive detections.
368
+ """
369
+ return self.__fp_scores
370
+
371
+ @fp_scores.setter
372
+ def fp_scores(self, scores: list):
373
+ """
374
+ Sets the confidence scores for false positive detections.
375
+
376
+ Parameters
377
+ ----------
378
+ scores: list
379
+ A list of confidence scores to assign to false positive detections.
380
+ """
381
+ self.__fp_scores = scores
382
+
383
+ @property
384
+ def tp_ious(self):
385
+ """
386
+ Attribute to access the IoU values for true positive detections.
387
+
388
+ Returns
389
+ -------
390
+ list
391
+ A list containing Intersection-over-Union (IoU)
392
+ values for true positives.
393
+ """
394
+ return self.__tp_ious
395
+
396
+ @tp_ious.setter
397
+ def tp_ious(self, ious: list):
398
+ """
399
+ Sets the IoU values for true positive detections.
400
+
401
+ Parameters
402
+ ----------
403
+ ious: list
404
+ A list of IoU values to assign to true positive detections.
405
+ """
406
+ self.__tp_ious = ious
407
+
408
+ @property
409
+ def fp_ious(self):
410
+ """
411
+ Attribute to access the IoU values for false positive detections.
412
+
413
+ Returns
414
+ -------
415
+ list
416
+ A list containing Intersection-over-Union (IoU) values
417
+ for false positives.
418
+ """
419
+ return self.__fp_ious
420
+
421
+ @fp_ious.setter
422
+ def fp_ious(self, ious: list):
423
+ """
424
+ Sets the IoU values for false positive detections.
425
+
426
+ Parameters
427
+ ----------
428
+ ious: list
429
+ A list of IoU values to assign to false positive detections.
430
+ """
431
+ self.__fp_ious = ious
432
+
433
+ def reset(self):
434
+ """
435
+ Resets the containers for the data use to plot.
436
+ """
437
+ self.__class_histogram_data = dict()
438
+
439
+ """Confusion Matrix Data"""
440
+ self.__confusion_labels = list()
441
+ self.__confusion_matrix = list()
442
+
443
+ """Precision Recall Curve"""
444
+ self.__px = np.array([])
445
+ self.__py = np.array([])
446
+ self.__precision = list()
447
+ self.__recall = list()
448
+ self.__f1 = list()
449
+ self.__average_precision = list()
450
+ self.__curve_labels = list()
451
+
452
+ """TP vs FP scores"""
453
+ self.__tp_scores = list()
454
+ self.__fp_scores = list()
455
+
456
+ """TP vs FP IoUs"""
457
+ self.__tp_ious = list()
458
+ self.__fp_ious = list()
459
+
460
+
461
+ class MultitaskPlots:
462
+ """
463
+ A container for both detection and segmentation
464
+ plots for Multitask validation.
465
+
466
+ Parameters
467
+ -----------
468
+ detection_plots: Plots
469
+ Detection plots container.
470
+ segmentation_plots: Plots
471
+ Segmentation plots container.
472
+ """
473
+
474
+ def __init__(self, detection_plots: Plots, segmentation_plots: Plots):
475
+ self.detection_plots = detection_plots
476
+ self.segmentation_plots = segmentation_plots