From 9d45f336de08f846f75278268b3ae296377be736 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 30 Jan 2021 15:14:08 -0800 Subject: [PATCH 1/6] Add --speed benchmark --- test.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test.py b/test.py index 22d20f0323e3..b9c866226a22 100644 --- a/test.py +++ b/test.py @@ -321,15 +321,19 @@ def test(data, ) elif opt.task == 'study': # run over a range of settings and save/plot - for weights in ['yolov5s.pt', 'yolov5m.pt', 'yolov5l.pt', 'yolov5x.pt']: - f = 'study_%s_%s.txt' % (Path(opt.data).stem, Path(weights).stem) # filename to save to + for w in opt.weights: + f = 'study_%s_%s.txt' % (Path(opt.data).stem, Path(w).stem) # filename to save to x = list(range(320, 800, 64)) # x axis y = [] # y axis for i in x: # img-size print('\nRunning %s point %s...' % (f, i)) - r, _, t = test(opt.data, weights, opt.batch_size, i, opt.conf_thres, opt.iou_thres, opt.save_json, + r, _, t = test(opt.data, w, opt.batch_size, i, opt.conf_thres, opt.iou_thres, opt.save_json, plots=False) y.append(r + t) # results and times np.savetxt(f, y, fmt='%10.4g') # save os.system('zip -r study.zip study_*.txt') plot_study_txt(f, x) # plot + + elif opt.task == 'speed': # speed benchmarks + for w in opt.weights: + test(opt.data, w, opt.batch_size, opt.img_size, 0.25, 0.45, save_json=False, plots=False) From 099e0e2a4cac36d383bee105d05c87f5a3da58d4 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 30 Jan 2021 20:27:42 -0800 Subject: [PATCH 2/6] test range 256 - 1536 --- test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.py b/test.py index b9c866226a22..0ed7741573bc 100644 --- a/test.py +++ b/test.py @@ -323,7 +323,7 @@ def test(data, elif opt.task == 'study': # run over a range of settings and save/plot for w in opt.weights: f = 'study_%s_%s.txt' % (Path(opt.data).stem, Path(w).stem) # filename to save to - x = list(range(320, 800, 64)) # x axis + x = list(range(256, 1536 + 128, 128)) # x axis y = [] # y axis for i in x: # img-size print('\nRunning %s point %s...' % (f, i)) From 89fdf438bc6f80da5773bcf7373500d1ad36edc7 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sun, 31 Jan 2021 13:43:50 -0800 Subject: [PATCH 3/6] update --- test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.py b/test.py index 0ed7741573bc..e0df3297767e 100644 --- a/test.py +++ b/test.py @@ -321,9 +321,9 @@ def test(data, ) elif opt.task == 'study': # run over a range of settings and save/plot + x = list(range(256, 1536 + 128, 128)) # x axis for w in opt.weights: f = 'study_%s_%s.txt' % (Path(opt.data).stem, Path(w).stem) # filename to save to - x = list(range(256, 1536 + 128, 128)) # x axis y = [] # y axis for i in x: # img-size print('\nRunning %s point %s...' % (f, i)) From 1a507d47d7c0ca062eb8c620098662f42e4e69c2 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sun, 31 Jan 2021 13:48:24 -0800 Subject: [PATCH 4/6] update --- test.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test.py b/test.py index e0df3297767e..82acd93552da 100644 --- a/test.py +++ b/test.py @@ -320,20 +320,20 @@ def test(data, save_conf=opt.save_conf, ) + elif opt.task == 'speed': # speed benchmarks + for w in opt.weights: + test(opt.data, w, opt.batch_size, opt.img_size, 0.25, 0.45, save_json=False, plots=False) + elif opt.task == 'study': # run over a range of settings and save/plot x = list(range(256, 1536 + 128, 128)) # x axis for w in opt.weights: - f = 'study_%s_%s.txt' % (Path(opt.data).stem, Path(w).stem) # filename to save to + f = f'study_{Path(opt.data).stem}_{Path(w).stem}.txt' # filename to save to y = [] # y axis for i in x: # img-size - print('\nRunning %s point %s...' % (f, i)) + print(f'\nRunning {f} point {i}...') r, _, t = test(opt.data, w, opt.batch_size, i, opt.conf_thres, opt.iou_thres, opt.save_json, plots=False) y.append(r + t) # results and times np.savetxt(f, y, fmt='%10.4g') # save os.system('zip -r study.zip study_*.txt') - plot_study_txt(f, x) # plot - - elif opt.task == 'speed': # speed benchmarks - for w in opt.weights: - test(opt.data, w, opt.batch_size, opt.img_size, 0.25, 0.45, save_json=False, plots=False) + plot_study_txt('.', x) # plot From 26bb01d24ef4886d496606875c20574b0decc0d0 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sun, 31 Jan 2021 13:49:15 -0800 Subject: [PATCH 5/6] update --- test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.py b/test.py index 82acd93552da..72f23308d1b4 100644 --- a/test.py +++ b/test.py @@ -325,7 +325,7 @@ def test(data, test(opt.data, w, opt.batch_size, opt.img_size, 0.25, 0.45, save_json=False, plots=False) elif opt.task == 'study': # run over a range of settings and save/plot - x = list(range(256, 1536 + 128, 128)) # x axis + x = list(range(256, 1536 + 128, 128)) # x axis (image sizes) for w in opt.weights: f = f'study_{Path(opt.data).stem}_{Path(w).stem}.txt' # filename to save to y = [] # y axis From 91f7decc3def66c788c7537e1cb503c0a8415662 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sun, 31 Jan 2021 13:52:10 -0800 Subject: [PATCH 6/6] update --- test.py | 2 +- utils/plots.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test.py b/test.py index 72f23308d1b4..738764f15601 100644 --- a/test.py +++ b/test.py @@ -336,4 +336,4 @@ def test(data, y.append(r + t) # results and times np.savetxt(f, y, fmt='%10.4g') # save os.system('zip -r study.zip study_*.txt') - plot_study_txt('.', x) # plot + plot_study_txt(x=x) # plot diff --git a/utils/plots.py b/utils/plots.py index a199963d7d99..7dad3c72e996 100644 --- a/utils/plots.py +++ b/utils/plots.py @@ -223,7 +223,7 @@ def plot_targets_txt(): # from utils.plots import *; plot_targets_txt() plt.savefig('targets.jpg', dpi=200) -def plot_study_txt(path='study/', x=None): # from utils.plots import *; plot_study_txt() +def plot_study_txt(path='', x=None): # from utils.plots import *; plot_study_txt() # Plot study.txt generated by test.py fig, ax = plt.subplots(2, 4, figsize=(10, 6), tight_layout=True) ax = ax.ravel()