glenn-jocher
commited on
Commit
•
63ddb6f
1
Parent(s):
c2403eb
Update autoanchor.py (#6794)
Browse files* Update autoanchor.py
* Update autoanchor.py
- utils/autoanchor.py +4 -3
utils/autoanchor.py
CHANGED
@@ -57,9 +57,10 @@ def check_anchors(dataset, model, thr=4.0, imgsz=640):
|
|
57 |
anchors = torch.tensor(anchors, device=m.anchors.device).type_as(m.anchors)
|
58 |
m.anchors[:] = anchors.clone().view_as(m.anchors) / m.stride.to(m.anchors.device).view(-1, 1, 1) # loss
|
59 |
check_anchor_order(m)
|
60 |
-
|
61 |
else:
|
62 |
-
|
|
|
63 |
|
64 |
|
65 |
def kmean_anchors(dataset='./data/coco128.yaml', n=9, img_size=640, thr=4.0, gen=1000, verbose=True):
|
@@ -120,7 +121,7 @@ def kmean_anchors(dataset='./data/coco128.yaml', n=9, img_size=640, thr=4.0, gen
|
|
120 |
# Filter
|
121 |
i = (wh0 < 3.0).any(1).sum()
|
122 |
if i:
|
123 |
-
LOGGER.info(f'{PREFIX}WARNING: Extremely small objects found
|
124 |
wh = wh0[(wh0 >= 2.0).any(1)] # filter > 2 pixels
|
125 |
# wh = wh * (npr.rand(wh.shape[0], 1) * 0.9 + 0.1) # multiply by random scale 0-1
|
126 |
|
|
|
57 |
anchors = torch.tensor(anchors, device=m.anchors.device).type_as(m.anchors)
|
58 |
m.anchors[:] = anchors.clone().view_as(m.anchors) / m.stride.to(m.anchors.device).view(-1, 1, 1) # loss
|
59 |
check_anchor_order(m)
|
60 |
+
s = f'{PREFIX}Done ✅ (optional: update model *.yaml to use these anchors in the future)'
|
61 |
else:
|
62 |
+
s = f'{PREFIX}Done ⚠️ (original anchors better than new anchors, proceeding with original anchors)'
|
63 |
+
LOGGER.info(emojis(s))
|
64 |
|
65 |
|
66 |
def kmean_anchors(dataset='./data/coco128.yaml', n=9, img_size=640, thr=4.0, gen=1000, verbose=True):
|
|
|
121 |
# Filter
|
122 |
i = (wh0 < 3.0).any(1).sum()
|
123 |
if i:
|
124 |
+
LOGGER.info(f'{PREFIX}WARNING: Extremely small objects found: {i} of {len(wh0)} labels are < 3 pixels in size')
|
125 |
wh = wh0[(wh0 >= 2.0).any(1)] # filter > 2 pixels
|
126 |
# wh = wh * (npr.rand(wh.shape[0], 1) * 0.9 + 0.1) # multiply by random scale 0-1
|
127 |
|