|
|
@@ -1,5 +1,7 @@ |
|
|
|
# Auto-anchor utils |
|
|
|
|
|
|
|
import random |
|
|
|
|
|
|
|
import numpy as np |
|
|
|
import torch |
|
|
|
import yaml |
|
|
@@ -149,7 +151,7 @@ def kmean_anchors(path='./data/coco128.yaml', n=9, img_size=640, thr=4.0, gen=10 |
|
|
|
for _ in pbar: |
|
|
|
v = np.ones(sh) |
|
|
|
while (v == 1).all(): # mutate until a change occurs (prevent duplicates) |
|
|
|
v = ((npr.random(sh) < mp) * npr.random() * npr.randn(*sh) * s + 1).clip(0.3, 3.0) |
|
|
|
v = ((npr.random(sh) < mp) * random.random() * npr.randn(*sh) * s + 1).clip(0.3, 3.0) |
|
|
|
kg = (k.copy() * v).clip(min=2.0) |
|
|
|
fg = anchor_fitness(kg) |
|
|
|
if fg > f: |