MCPcopy
hub / github.com/WongKinYiu/PyTorch_YOLOv4 / metric

Function metric

utils/autoanchor.py:29–35  ·  view source on GitHub ↗
(k)

Source from the content-addressed store, hash-verified

27 wh = torch.tensor(np.concatenate([l[:, 3:5] * s for s, l in zip(shapes * scale, dataset.labels)])).float() # wh
28
29 def metric(k): # compute metric
30 r = wh[:, None] / k[None]
31 x = torch.min(r, 1. / r).min(2)[0] # ratio metric
32 best = x.max(1)[0] # best_x
33 aat = (x > 1. / thr).float().sum(1).mean() # anchors above threshold
34 bpr = (best > 1. / thr).float().mean() # best possible recall
35 return bpr, aat
36
37 bpr, aat = metric(m.anchor_grid.clone().cpu().view(-1, 2))
38 print('anchors/target = %.2f, Best Possible Recall (BPR) = %.4f' % (aat, bpr), end='')

Callers 3

check_anchorsFunction · 0.85
anchor_fitnessFunction · 0.85
print_resultsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected