From 6deda823840d13b9dfc7b04c38dd75be5b2e4ac6 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Mon, 18 Feb 2019 14:03:39 +0100 Subject: [PATCH] updates --- test.py | 6 +++--- utils/datasets.py | 8 ++++---- utils/utils.py | 7 ++++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/test.py b/test.py index b6c57f2d..21c9b461 100644 --- a/test.py +++ b/test.py @@ -103,15 +103,15 @@ def test( mean_R = np.mean(mR) mean_P = np.mean(mP) - # Print image mAP and running mean mAP - print(('%11s%11s' + '%11.3g' * 3) % (len(mAPs), dataloader.nF, mean_P, mean_R, mean_mAP)) + # Print image mAP and running mean mAP + print(('%11s%11s' + '%11.3g' * 3) % (len(mAPs), dataloader.nF, mean_P, mean_R, mean_mAP)) # Print mAP per class print('%11s' * 5 % ('Image', 'Total', 'P', 'R', 'mAP') + '\n\nmAP Per Class:') classes = load_classes(data_cfg_dict['names']) # Extracts class labels from file for i, c in enumerate(classes): - print('%15s: %-.4f' % (c, AP_accum[i] / AP_accum_count[i])) + print('%15s: %-.4f' % (c, AP_accum[i] / (AP_accum_count[i] + 1E-16))) # Return mAP return mean_mAP, mean_R, mean_P diff --git a/utils/datasets.py b/utils/datasets.py index d934915c..17ebbfad 100755 --- a/utils/datasets.py +++ b/utils/datasets.py @@ -91,13 +91,13 @@ class LoadWebcam: # for inference class LoadImagesAndLabels: # for training def __init__(self, path, batch_size=1, img_size=608, multi_scale=False, augment=False): - self.path = path with open(path, 'r') as file: self.img_files = file.readlines() + self.img_files = [x.replace('\n', '') for x in self.img_files] + self.img_files = list(filter(lambda x: len(x) > 0, self.img_files)) - self.img_files = [path.replace('\n', '') for path in self.img_files] - self.label_files = [path.replace('images', 'labels').replace('.png', '.txt').replace('.jpg', '.txt') - for path in self.img_files] + self.label_files = [x.replace('images', 'labels').replace('.png', '.txt').replace('.jpg', '.txt') + for x in self.img_files] self.nF = len(self.img_files) # number of image files self.nB = math.ceil(self.nF / batch_size) # number of batches diff --git a/utils/utils.py b/utils/utils.py index 45060b3f..851d98b6 100755 --- a/utils/utils.py +++ b/utils/utils.py @@ -438,13 +438,14 @@ def plot_results(): # Plot YOLO training results file 'results.txt' import glob import matplotlib.pyplot as plt + import numpy as np # import os; os.system('rm -rf results.txt && wget https://storage.googleapis.com/ultralytics/results_v1_0.txt') plt.figure(figsize=(16, 8)) - s = ['X', 'Y', 'Width', 'Height', 'Objectness', 'Classification', 'Total Loss', 'Precision', 'Recall', 'mAP'] - files = sorted(glob.glob('results*.txt')) + s = ['X', 'Y', 'Width', 'Height', 'Confidence', 'Classification', 'Total Loss', 'mAP', 'Recall', 'Precision'] + files = sorted(glob.glob('results.txt')) for f in files: - results = np.loadtxt(f, usecols=[2, 3, 4, 5, 6, 7, 8, 17, 18, 16]).T # column 16 is mAP + results = np.loadtxt(f, usecols=[2, 3, 4, 5, 6, 7, 8, 11, 12, 13]).T # column 13 is mAP n = results.shape[1] for i in range(10): plt.subplot(2, 5, i + 1)