-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Confusion about num_classes #108
Comments
Hi @dvd42 The explanation you're pointing at was slightly incorrect, I fixed it. I think I have answered your question, and as such I'm closing this. Feel free to reach out if you have further concerns. |
Thanks for fixing my wrong answer @alcinos ! |
Just to be clear about the
>>> labels = torch.randint(1, 91, (4, 11)) So let us say that you have
Line 37 in 10a2c75
A good piece of news is that the code should still work fine even if the user were to start indexing the classes at 0. |
Hi @alcinos. I have read many issues and your comments about The labels of COCO dataset are from 1 to 90. So in detr, self.class_embed = nn.Linear(hidden_dim, num_classes + 1) My questions are:
target_classes_o = torch.cat([t["labels"][J] for t, (_, J) in zip(targets, indices)])
target_classes = torch.full(src_logits.shape[:2], **0**,
dtype=torch.int64, device=src_logits.device)
target_classes[idx] = target_classes_o Can it work well? |
Not Alcinos, but:
In terms of minimizing time spent debugging and errors/issues encountered by other users, this convention is a good trade-off. |
Thanks @woctezuma. The matcher in Line 68 in 5e66b4c
will always take all object classes predictions as cost. So I think the way I propose above will not affect the match as well. |
@yangsenius As noted by @woctezuma, there is no theoretical issue with using 0 as the "no-object" label, but I personally don't see any good reason to do it. Best of luck. |
Very thanks for your suggestions! |
Hi, I was looking through the code, and other posted issues and it is still not clear to me what the number of classes should be. For coco it is set to 91 (90 + 1 for the no-object class) as explained here. However as seen in the code that builds the model:
detr/models/detr.py
Lines 36 to 38 in 10a2c75
+1 is added in the classification layer for the no object class. So if I have a dataset that has X number of classes (without including the bg), what should I set the value of num_classes to be.
P.S: Thanks for this great project!!! :)
The text was updated successfully, but these errors were encountered: