glenn-jocher commited on
Commit
1dfc285
·
1 Parent(s): 8db51c7

AutoAnchor BPR to 4 significant figures

Browse files
Files changed (1) hide show
  1. utils/utils.py +2 -2
utils/utils.py CHANGED
@@ -66,7 +66,7 @@ def check_anchors(dataset, model, thr=4.0, imgsz=640):
66
  return (best > 1. / thr).float().mean() #  best possible recall
67
 
68
  bpr = metric(anchors.clone().cpu().view(-1, 2))
69
- print('Best Possible Recall (BPR) = %.3f' % bpr, end='')
70
  if bpr < 0.99: # threshold to recompute
71
  print('. Attempting to generate improved anchors, please wait...' % bpr)
72
  new_anchors = kmean_anchors(dataset, n=9, img_size=640, thr=4.0, gen=1000, verbose=False)
@@ -733,7 +733,7 @@ def kmean_anchors(path='./data/coco128.yaml', n=9, img_size=640, thr=4.0, gen=10
733
  k = k[np.argsort(k.prod(1))] # sort small to large
734
  x, best = metric(k, wh0)
735
  bpr, aat = (best > thr).float().mean(), (x > thr).float().mean() * n # best possible recall, anch > thr
736
- print('thr=%.2f: %.3f best possible recall, %.2f anchors past thr' % (thr, bpr, aat))
737
  print('n=%g, img_size=%s, metric_all=%.3f/%.3f-mean/best, past_thr=%.3f-mean: ' %
738
  (n, img_size, x.mean(), best.mean(), x[x > thr].mean()), end='')
739
  for i, x in enumerate(k):
 
66
  return (best > 1. / thr).float().mean() #  best possible recall
67
 
68
  bpr = metric(anchors.clone().cpu().view(-1, 2))
69
+ print('Best Possible Recall (BPR) = %.4f' % bpr, end='')
70
  if bpr < 0.99: # threshold to recompute
71
  print('. Attempting to generate improved anchors, please wait...' % bpr)
72
  new_anchors = kmean_anchors(dataset, n=9, img_size=640, thr=4.0, gen=1000, verbose=False)
 
733
  k = k[np.argsort(k.prod(1))] # sort small to large
734
  x, best = metric(k, wh0)
735
  bpr, aat = (best > thr).float().mean(), (x > thr).float().mean() * n # best possible recall, anch > thr
736
+ print('thr=%.2f: %.4f best possible recall, %.2f anchors past thr' % (thr, bpr, aat))
737
  print('n=%g, img_size=%s, metric_all=%.3f/%.3f-mean/best, past_thr=%.3f-mean: ' %
738
  (n, img_size, x.mean(), best.mean(), x[x > thr].mean()), end='')
739
  for i, x in enumerate(k):