This commit is contained in:
Glenn Jocher 2019-10-05 18:36:48 +02:00
parent 8c7a8ffecb
commit bfcae0ac97
1 changed files with 2 additions and 3 deletions

View File

@ -657,7 +657,7 @@ def kmeans_targets(path='../coco/trainvalno5k.txt', n=9, img_size=416): # from
from scipy import cluster from scipy import cluster
# Get label wh # Get label wh
dataset = LoadImagesAndLabels(path, augment=True, rect=True) dataset = LoadImagesAndLabels(path, augment=True, rect=True, cache_labels=True)
for s, l in zip(dataset.shapes, dataset.labels): for s, l in zip(dataset.shapes, dataset.labels):
l[:, [1, 3]] *= s[0] # normalized to pixels l[:, [1, 3]] *= s[0] # normalized to pixels
l[:, [2, 4]] *= s[1] l[:, [2, 4]] *= s[1]
@ -671,8 +671,7 @@ def kmeans_targets(path='../coco/trainvalno5k.txt', n=9, img_size=416): # from
# Measure IoUs # Measure IoUs
iou = torch.stack([wh_iou(torch.Tensor(wh).T, torch.Tensor(x).T) for x in k], 0) iou = torch.stack([wh_iou(torch.Tensor(wh).T, torch.Tensor(x).T) for x in k], 0)
biou = iou.max(0)[0] # closest anchor IoU biou = iou.max(0)[0] # closest anchor IoU
print('Best possible recall: %.3f' % (biou > 0.2635).float().mean()) # BPR (best possible recall)
print((biou < 0.2635).float().mean())
# Print # Print
print('kmeans anchors (n=%g, img_size=%g, IoU=%.2f/%.2f/%.2f-min/mean/best): ' % print('kmeans anchors (n=%g, img_size=%g, IoU=%.2f/%.2f/%.2f-min/mean/best): ' %