glenn-jocher commited on
Commit
e309a85
·
unverified ·
1 Parent(s): 567397d

Add val.py no label warning (#8782)

Browse files

Help resolve confusion around zero-metrics val.py results when no labels are found in https://github.com/ultralytics/yolov5/issues/8753

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