diff --git a/test.py b/test.py index 6e4d4654..4f70d297 100644 --- a/test.py +++ b/test.py @@ -69,8 +69,9 @@ def test( inf_out, train_out = model(imgs) # inference and training outputs # Compute loss - loss_i, _ = compute_loss(train_out, targets, model) - loss += loss_i.item() + if hasattr(model, 'hyp'): # if model has loss hyperparameters + loss_i, _ = compute_loss(train_out, targets, model) + loss += loss_i.item() # Run NMS output = non_max_suppression(inf_out, conf_thres=conf_thres, nms_thres=nms_thres)