diff --git a/utils/utils.py b/utils/utils.py index cb105ed6..be47c775 100755 --- a/utils/utils.py +++ b/utils/utils.py @@ -748,13 +748,12 @@ def plot_evolution_results(hyp): # from utils.utils import *; plot_evolution_re plt.savefig('evolve.png', dpi=200) -def plot_results(start=0, stop=0): # from utils.utils import *; plot_results2() +def plot_results(start=0, stop=0): # from utils.utils import *; plot_results() # Plot training results files 'results*.txt' - fig, ax = plt.subplots(2, 5, figsize=(14, 7)) ax = ax.ravel() s = ['GIoU', 'Confidence', 'Classification', 'Precision', 'Recall', - 'GIoU val', 'val Confidence', 'val Classification', 'mAP', 'F1'] + 'val GIoU', 'val Confidence', 'val Classification', 'mAP', 'F1'] for f in sorted(glob.glob('results*.txt') + glob.glob('../../Downloads/results*.txt')): results = np.loadtxt(f, usecols=[2, 4, 5, 9, 10, 13, 14, 15, 11, 12]).T n = results.shape[1] # number of rows @@ -767,14 +766,32 @@ def plot_results(start=0, stop=0): # from utils.utils import *; plot_results2() fig.savefig('results.png', dpi=200) +def plot_results_overlay(start=0, stop=0): # from utils.utils import *; plot_results_overlay() + # Plot training results files 'results*.txt', overlaying train and val losses + fig, ax = plt.subplots(1, 5, figsize=(14, 3.5)) + ax = ax.ravel() + s = ['train', 'train', 'train', 'Precision', 'mAP', 'val', 'val', 'val', 'Recall', 'F1'] # legends + t = ['GIoU', 'Confidence', 'Classification', 'P-R', 'mAP-F1'] # titles + for f in sorted(glob.glob('results*.txt') + glob.glob('../../Downloads/results*.txt')): + results = np.loadtxt(f, usecols=[2, 4, 5, 9, 11, 13, 14, 15, 10, 12]).T + n = results.shape[1] # number of rows + x = range(start, min(stop, n) if stop else n) + for i in range(5): + ax[i].plot(x, results[i, x], marker='.', label=s[i]) + ax[i].plot(x, results[i+5, x], marker='.', label=s[i+5]) + ax[i].set_title(t[i]) + ax[i].legend() + fig.tight_layout() + fig.savefig('results.png', dpi=200) + + def plot_results_orig(start=0, stop=0): # from utils.utils import *; plot_results_orig() # Plot training results files 'results*.txt' in original format - fig, ax = plt.subplots(2, 5, figsize=(14, 7)) ax = ax.ravel() s = ['GIoU/XY', 'Width/Height', 'Confidence', 'Classification', 'Train Loss', 'Precision', 'Recall', 'mAP', 'F1', 'Test Loss'] - for f in sorted(glob.glob('results*.txt') + glob.glob('../../Downloads/results*.txt')): + for f in sorted(glob.glob('results*.txt') + glob.glob('../../Google Drive/results*.txt')): results = np.loadtxt(f, usecols=[2, 3, 4, 5, 6, 9, 10, 11, 12, 13]).T n = results.shape[1] # number of rows x = range(start, min(stop, n) if stop else n)