Add val.py no label warning (#8782)

Help resolve confusion around zero-metrics val.py results when no labels are found in https://github.com/ultralytics/yolov5/issues/8753
pull/8747/head^2
Glenn Jocher 2022-07-29 14:45:29 +02:00 committed by GitHub
parent 567397d67a
commit e309a85586
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

2
val.py
View File

@ -275,6 +275,8 @@ def run(
# Print results
pf = '%20s' + '%11i' * 2 + '%11.3g' * 4 # print format
LOGGER.info(pf % ('all', seen, nt.sum(), mp, mr, map50, map))
if nt.sum() == 0:
LOGGER.warning(emojis(f'WARNING: no labels found in {task} set, can not compute metrics without labels ⚠️'))
# Print results per class
if (verbose or (nc < 50 and not training)) and nc > 1 and len(stats):