Do we have to count the background as an object class for SSD?

The documentation for the SSD class mentions that we should not count the background as an object class when passing the number of classes as a parameter to instantiate an SSD object.

However, further down in the same file, an SSD object is instantiated in a function that explicitly says that the background should be counted as an object class, but this is not taken into account in the code (i.e. I did not see num_classes be decremented by one when creating the SSD object).

Here is the documentation for this function, which says we should include the background in the number of classes.

This is confusing. Should we or should we not count the background as an object class when instantiating the SSD? In either case, how should object classes be ID’d during training?

As an example, with Faster RCNN, the background is counted as an object class (with ID 0 reserved for it) and actual object classes are identified during training starting from ID 1. What should be the procedure for SSD?

1 Like

This was solved here: Documentation confusing on whether SSD and RetinaNet count background as class object · Issue #4106 · pytorch/vision · GitHub

1 Like