diff --git a/test.py b/test.py index b1d9819d..75d527ca 100644 --- a/test.py +++ b/test.py @@ -181,8 +181,14 @@ def test(cfg, for i, c in enumerate(ap_class): print(pf % (names[c], seen, nt[c], p[i], r[i], ap[i], f1[i])) + # Print speeds + if verbose: + t = tuple(x / seen * 1E3 for x in (t0, t1, t0 + t1)) + (img_size, img_size, batch_size) # tuple + print('Speed: %.1f/%.1f/%.1f ms inference/NMS/total per %gx%g image at batch-size %g' % t) + # Save JSON if save_json and map and len(jdict): + print('COCO mAP with pycocotools...') imgIds = [int(Path(x).stem.split('_')[-1]) for x in dataloader.dataset.img_files] with open('results.json', 'w') as file: json.dump(jdict, file) @@ -204,11 +210,6 @@ def test(cfg, cocoEval.summarize() mf1, map = cocoEval.stats[:2] # update to pycocotools results (mAP@0.5:0.95, mAP@0.5) - # Print speeds - if verbose: - t = tuple(x / seen * 1E3 for x in (t0, t1, t0 + t1)) + (img_size, img_size, batch_size) # tuple - print('Speed: %.1f/%.1f/%.1f ms inference/NMS/total per %gx%g image at batch-size %g' % t) - # Return results maps = np.zeros(nc) + map for i, c in enumerate(ap_class):