This commit is contained in:
Glenn Jocher 2019-04-05 15:51:06 +02:00
parent fe896c1792
commit 325b1ba4bc
1 changed files with 5 additions and 4 deletions

View File

@ -54,7 +54,7 @@ def test(
seen = 0 seen = 0
model.eval() model.eval()
coco91class = coco80_to_coco91_class() coco91class = coco80_to_coco91_class()
print('%15s' * 7 % ('Class', 'Images', 'Targets', 'P', 'R', 'mAP', 'F1')) print(('%20s' + '%10s' * 6) % ('Class', 'Images', 'Targets', 'P', 'R', 'mAP', 'F1'))
loss, p, r, f1, mp, mr, map, mf1 = 0., 0., 0., 0., 0., 0., 0., 0. loss, p, r, f1, mp, mr, map, mf1 = 0., 0., 0., 0., 0., 0., 0., 0.
jdict, stats, ap, ap_class = [], [], [], [] jdict, stats, ap, ap_class = [], [], [], []
for batch_i, (imgs, targets, paths, shapes) in enumerate(tqdm(dataloader, desc='Computing mAP')): for batch_i, (imgs, targets, paths, shapes) in enumerate(tqdm(dataloader, desc='Computing mAP')):
@ -137,12 +137,13 @@ def test(
mp, mr, map, mf1 = p.mean(), r.mean(), ap.mean(), f1.mean() mp, mr, map, mf1 = p.mean(), r.mean(), ap.mean(), f1.mean()
# Print results # Print results
print(('%15s' + '%15.3g' * 6) % ('all', seen, nt.sum(), mp, mr, map, mf1), end='\n\n') pf = ('%20s' + '%10.3g' * 6) # print format
print(pf % ('all', seen, nt.sum(), mp, mr, map, mf1), end='\n\n')
# Print results per class # Print results per class
if nc > 1 and len(stats_np): if nc > 1 and len(stats_np):
for i, c in enumerate(ap_class): for i, c in enumerate(ap_class):
print(('%15s' + '%15.3g' * 6) % (names[c], seen, nt[c], p[i], r[i], ap[i], f1[i])) print(pf % (names[c], seen, nt[c], p[i], r[i], ap[i], f1[i]))
# Save JSON # Save JSON
if save_json and map and len(jdict): if save_json and map and len(jdict):
@ -172,7 +173,7 @@ if __name__ == '__main__':
parser = argparse.ArgumentParser(prog='test.py') parser = argparse.ArgumentParser(prog='test.py')
parser.add_argument('--batch-size', type=int, default=32, help='size of each image batch') parser.add_argument('--batch-size', type=int, default=32, help='size of each image batch')
parser.add_argument('--cfg', type=str, default='cfg/yolov3-spp.cfg', help='cfg file path') parser.add_argument('--cfg', type=str, default='cfg/yolov3-spp.cfg', help='cfg file path')
parser.add_argument('--data-cfg', type=str, default='data/coco.data', help='coco.data file path') parser.add_argument('--data-cfg', type=str, default='data/coco_10img.data', help='coco.data file path')
parser.add_argument('--weights', type=str, default='weights/yolov3-spp.weights', help='path to weights file') parser.add_argument('--weights', type=str, default='weights/yolov3-spp.weights', help='path to weights file')
parser.add_argument('--iou-thres', type=float, default=0.5, help='iou threshold required to qualify as detected') parser.add_argument('--iou-thres', type=float, default=0.5, help='iou threshold required to qualify as detected')
parser.add_argument('--conf-thres', type=float, default=0.001, help='object confidence threshold') parser.add_argument('--conf-thres', type=float, default=0.001, help='object confidence threshold')