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 bec9017..f491032 100644 --- a/utils/autoanchor.py +++ b/utils/autoanchor.py @@ -51,8 +51,8 @@ def check_anchors(dataset, model, thr=4.0, imgsz=640): 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.')