Skip to content

Commit

Permalink
Add num classes comment (facebookresearch#246)
Browse files Browse the repository at this point in the history
* Add comment explaining num_classes

* More comments

* More comments
  • Loading branch information
fmassa authored Sep 28, 2020
1 parent 7cd7895 commit d48394a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions models/detr.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,18 @@ def forward(self, x):


def build(args):
# the `num_classes` naming here is somewhat misleading.
# it indeed corresponds to `max_obj_id + 1`, where max_obj_id
# is the maximum id for a class in your dataset. For example,
# COCO has a max_obj_id of 90, so we pass `num_classes` to be 91.
# As another example, for a dataset that has a single class with id 1,
# you should pass `num_classes` to be 2 (max_obj_id + 1).
# For more details on this, check the following discussion
# https://github.com/facebookresearch/detr/issues/108#issuecomment-650269223
num_classes = 20 if args.dataset_file != 'coco' else 91
if args.dataset_file == "coco_panoptic":
# for panoptic, we just add a num_classes that is large enough to hold
# max_obj_id + 1, but the exact value doesn't really matter
num_classes = 250
device = torch.device(args.device)

Expand Down

0 comments on commit d48394a

Please sign in to comment.