diff --git a/utils/utils.py b/utils/utils.py index 91ac10cf..fa24b07f 100755 --- a/utils/utils.py +++ b/utils/utils.py @@ -256,10 +256,11 @@ def compute_loss(p, targets): # predictions, targets for i, pi0 in enumerate(p): # layer i predictions, i b, a, gj, gi = indices[i] # image, anchor, gridx, gridy tconf = torch.zeros_like(pi0[..., 0]) # conf + nt = len(b) # number of targets # Compute losses - k = 1 # nT / bs - if len(b) > 0: + k = 1 # nt / bs + if nt: pi = pi0[b, a, gj, gi] # predictions closest to anchors tconf[b, a, gj, gi] = 1 # conf