From 1158a50abd78808049327fdf60724b2b32726d88 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sun, 2 Oct 2022 13:37:54 +0200 Subject: [PATCH] Simplify val.py benchmark mode with speed mode (#9674) Update --- benchmarks.py | 4 ++-- segment/val.py | 3 +-- val.py | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/benchmarks.py b/benchmarks.py index b3b58eb3257c..ef5c882973f0 100644 --- a/benchmarks.py +++ b/benchmarks.py @@ -81,10 +81,10 @@ def run( # Validate if model_type == SegmentationModel: - result = val_seg(data, w, batch_size, imgsz, plots=False, device=device, task='benchmark', half=half) + result = val_seg(data, w, batch_size, imgsz, plots=False, device=device, task='speed', half=half) metric = result[0][7] # (box(p, r, map50, map), mask(p, r, map50, map), *loss(box, obj, cls)) else: # DetectionModel: - result = val_det(data, w, batch_size, imgsz, plots=False, device=device, task='benchmark', half=half) + result = val_det(data, w, batch_size, imgsz, plots=False, device=device, task='speed', half=half) metric = result[0][3] # (p, r, map50, map, *loss(box, obj, cls)) speed = result[2][1] # times (preprocess, inference, postprocess) y.append([name, round(file_size(w), 1), round(metric, 4), round(speed, 2)]) # MB, mAP, t_inference diff --git a/segment/val.py b/segment/val.py index 0a37998c1771..f1ec54638d61 100644 --- a/segment/val.py +++ b/segment/val.py @@ -210,8 +210,7 @@ def run( assert ncm == nc, f'{weights} ({ncm} classes) trained on different --data than what you passed ({nc} ' \ f'classes). Pass correct combination of --weights and --data that are trained together.' model.warmup(imgsz=(1 if pt else batch_size, 3, imgsz, imgsz)) # warmup - pad = 0.0 if task in ('speed', 'benchmark') else 0.5 - rect = False if task == 'benchmark' else pt # square inference for benchmarks + pad, rect = (0.0, False) if task == 'speed' else (0.5, pt) # square inference for benchmarks task = task if task in ('train', 'val', 'test') else 'val' # path to train/val/test images dataloader = create_dataloader(data[task], imgsz, diff --git a/val.py b/val.py index c0954498d2fb..ca838c0beb2f 100644 --- a/val.py +++ b/val.py @@ -169,8 +169,7 @@ def run( assert ncm == nc, f'{weights} ({ncm} classes) trained on different --data than what you passed ({nc} ' \ f'classes). Pass correct combination of --weights and --data that are trained together.' model.warmup(imgsz=(1 if pt else batch_size, 3, imgsz, imgsz)) # warmup - pad = 0.0 if task in ('speed', 'benchmark') else 0.5 - rect = False if task == 'benchmark' else pt # square inference for benchmarks + pad, rect = (0.0, False) if task == 'speed' else (0.5, pt) # square inference for benchmarks task = task if task in ('train', 'val', 'test') else 'val' # path to train/val/test images dataloader = create_dataloader(data[task], imgsz,