This commit is contained in:
Glenn Jocher 2019-08-15 16:57:17 +02:00
parent 4f78eec83e
commit be7f4fa72f
1 changed files with 9 additions and 6 deletions

View File

@ -594,13 +594,16 @@ def kmeans_targets(path='data/coco_64img.txt', n=9, img_size=416): # from utils
# 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)
miou = iou.mean() # mean IoU with all anchors biou = iou.max(0)[0] # closest anchor IoU
biou = iou.max(0)[0].mean() # mean IoU with the closest anchor
# Print results # Print
print('kmeans anchors (n=%g, img_size=%g, IoU=%.2f/%.2f mean/best): ' % (n, img_size, miou, biou), end='') print('kmeans anchors (n=%g, img_size=%g, IoU=%.2f/%.2f/%.2f-min/mean/best): ' %
for x in k.ravel(): (n, img_size, biou.min(), iou.mean(), biou.mean()), end='')
print('%.1f, ' % x, end='') # drop-in replacement for *.cfg anchors for i, x in enumerate(k):
print('%i,%i' % (round(x[0]), round(x[1])), end=', ' if i < len(k) - 1 else '\n') # use in *.cfg
# Plot
# plt.hist(biou.numpy().ravel(), 100)
def print_mutation(hyp, results, bucket=''): def print_mutation(hyp, results, bucket=''):