(k)
| 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='') |
no outgoing calls
no test coverage detected