File size: 533 Bytes
7aad26f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from ultralytics import YOLO

def test_model():
    # Load the trained YOLO model with the correct path
    model = YOLO(r"runs\detect\train18\weights\best.pt")

    # Evaluate the model on the test set
    metrics = model.val(data=r"datasets\data.yaml")

    # Print key detection metrics
    print(f"mAP@50: {metrics.box.map50:.4f}")  # Mean Average Precision at IoU=0.5
    print(f"mAP@50-95: {metrics.box.map:.4f}")  # Mean Average Precision averaged over IoU=0.5:0.95

if __name__ == "__main__":
    test_model()