-
-
Notifications
You must be signed in to change notification settings - Fork 17.2k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Search before asking
- I have searched the YOLOv5 issues and found no similar bug report.
YOLOv5 Component
Validation
Bug
The problem exists on images on which the model has not made a prediction.
Then the following lines are called:
Lines 228 to 231 in 29d79a6
if npr == 0: | |
if nl: | |
stats.append((correct, *torch.zeros((3, 0), device=device))) | |
continue |
The problem now is that when the tcls array is calculated here:
Line 264 in 29d79a6
stats = [torch.cat(x, 0).cpu().numpy() for x in zip(*stats)] # to numpy |
, these labels are not taken into account. This results in a wrong AP calculation because the number of total positives is wrong. In the example shown below, the length of tcls should be 4, but it is only 1.
Environment
YOLOv5
torch 1.11 and torch 1.12
python 3.8
Minimal Reproducible Example
stats = list()
device = 'cpu'
correct = torch.zeros(1, 10, dtype=torch.bool, device=device)
stats.append((correct, *torch.zeros((3, 1), device=device)))
for _ in range(3):
correct = torch.zeros(0, 10, dtype=torch.bool, device=device)
stats.append((correct, *torch.zeros((3, 0), device=device)))
[torch.cat(x, 0).cpu().numpy() for x in zip(*stats)]
Additional
Possible Solutionin line 230 in val.py:
stats.append((correct, *torch.zeros((2, 0), device=device), labels[:, 0]))
Are you willing to submit a PR?
- Yes I'd like to help by submitting a PR!
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working