licence_plate_detection_with_OCR / training_epoch_accuracy_visulizer.py
upadhyaysuraj's picture
Upload 11 files
57d8fc8 verified
import pandas as pd
import matplotlib.pyplot as plt
def plot_training_results(csv_path):
"""
Plots the training accuracy over epochs from the training results CSV file.
Parameters:
csv_path (str): Path to the training results CSV file.
"""
# Load the training results from the CSV file
results = pd.read_csv(csv_path)
results.columns = results.columns.str.strip() # Remove any leading/trailing whitespace from column names
# Extract epochs and accuracy metrics
epochs = results.index + 1 # Epochs are zero-indexed, so add 1
mAP_0_5 = results['metrics/mAP50(B)'] # Mean Average Precision at IoU=0.5
mAP_0_5_0_95 = results['metrics/mAP50-95(B)'] # Mean Average Precision at IoU=0.5:0.95
# Plot the accuracy over epochs
plt.figure(figsize=(10, 5))
plt.plot(epochs, mAP_0_5, label='mAP@0.5')
plt.plot(epochs, mAP_0_5_0_95, label='mAP@0.5:0.95')
plt.xlabel('Epoch')
plt.ylabel('Accuracy')
plt.title('Accuracy Over Epochs')
plt.legend()
plt.grid(True)
plt.show()
if __name__ == "__main__":
plot_training_results('runs/detect/train/results.csv')