from typing import List
from kitcar_ml.utils.bounding_box import BoundingBox
from kitcar_ml.utils.evaluation.interpolation_evaluator import InterpolationEvaluator
from kitcar_ml.utils.evaluation.test.basic_utility import create_bounding_boxes
from kitcar_ml.utils.evaluation.test.model_mock import predict_with_overlap
[docs]def predict(model, gts) -> List[List[BoundingBox]]:
"""Predicts the bounding boxes for the images using the model.
Returns: The groundtruth labels and the detections
"""
det_bbs = []
for gt in gts:
dets = model(None, gt, accuracy=0.8, additional_labels=0, error=0.00)
det_bbs.append(dets)
return det_bbs
if __name__ == "__main__":
# Initialize the evaluator.
iouv = (0.1, 0.2, 0.3, 0.5, 0.78, 0.95)
interpolation_evaluator = InterpolationEvaluator(iouv)
# Faking the dataset.
gts, _, _ = create_bounding_boxes(
accuracy=0.5, max_boxes=500, num_images=10, num_classes=5
)
# Create the detections with the model that you want to test.
dets = predict(predict_with_overlap, gts)
# Call the evaluator with the groundtruths and the detections.
interpolation_evaluator(gts, dets, classes=["0", "3"])
# Output a summary of the evaluator.
print(interpolation_evaluator)
# Plot the calculated graphics.
interpolation_evaluator.plot_precision_recall_curves(
save_path=None, save_prefix="test_model"
)