I am currently working with Ultralytics - YOLOv8 model. I want to calculate the confusion matrix manually, not using val.py module. Hence, I wrote the code:
import os
import torch
from PIL import Image
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle
from glob import glob
from shutil import rmtree
from ultralytics import YOLO
import numpy as np
# Set the path to your model weights
weights_path = 'best.pt'
# Set the path to your test data folder
test_data_folder = 'images'
# Load the model
model = YOLO(weights_path)
### I want to iterate, predict and save the list of precion-recall-threshold with this for-loop
#for conf in np.arange(.005,1.01,.005):
result = model.predict(source=test_data_folder,save_txt=True,save=True,conf=0.7)
With the code, the result variable is used to store results from the whole image folder I want to test/validate.
But how do I retrieve things like IoU scores, confusion matrices, etc. whenever I change the conf parameter for the precision-recall curve?
Acknowledging the trainning and validating process has plotted the figures for me, but my boss wants to do it manually to understand the model.
I want to retrieve 3 lists precision, recall, and threshold for each conf value changes to draw precision-recall curve and get optimal threshold that we need
Thanks