NauchtanRobotics glenn-jocher commited on
Commit
0be58f1
·
unverified ·
1 Parent(s): 1172ac1

Adjust legend labels for classes without instances (#5174)

Browse files

* legend-labels Adjust legend labels for classes without instances.

* #5158 Re-indexed series names: only classes containing data.

* #5158 Re-indexed series names: only classes containing data.

* Cleanup

Co-authored-by: Glenn Jocher <[email protected]>

Files changed (1) hide show
  1. utils/metrics.py +2 -0
utils/metrics.py CHANGED
@@ -71,6 +71,8 @@ def ap_per_class(tp, conf, pred_cls, target_cls, plot=False, save_dir='.', names
71
 
72
  # Compute F1 (harmonic mean of precision and recall)
73
  f1 = 2 * p * r / (p + r + 1e-16)
 
 
74
  if plot:
75
  plot_pr_curve(px, py, ap, Path(save_dir) / 'PR_curve.png', names)
76
  plot_mc_curve(px, f1, Path(save_dir) / 'F1_curve.png', names, ylabel='F1')
 
71
 
72
  # Compute F1 (harmonic mean of precision and recall)
73
  f1 = 2 * p * r / (p + r + 1e-16)
74
+ names = [v for k, v in names.items() if k in unique_classes] # list: only classes that have data
75
+ names = {i: v for i, v in enumerate(names)} # to dict
76
  if plot:
77
  plot_pr_curve(px, py, ap, Path(save_dir) / 'PR_curve.png', names)
78
  plot_mc_curve(px, f1, Path(save_dir) / 'F1_curve.png', names, ylabel='F1')