valor-lite 0.33.12__py3-none-any.whl → 0.33.14__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,104 @@
1
+ from collections import defaultdict
2
+
3
+ import numpy as np
4
+ from numpy.typing import NDArray
5
+ from valor_lite.semantic_segmentation.metric import Metric, MetricType
6
+
7
+
8
+ def unpack_precision_recall_iou_into_metric_lists(
9
+ results: tuple,
10
+ label_metadata: NDArray[np.int32],
11
+ index_to_label: dict[int, str],
12
+ ) -> dict[MetricType, list[Metric]]:
13
+
14
+ n_labels = len(index_to_label)
15
+ (
16
+ precision,
17
+ recall,
18
+ f1_score,
19
+ accuracy,
20
+ ious,
21
+ hallucination_ratios,
22
+ missing_prediction_ratios,
23
+ ) = results
24
+
25
+ metrics = defaultdict(list)
26
+
27
+ metrics[MetricType.Accuracy] = [
28
+ Metric.accuracy(
29
+ value=float(accuracy),
30
+ )
31
+ ]
32
+
33
+ metrics[MetricType.ConfusionMatrix] = [
34
+ Metric.confusion_matrix(
35
+ confusion_matrix={
36
+ index_to_label[gt_label_idx]: {
37
+ index_to_label[pd_label_idx]: {
38
+ "iou": float(ious[gt_label_idx, pd_label_idx])
39
+ }
40
+ for pd_label_idx in range(n_labels)
41
+ if label_metadata[pd_label_idx, 0] > 0
42
+ }
43
+ for gt_label_idx in range(n_labels)
44
+ if label_metadata[gt_label_idx, 0] > 0
45
+ },
46
+ hallucinations={
47
+ index_to_label[pd_label_idx]: {
48
+ "ratio": float(hallucination_ratios[pd_label_idx])
49
+ }
50
+ for pd_label_idx in range(n_labels)
51
+ if label_metadata[pd_label_idx, 0] > 0
52
+ },
53
+ missing_predictions={
54
+ index_to_label[gt_label_idx]: {
55
+ "ratio": float(missing_prediction_ratios[gt_label_idx])
56
+ }
57
+ for gt_label_idx in range(n_labels)
58
+ if label_metadata[gt_label_idx, 0] > 0
59
+ },
60
+ )
61
+ ]
62
+
63
+ metrics[MetricType.mIOU] = [
64
+ Metric.mean_iou(
65
+ value=float(ious.diagonal().mean()),
66
+ )
67
+ ]
68
+
69
+ for label_idx, label in index_to_label.items():
70
+
71
+ kwargs = {
72
+ "label": label,
73
+ }
74
+
75
+ # if no groundtruths exists for a label, skip it.
76
+ if label_metadata[label_idx, 0] == 0:
77
+ continue
78
+
79
+ metrics[MetricType.Precision].append(
80
+ Metric.precision(
81
+ value=float(precision[label_idx]),
82
+ **kwargs,
83
+ )
84
+ )
85
+ metrics[MetricType.Recall].append(
86
+ Metric.recall(
87
+ value=float(recall[label_idx]),
88
+ **kwargs,
89
+ )
90
+ )
91
+ metrics[MetricType.F1].append(
92
+ Metric.f1_score(
93
+ value=float(f1_score[label_idx]),
94
+ **kwargs,
95
+ )
96
+ )
97
+ metrics[MetricType.IOU].append(
98
+ Metric.iou(
99
+ value=float(ious[label_idx, label_idx]),
100
+ **kwargs,
101
+ )
102
+ )
103
+
104
+ return metrics
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: valor-lite
3
- Version: 0.33.12
3
+ Version: 0.33.14
4
4
  Summary: Compute valor metrics locally.
5
5
  License: MIT License
6
6
 
@@ -0,0 +1,27 @@
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=hcCFJ4ZywlFCqhx0om80Uf4xpASYPvs2vpP1yOUIqaE,403
4
+ valor_lite/classification/__init__.py,sha256=8MI8bGwCxYGqRP7KxG7ezhYv4qQ5947XGvvlF8WPM5g,392
5
+ valor_lite/classification/annotation.py,sha256=0aUOvcwBAZgiNOJuyh-pXyNTG7vP7r8CUfnU3OmpUwQ,1113
6
+ valor_lite/classification/computation.py,sha256=qfBhhuDYCiY8h2RdBG3shzgJbHLXDVNujkYFg9xZa6U,12116
7
+ valor_lite/classification/manager.py,sha256=8GXZECSx4CBbG5NfPrA19BPENqmrjo-wZBmaulWHY20,16676
8
+ valor_lite/classification/metric.py,sha256=0ZGp7Wm4oc0h_EBiYfVEs39QEeL5xa-F27gig7smnq8,11409
9
+ valor_lite/classification/utilities.py,sha256=PmQar06Vt-ew4Jvnn0IM63mq730QVTsdRtFdVu1HMFU,6885
10
+ valor_lite/object_detection/__init__.py,sha256=Ql8rju2q7y0Zd9zFvtBJDRhgQFDm1RSYkTsyH3ZE6pA,648
11
+ valor_lite/object_detection/annotation.py,sha256=o6VfiRobiB0ljqsNBLAYMXgi32RSIR7uTA-dgxq6zBI,8248
12
+ valor_lite/object_detection/computation.py,sha256=xqV_KdYAGyq32VePW0pL8pO3YGRO46ZUVo0luwYD1P8,28024
13
+ valor_lite/object_detection/manager.py,sha256=YjM9Kx3xrIt2VMjNZ-8guPchPq7YBABlams_7eZvYVY,23298
14
+ valor_lite/object_detection/metric.py,sha256=QbxYTOykysshhpdVJjxMPnw8hvcAv4SM3sXDZj8OwnE,23967
15
+ valor_lite/object_detection/utilities.py,sha256=98VSW-g8EYI8Cdd9KHLHdm6F4fI89jaX5I4z99zny4s,16271
16
+ valor_lite/semantic_segmentation/__init__.py,sha256=HQQkr3iBPQfdUrsu0uvx-Uyv9SYmumU1B3slbWOnpNY,245
17
+ valor_lite/semantic_segmentation/annotation.py,sha256=CujYFdHS3fgr4Y7mEDs_u1XBmbPJzNU2CdqvjCT_d_A,2938
18
+ valor_lite/semantic_segmentation/computation.py,sha256=rrql3zmpqt4Zygc2BD4SyUfNW_NXC93_kHB-lGBzjXU,5122
19
+ valor_lite/semantic_segmentation/manager.py,sha256=pMepH3zk_fApyFtC9tLrmEYuCbg1n5TLh1J8QRadE44,14287
20
+ valor_lite/semantic_segmentation/metric.py,sha256=i8uTcalwvzK7CDHJ_8I-zplWe-qrMtXwH_5ZcTBi3M8,6219
21
+ valor_lite/semantic_segmentation/utilities.py,sha256=vZM66YNMz9VJclhuKvcWp74nF65s6bscnnD5U9iDW7Q,2925
22
+ valor_lite/text_generation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
+ valor_lite-0.33.14.dist-info/LICENSE,sha256=M0L53VuwfEEqezhHb7NPeYcO_glw7-k4DMLZQ3eRN64,1068
24
+ valor_lite-0.33.14.dist-info/METADATA,sha256=G2j4SCVunrizKzJ9pBRH8h73RbzbFMbbMViHFuXG4pM,5632
25
+ valor_lite-0.33.14.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
26
+ valor_lite-0.33.14.dist-info/top_level.txt,sha256=9ujykxSwpl2Hu0_R95UQTR_l07k9UUTSdrpiqmq6zc4,11
27
+ valor_lite-0.33.14.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.1.0)
2
+ Generator: setuptools (75.2.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,24 +0,0 @@
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=pMePRFKCikYiGDgR-ZB8TmrzAts5ZIz4EywCT-XL42g,12100
7
- valor_lite/classification/manager.py,sha256=fwb5z84SzgJ-ud1kTY3oYbUJLbA7R0cdWqqcaAIUcWs,23222
8
- valor_lite/classification/metric.py,sha256=JjY9x6Sq1Hr_2agGnyT9EhVI5wXKQcMmEwxIK32yhGw,11903
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=ZW83XT-aemRg-5ZdISmrj0bRD9wWmYCU3gkSlfXlNZc,27747
12
- valor_lite/object_detection/manager.py,sha256=vb4JpynNF0JcnFwNmReFjls9UGAquigN2hpEbG89J04,38991
13
- valor_lite/object_detection/metric.py,sha256=tHRVnpBqw_w1VwnNkTCmu1yv7Max9FRlf5uh0wYew4s,24046
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.12.dist-info/LICENSE,sha256=M0L53VuwfEEqezhHb7NPeYcO_glw7-k4DMLZQ3eRN64,1068
21
- valor_lite-0.33.12.dist-info/METADATA,sha256=Sak_wCIniTYTNYjNrF8sy-ITbFdG_j_zFUq-jz1PYLk,5632
22
- valor_lite-0.33.12.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
23
- valor_lite-0.33.12.dist-info/top_level.txt,sha256=9ujykxSwpl2Hu0_R95UQTR_l07k9UUTSdrpiqmq6zc4,11
24
- valor_lite-0.33.12.dist-info/RECORD,,