From 3708cdedd2d9348d2c2c0588f62bb1fe574cd1ec Mon Sep 17 00:00:00 2001 From: "Kin-Yiu, Wong" <102582011@cc.ncu.edu.tw> Date: Tue, 9 Aug 2022 20:06:36 +0800 Subject: [PATCH] main code update anchor https://github.com/WongKinYiu/yolov7/issues/272 --- utils/autoanchor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/autoanchor.py b/utils/autoanchor.py index bec9017711..f491032e53 100644 --- a/utils/autoanchor.py +++ b/utils/autoanchor.py @@ -51,8 +51,8 @@ def metric(k): # compute metric if new_bpr > bpr: # replace anchors anchors = torch.tensor(anchors, device=m.anchors.device).type_as(m.anchors) m.anchor_grid[:] = anchors.clone().view_as(m.anchor_grid) # for inference - m.anchors[:] = anchors.clone().view_as(m.anchors) / m.stride.to(m.anchors.device).view(-1, 1, 1) # loss check_anchor_order(m) + m.anchors[:] = anchors.clone().view_as(m.anchors) / m.stride.to(m.anchors.device).view(-1, 1, 1) # loss print(f'{prefix}New anchors saved to model. Update model *.yaml to use these anchors in the future.') else: print(f'{prefix}Original anchors better than new anchors. Proceeding with original anchors.')