Spaces:
Sleeping
Sleeping
Merge branch 'main' of https://huggingface.co/spaces/SEA-AI/PanopticQuality
Browse files- PanopticQuality.py +6 -7
- README.md +60 -4
PanopticQuality.py
CHANGED
@@ -109,6 +109,7 @@ class PQMetric(evaluate.Metric):
|
|
109 |
DEFAULT_STUFF = ["WATER", "SKY", "LAND", "CONSTRUCTION", "ICE", "OWN_BOAT"]
|
110 |
|
111 |
self.label2id = label2id if label2id is not None else DEFAULT_LABEL2ID
|
|
|
112 |
self.stuff = stuff if stuff is not None else DEFAULT_STUFF
|
113 |
self.per_class = per_class
|
114 |
self.split_sq_rq = split_sq_rq
|
@@ -118,6 +119,7 @@ class PQMetric(evaluate.Metric):
|
|
118 |
return_per_class=per_class,
|
119 |
return_sq_and_rq=split_sq_rq
|
120 |
)
|
|
|
121 |
|
122 |
def _info(self):
|
123 |
return evaluate.MetricInfo(
|
@@ -171,9 +173,6 @@ class PQMetric(evaluate.Metric):
|
|
171 |
fn = self.pq_metric.metric.false_negatives.clone()
|
172 |
iou = self.pq_metric.metric.iou_sum.clone()
|
173 |
|
174 |
-
id2label = {id: label for label, id in self.label2id.items()}
|
175 |
-
things_stuffs = sorted(self.pq_metric.things) + sorted(self.pq_metric.stuffs)
|
176 |
-
|
177 |
# compute scores
|
178 |
result = self.pq_metric.compute() # shape : (n_classes (sorted things + sorted stuffs), scores (pq, sq, rq))
|
179 |
|
@@ -182,11 +181,11 @@ class PQMetric(evaluate.Metric):
|
|
182 |
if self.per_class:
|
183 |
if not self.split_sq_rq:
|
184 |
result = result.T
|
185 |
-
result_dict["scores"] = {id2label[numeric_label]: result[i].tolist() \
|
186 |
-
for i, numeric_label in enumerate(things_stuffs)}
|
187 |
result_dict["scores"].update({"ALL": result.mean(axis=0).tolist()})
|
188 |
-
result_dict["numbers"] = {id2label[numeric_label]: [tp[i].item(), fp[i].item(), fn[i].item(), iou[i].item()] \
|
189 |
-
for i, numeric_label in enumerate(things_stuffs)}
|
190 |
result_dict["numbers"].update({"ALL": [tp.sum().item(), fp.sum().item(), fn.sum().item(), iou.sum().item()]})
|
191 |
else:
|
192 |
result_dict["scores"] = {"ALL": result.tolist() if self.split_sq_rq else [result.tolist()]}
|
|
|
109 |
DEFAULT_STUFF = ["WATER", "SKY", "LAND", "CONSTRUCTION", "ICE", "OWN_BOAT"]
|
110 |
|
111 |
self.label2id = label2id if label2id is not None else DEFAULT_LABEL2ID
|
112 |
+
self.id2label = {id: label for label, id in self.label2id.items()}
|
113 |
self.stuff = stuff if stuff is not None else DEFAULT_STUFF
|
114 |
self.per_class = per_class
|
115 |
self.split_sq_rq = split_sq_rq
|
|
|
119 |
return_per_class=per_class,
|
120 |
return_sq_and_rq=split_sq_rq
|
121 |
)
|
122 |
+
self.things_stuffs = sorted(self.pq_metric.things) + sorted(self.pq_metric.stuffs)
|
123 |
|
124 |
def _info(self):
|
125 |
return evaluate.MetricInfo(
|
|
|
173 |
fn = self.pq_metric.metric.false_negatives.clone()
|
174 |
iou = self.pq_metric.metric.iou_sum.clone()
|
175 |
|
|
|
|
|
|
|
176 |
# compute scores
|
177 |
result = self.pq_metric.compute() # shape : (n_classes (sorted things + sorted stuffs), scores (pq, sq, rq))
|
178 |
|
|
|
181 |
if self.per_class:
|
182 |
if not self.split_sq_rq:
|
183 |
result = result.T
|
184 |
+
result_dict["scores"] = {self.id2label[numeric_label]: result[i].tolist() \
|
185 |
+
for i, numeric_label in enumerate(self.things_stuffs)}
|
186 |
result_dict["scores"].update({"ALL": result.mean(axis=0).tolist()})
|
187 |
+
result_dict["numbers"] = {self.id2label[numeric_label]: [tp[i].item(), fp[i].item(), fn[i].item(), iou[i].item()] \
|
188 |
+
for i, numeric_label in enumerate(self.things_stuffs)}
|
189 |
result_dict["numbers"].update({"ALL": [tp.sum().item(), fp.sum().item(), fn.sum().item(), iou.sum().item()]})
|
190 |
else:
|
191 |
result_dict["scores"] = {"ALL": result.tolist() if self.split_sq_rq else [result.tolist()]}
|
README.md
CHANGED
@@ -5,7 +5,7 @@ tags:
|
|
5 |
- metric
|
6 |
description: PanopticQuality score
|
7 |
sdk: gradio
|
8 |
-
sdk_version:
|
9 |
app_file: app.py
|
10 |
pinned: false
|
11 |
emoji: 🖼️
|
@@ -36,11 +36,52 @@ To get started with PanopticQuality, make sure you have the necessary dependenci
|
|
36 |
Added data ...
|
37 |
Start computing ...
|
38 |
Finished!
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
```
|
41 |
|
42 |
## Metric Settings
|
43 |
-
The metric takes
|
44 |
|
45 |
* `label2id: Dict[str, int]`: this dictionary is used to map string labels to an integer representation.
|
46 |
if not provided a default setting will be used:
|
@@ -69,8 +110,23 @@ The metric takes two optional input parameters: __label2id__ and __stuff__.
|
|
69 |
`
|
70 |
["WATER", "SKY", "LAND", "CONSTRUCTION", "ICE", "OWN_BOAT"]`
|
71 |
|
|
|
|
|
|
|
|
|
|
|
72 |
## Output Values
|
73 |
-
A
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
## Further References
|
76 |
|
|
|
5 |
- metric
|
6 |
description: PanopticQuality score
|
7 |
sdk: gradio
|
8 |
+
sdk_version: 4.36.0
|
9 |
app_file: app.py
|
10 |
pinned: false
|
11 |
emoji: 🖼️
|
|
|
36 |
Added data ...
|
37 |
Start computing ...
|
38 |
Finished!
|
39 |
+
{'scores': {'MOTORBOAT': [0.18632257426639526,
|
40 |
+
0.698709617058436,
|
41 |
+
0.2666666805744171],
|
42 |
+
'FAR_AWAY_OBJECT': [0.0, 0.0, 0.0],
|
43 |
+
'SAILING_BOAT_WITH_CLOSED_SAILS': [0.0, 0.0, 0.0],
|
44 |
+
'SHIP': [0.3621737026917471, 0.684105846616957, 0.529411792755127],
|
45 |
+
'WATERCRAFT': [0.0, 0.0, 0.0],
|
46 |
+
'SPHERICAL_BUOY': [0.0, 0.0, 0.0],
|
47 |
+
'FLOTSAM': [0.0, 0.0, 0.0],
|
48 |
+
'SAILING_BOAT_WITH_OPEN_SAILS': [0.0, 0.0, 0.0],
|
49 |
+
'CONTAINER': [0.0, 0.0, 0.0],
|
50 |
+
'PILLAR_BUOY': [0.0, 0.0, 0.0],
|
51 |
+
'AERIAL_ANIMAL': [0.0, 0.0, 0.0],
|
52 |
+
'HUMAN_IN_WATER': [0.0, 0.0, 0.0],
|
53 |
+
'WOODEN_LOG': [0.0, 0.0, 0.0],
|
54 |
+
'MARITIME_ANIMAL': [0.0, 0.0, 0.0],
|
55 |
+
'WATER': [0.9397601008415222, 0.9397601008415222, 1.0],
|
56 |
+
'SKY': [0.9674496332804362, 0.9674496332804362, 1.0],
|
57 |
+
'LAND': [0.30757412078761204, 0.8304501533508301, 0.37037035822868347],
|
58 |
+
'CONSTRUCTION': [0.0, 0.0, 0.0],
|
59 |
+
'OWN_BOAT': [0.0, 0.0, 0.0],
|
60 |
+
'ALL': [0.14543579641409013, 0.21686712374464112, 0.16665520166095935]},
|
61 |
+
'numbers': {'MOTORBOAT': [6, 15, 18, 4.1922577023506165],
|
62 |
+
'FAR_AWAY_OBJECT': [0, 8, 9, 0.0],
|
63 |
+
'SAILING_BOAT_WITH_CLOSED_SAILS': [0, 2, 0, 0.0],
|
64 |
+
'SHIP': [9, 1, 15, 6.156952619552612],
|
65 |
+
'WATERCRAFT': [0, 9, 12, 0.0],
|
66 |
+
'SPHERICAL_BUOY': [0, 4, 22, 0.0],
|
67 |
+
'FLOTSAM': [0, 0, 1, 0.0],
|
68 |
+
'SAILING_BOAT_WITH_OPEN_SAILS': [0, 6, 0, 0.0],
|
69 |
+
'CONTAINER': [0, 0, 0, 0.0],
|
70 |
+
'PILLAR_BUOY': [0, 0, 9, 0.0],
|
71 |
+
'AERIAL_ANIMAL': [0, 0, 0, 0.0],
|
72 |
+
'HUMAN_IN_WATER': [0, 0, 0, 0.0],
|
73 |
+
'WOODEN_LOG': [0, 0, 0, 0.0],
|
74 |
+
'MARITIME_ANIMAL': [0, 0, 0, 0.0],
|
75 |
+
'WATER': [15, 0, 0, 14.096401512622833],
|
76 |
+
'SKY': [15, 0, 0, 14.511744499206543],
|
77 |
+
'LAND': [5, 9, 8, 4.15225076675415],
|
78 |
+
'CONSTRUCTION': [0, 0, 0, 0.0],
|
79 |
+
'OWN_BOAT': [0, 0, 8, 0.0],
|
80 |
+
'ALL': [50, 54, 102, 43.109607100486755]}}
|
81 |
```
|
82 |
|
83 |
## Metric Settings
|
84 |
+
The metric takes four optional input parameters: __label2id__, __stuff__, __per_class__ and __split_sq_rq__.
|
85 |
|
86 |
* `label2id: Dict[str, int]`: this dictionary is used to map string labels to an integer representation.
|
87 |
if not provided a default setting will be used:
|
|
|
110 |
`
|
111 |
["WATER", "SKY", "LAND", "CONSTRUCTION", "ICE", "OWN_BOAT"]`
|
112 |
|
113 |
+
* `per_class: bool = True`: By default, the results are split up per class.
|
114 |
+
Setting this to False will aggregate the results (average the _scores_, sum up the _numbers_; see below for explanation of _scores_ and _numbers_)
|
115 |
+
* `split_sq_rq: bool = True`: By default, the PQ-score is returned in three parts: the PQ score itself, and split into the segmentation quality (SQ) and recognition quality (RQ) part.
|
116 |
+
Setting this to False will return the PQ score only (PQ=RQ*SQ).
|
117 |
+
|
118 |
## Output Values
|
119 |
+
A dictionary containing the following keys:
|
120 |
+
* __scores__: This is a dictionary, that contains a key for each label, if `per_class == True`. Otherwise it only contains the key _all_.
|
121 |
+
For each key, it contains a list that holds the scores in the following order: PQ, SQ and RQ. If `split_sq_rq == False`, the list consists of PQ only.
|
122 |
+
* __numbers__: This is a dictionary, that contains a key for each label, if `per_class == True`. Otherwise it only contains the key _all_.
|
123 |
+
For each key, it contains a list that consists of four elements: TP, FP, FN and IOU:
|
124 |
+
* __TP__: number of true positive predictions
|
125 |
+
* __FP__: number of false positive predictions
|
126 |
+
* __FN__: number of false negative predictions
|
127 |
+
* __IOU__: sum of IOU of all TP predictions with ground truth
|
128 |
+
|
129 |
+
With all these values, it is possible to calculate the final scores.
|
130 |
|
131 |
## Further References
|
132 |
|