MCPcopy
hub / github.com/ultralytics/yolov5 / main

Function main

val.py:371–401  ·  view source on GitHub ↗
(opt)

Source from the content-addressed store, hash-verified

369
370
371def main(opt):
372 check_requirements(exclude=('tensorboard', 'thop'))
373
374 if opt.task in ('train', 'val', 'test'): # run normally
375 if opt.conf_thres > 0.001: # https://github.com/ultralytics/yolov5/issues/1466
376 LOGGER.info(f'WARNING ⚠️ confidence threshold {opt.conf_thres} > 0.001 produces invalid results')
377 if opt.save_hybrid:
378 LOGGER.info('WARNING ⚠️ --save-hybrid will return high mAP from hybrid labels, not from predictions alone')
379 run(**vars(opt))
380
381 else:
382 weights = opt.weights if isinstance(opt.weights, list) else [opt.weights]
383 opt.half = torch.cuda.is_available() and opt.device != 'cpu' # FP16 for fastest results
384 if opt.task == 'speed': # speed benchmarks
385 # python val.py --task speed --data coco.yaml --batch 1 --weights yolov5n.pt yolov5s.pt...
386 opt.conf_thres, opt.iou_thres, opt.save_json = 0.25, 0.45, False
387 for opt.weights in weights:
388 run(**vars(opt), plots=False)
389
390 elif opt.task == 'study': # speed vs mAP benchmarks
391 # python val.py --task study --data coco.yaml --iou 0.7 --weights yolov5n.pt yolov5s.pt...
392 for opt.weights in weights:
393 f = f'study_{Path(opt.data).stem}_{Path(opt.weights).stem}.txt' # filename to save to
394 x, y = list(range(256, 1536 + 128, 128)), [] # x axis (image sizes), y axis
395 for opt.imgsz in x: # img-size
396 LOGGER.info(f'\nRunning {f} --imgsz {opt.imgsz}...')
397 r, _, t = run(**vars(opt), plots=False)
398 y.append(r + t) # results and times
399 np.savetxt(f, y, fmt='%10.4g') # save
400 os.system('zip -r study.zip study_*.txt')
401 plot_val_study(x=x) # plot
402
403
404if __name__ == "__main__":

Callers 1

val.pyFile · 0.70

Calls 4

check_requirementsFunction · 0.90
plot_val_studyFunction · 0.90
infoMethod · 0.80
runFunction · 0.70

Tested by

no test coverage detected