This commit is contained in:
Glenn Jocher 2019-02-18 14:03:39 +01:00
parent 03685866fd
commit 6deda82384
3 changed files with 11 additions and 10 deletions

View File

@ -103,15 +103,15 @@ def test(
mean_R = np.mean(mR) mean_R = np.mean(mR)
mean_P = np.mean(mP) mean_P = np.mean(mP)
# Print image mAP and running 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(('%11s%11s' + '%11.3g' * 3) % (len(mAPs), dataloader.nF, mean_P, mean_R, mean_mAP))
# Print mAP per class # Print mAP per class
print('%11s' * 5 % ('Image', 'Total', 'P', 'R', 'mAP') + '\n\nmAP 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 classes = load_classes(data_cfg_dict['names']) # Extracts class labels from file
for i, c in enumerate(classes): 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 mAP
return mean_mAP, mean_R, mean_P return mean_mAP, mean_R, mean_P

View File

@ -91,13 +91,13 @@ class LoadWebcam: # for inference
class LoadImagesAndLabels: # for training class LoadImagesAndLabels: # for training
def __init__(self, path, batch_size=1, img_size=608, multi_scale=False, augment=False): def __init__(self, path, batch_size=1, img_size=608, multi_scale=False, augment=False):
self.path = path
with open(path, 'r') as file: with open(path, 'r') as file:
self.img_files = file.readlines() 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 = [x.replace('images', 'labels').replace('.png', '.txt').replace('.jpg', '.txt')
self.label_files = [path.replace('images', 'labels').replace('.png', '.txt').replace('.jpg', '.txt') for x in self.img_files]
for path in self.img_files]
self.nF = len(self.img_files) # number of image files self.nF = len(self.img_files) # number of image files
self.nB = math.ceil(self.nF / batch_size) # number of batches self.nB = math.ceil(self.nF / batch_size) # number of batches

View File

@ -438,13 +438,14 @@ def plot_results():
# Plot YOLO training results file 'results.txt' # Plot YOLO training results file 'results.txt'
import glob import glob
import matplotlib.pyplot as plt 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') # import os; os.system('rm -rf results.txt && wget https://storage.googleapis.com/ultralytics/results_v1_0.txt')
plt.figure(figsize=(16, 8)) plt.figure(figsize=(16, 8))
s = ['X', 'Y', 'Width', 'Height', 'Objectness', 'Classification', 'Total Loss', 'Precision', 'Recall', 'mAP'] s = ['X', 'Y', 'Width', 'Height', 'Confidence', 'Classification', 'Total Loss', 'mAP', 'Recall', 'Precision']
files = sorted(glob.glob('results*.txt')) files = sorted(glob.glob('results.txt'))
for f in files: 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] n = results.shape[1]
for i in range(10): for i in range(10):
plt.subplot(2, 5, i + 1) plt.subplot(2, 5, i + 1)