Spaces:
Sleeping
Sleeping
bascobasculino
commited on
Commit
•
68c72a6
1
Parent(s):
0fc63e3
- my_metricv2.py +22 -9
my_metricv2.py
CHANGED
@@ -109,11 +109,9 @@ class MyMetricv2(evaluate.Metric):
|
|
109 |
"""Returns the scores"""
|
110 |
# TODO: Compute the different scores of the module
|
111 |
|
112 |
-
# <frame number>, <object id>, <bb_left>, <bb_top>, <bb_width>, <bb_height>, <confidence>, <x>, <y>, <z>
|
113 |
-
|
114 |
return calculate(predictions, references)
|
115 |
|
116 |
-
def calculate(predictions, references):
|
117 |
"""Returns the scores"""
|
118 |
try:
|
119 |
np_predictions = np.array(predictions)
|
@@ -123,14 +121,29 @@ def calculate(predictions, references):
|
|
123 |
try:
|
124 |
np_references = np.array(references)
|
125 |
except:
|
126 |
-
raise ValueError("The references should be a list of np.arrays in the format [frame number, object id, bb_left, bb_top, bb_width, bb_height
|
127 |
|
128 |
-
|
129 |
-
|
130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
return {
|
132 |
-
|
133 |
"predictions": predictions,
|
134 |
"references": references
|
135 |
-
|
136 |
}
|
|
|
109 |
"""Returns the scores"""
|
110 |
# TODO: Compute the different scores of the module
|
111 |
|
|
|
|
|
112 |
return calculate(predictions, references)
|
113 |
|
114 |
+
def calculate(predictions, references, max_iou: float = 0.5):
|
115 |
"""Returns the scores"""
|
116 |
try:
|
117 |
np_predictions = np.array(predictions)
|
|
|
121 |
try:
|
122 |
np_references = np.array(references)
|
123 |
except:
|
124 |
+
raise ValueError("The references should be a list of np.arrays in the format [frame number, object id, bb_left, bb_top, bb_width, bb_height]")
|
125 |
|
126 |
+
if np_predictions.shape[1] != 7:
|
127 |
+
raise ValueError("The predictions should be a list of np.arrays in the format [frame number, object id, bb_left, bb_top, bb_width, bb_height, confidence]")
|
128 |
+
if np_references.shape[1] != 6:
|
129 |
+
raise ValueError("The references should be a list of np.arrays in the format [frame number, object id, bb_left, bb_top, bb_width, bb_height]")
|
130 |
+
|
131 |
+
if np_predictions[:, 0].min() <= 0:
|
132 |
+
raise ValueError("The frame number in the predictions should be a positive integer")
|
133 |
+
if np_references[:, 0].min() <= 0:
|
134 |
+
raise ValueError("The frame number in the references should be a positive integer")
|
135 |
+
|
136 |
+
|
137 |
+
num_frames = max(np_references[:, 0].max(), np_predictions[:, 0].max())
|
138 |
+
|
139 |
+
acc = mm.MOTAccumulator(auto_id=True)
|
140 |
+
for i in range(1, num_frames+1):
|
141 |
+
preds = np_predictions[np_predictions[:, 0] == i, 1:6]
|
142 |
+
refs = np_references[np_references[:, 0] == i, 1:6]
|
143 |
+
print(preds)
|
144 |
+
print(refs)
|
145 |
+
|
146 |
return {
|
|
|
147 |
"predictions": predictions,
|
148 |
"references": references
|
|
|
149 |
}
|