Made evaluation compatible with Caffe-like decoding
Signed-off-by: Jim Martens <github@2martens.de>
This commit is contained in:
@ -61,7 +61,7 @@ def get_number_gt_per_class(labels: Sequence[Sequence[Sequence[int]]],
|
||||
|
||||
def prepare_predictions(predictions: Sequence[Sequence[Sequence[Union[int, float]]]],
|
||||
nr_classes: int) -> \
|
||||
List[List[Tuple[int, float, float, int, int, int, int]]]:
|
||||
List[List[Tuple[int, float, int, int, int, int]]]:
|
||||
"""
|
||||
Prepares the predictions for further processing.
|
||||
|
||||
@ -73,27 +73,38 @@ def prepare_predictions(predictions: Sequence[Sequence[Sequence[Union[int, float
|
||||
list of predictions per class
|
||||
"""
|
||||
results = [list() for _ in range(nr_classes + 1)]
|
||||
# index positions for bounding box coordinates
|
||||
xmin = 2
|
||||
ymin = 3
|
||||
xmax = 4
|
||||
ymax = 5
|
||||
|
||||
for i, batch_item in enumerate(predictions):
|
||||
image_id = i
|
||||
|
||||
for box in batch_item:
|
||||
if len(box) == 7:
|
||||
# entropy is in box list
|
||||
xmin += 1
|
||||
ymin += 1
|
||||
xmax += 1
|
||||
ymax += 1
|
||||
|
||||
class_id = int(box[0])
|
||||
# Round the box coordinates to reduce the required memory.
|
||||
confidence = box[1]
|
||||
entropy = box[2]
|
||||
xmin = round(box[3])
|
||||
ymin = round(box[4])
|
||||
xmax = round(box[5])
|
||||
ymax = round(box[6])
|
||||
prediction = (image_id, confidence, entropy, xmin, ymin, xmax, ymax)
|
||||
xmin = round(box[xmin])
|
||||
ymin = round(box[ymin])
|
||||
xmax = round(box[xmax])
|
||||
ymax = round(box[ymax])
|
||||
prediction = (image_id, confidence, xmin, ymin, xmax, ymax)
|
||||
# Append the predicted box to the results list for its class.
|
||||
results[class_id].append(prediction)
|
||||
|
||||
return results
|
||||
|
||||
|
||||
def match_predictions(predictions: Sequence[Sequence[Tuple[int, float, float, int, int, int, int]]],
|
||||
def match_predictions(predictions: Sequence[Sequence[Tuple[int, float, int, int, int, int]]],
|
||||
labels: Sequence[Sequence[Sequence[int]]],
|
||||
iou_func: callable,
|
||||
nr_classes: int,
|
||||
@ -169,7 +180,6 @@ def match_predictions(predictions: Sequence[Sequence[Tuple[int, float, float, in
|
||||
# Create the data type for the structured array.
|
||||
preds_data_type = np.dtype([('image_id', np.int32),
|
||||
('confidence', 'f4'),
|
||||
('entropy', 'f4'),
|
||||
('xmin', 'f4'),
|
||||
('ymin', 'f4'),
|
||||
('xmax', 'f4'),
|
||||
|
||||
Reference in New Issue
Block a user