Skip to content

Commit be348cc

Browse files
authored
Validate --task speed CPU fix (#10244)
1 parent 72cad39 commit be348cc

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

segment/val.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ def main(opt):
444444

445445
else:
446446
weights = opt.weights if isinstance(opt.weights, list) else [opt.weights]
447-
opt.half = True # FP16 for fastest results
447+
opt.half = torch.cuda.is_available() and opt.device != 'cpu' # FP16 for fastest results
448448
if opt.task == 'speed': # speed benchmarks
449449
# python val.py --task speed --data coco.yaml --batch 1 --weights yolov5n.pt yolov5s.pt...
450450
opt.conf_thres, opt.iou_thres, opt.save_json = 0.25, 0.45, False

val.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ def main(opt):
380380

381381
else:
382382
weights = opt.weights if isinstance(opt.weights, list) else [opt.weights]
383-
opt.half = True # FP16 for fastest results
383+
opt.half = torch.cuda.is_available() and opt.device != 'cpu' # FP16 for fastest results
384384
if opt.task == 'speed': # speed benchmarks
385385
# python val.py --task speed --data coco.yaml --batch 1 --weights yolov5n.pt yolov5s.pt...
386386
opt.conf_thres, opt.iou_thres, opt.save_json = 0.25, 0.45, False

0 commit comments

Comments
 (0)