Spaces:
Sleeping
Sleeping
franzi2505
commited on
Commit
•
0bb094e
1
Parent(s):
193d419
add per class pq score + sq and rq split up
Browse files- PanopticQuality.py +8 -1
PanopticQuality.py
CHANGED
@@ -151,6 +151,9 @@ class PQMetric(evaluate.Metric):
|
|
151 |
# in case the inputs are lists, convert them to numpy arrays
|
152 |
|
153 |
self.pq_metric.update(prediction, reference)
|
|
|
|
|
|
|
154 |
|
155 |
# does not impact the metric, but is required for the interface x_x
|
156 |
super(evaluate.Metric, self).add(
|
@@ -161,7 +164,11 @@ class PQMetric(evaluate.Metric):
|
|
161 |
|
162 |
def _compute(self, *, predictions, references, **kwargs):
|
163 |
"""Called within the evaluate.Metric.compute() method"""
|
164 |
-
|
|
|
|
|
|
|
|
|
165 |
|
166 |
def add_payload(self, payload: Payload, model_name: str = None):
|
167 |
"""Converts the payload to the format expected by the metric"""
|
|
|
151 |
# in case the inputs are lists, convert them to numpy arrays
|
152 |
|
153 |
self.pq_metric.update(prediction, reference)
|
154 |
+
print("TP:", self.pq_metric.metric.true_positives)
|
155 |
+
print("FP:", self.pq_metric.metric.false_positives)
|
156 |
+
print("FN:", self.pq_metric.metric.false_negatives)
|
157 |
|
158 |
# does not impact the metric, but is required for the interface x_x
|
159 |
super(evaluate.Metric, self).add(
|
|
|
164 |
|
165 |
def _compute(self, *, predictions, references, **kwargs):
|
166 |
"""Called within the evaluate.Metric.compute() method"""
|
167 |
+
result = self.pq_metric.compute() # n_classes (sorted things + sorted stuffs), (pq, sq, rq)
|
168 |
+
id2label = {id: label for label, id in self.label2id.items()}
|
169 |
+
return {
|
170 |
+
id2label[numeric_label]: result[i] for i, numeric_label in enumerate(self.pq_metric.things + self.pq_metric.stuffs)
|
171 |
+
}
|
172 |
|
173 |
def add_payload(self, payload: Payload, model_name: str = None):
|
174 |
"""Converts the payload to the format expected by the metric"""
|