V2AI / Det3D

World's first general purpose 3D object detection codebse.
https://arxiv.org/abs/1908.09492
Apache License 2.0
1.5k stars 298 forks source link

Questions about number of anchors #101

Closed Jun-CEN closed 4 years ago

Jun-CEN commented 4 years ago

The code is about class MultiGroupHead which is in Det3D/det3d/models/bbox_heads/mg_head.py

Original code

num_classes = [len(t["class_names"]) for t in tasks]
self.class_names = [t["class_names"] for t in tasks]
self.num_anchor_per_locs = [2 * n for n in num_classes]

for num_c, num_a, box_cs in zip(
            num_classes, self.num_anchor_per_locs, box_code_sizes
        ):
            if self.encode_background_as_zeros:
                num_cls = num_a * num_c
            else:
                num_cls = num_a * (num_c + 1)
            num_clss.append(num_cls)

For example, if task is like this:

dict(num_class=2, class_names=["Bus","Trailer"])

Then num_classes will be 2, and num_anchor_per_locs will be 4. Finally, num_cls will be 2*4=8. I am wondering what does this 8 represents? If we only consider 2 different orientations of anchor for one class, the total number of anchors should be same as num_anchor_per_locs, why do we still need to multiply num_anchor_per_locs by num_classes?

poodarchu commented 4 years ago

anchor size is agnostic to categories, so we need to predict probability of being any one of all categories in this head.

afroowoo commented 4 years ago

Hello in the same code what does num_dir = num_a * 2 mean? Aren't the 2 different orientations already encapsulated in self.num_anchor_per_locs = [2 * n for n in num_classes]?

So for 1 class why are 4 directions needed?