Skip to content

num_classes issue #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
virgile-fsr opened this issue Mar 25, 2025 · 1 comment
Open

num_classes issue #51

virgile-fsr opened this issue Mar 25, 2025 · 1 comment

Comments

@virgile-fsr
Copy link

self.reinitialize_detection_head(checkpoint_num_classes)

If user creates a new model with:
model = RFDETRBase(num_classes=123)
The code linked above will overwrite the num classes specified by the users by the one in the checkpoint (90 by default). I don't think this is expected behavior. More worrisome, the config of the object stays with num_classes=123 which will cause issues in the train function.

If you call: model.train(dataset_dir=...) with the model above, it will check the number of classes in the dataset and compare it with self.model_config.num_classes which is still 123 in our example (even though the actual model has a 90 sized output layer). So if the number of classes in the dataset is indeed 123, the check will pass even though it should not.

A different issue it that if you try a dataset with a single class, the labels from the dataloader will have size zero.

@isaacrob-roboflow
Copy link
Collaborator

single class is being discussed here #48, the issue is due to our working mainly with datasets exported from roboflow which have a filler 0 class causing the issue you're observing with non-roboflow format datasets.

good point re using number of classes as an excuse to reinitialize the head! do you have an idea of what a preferred interface would look like? maybe something like having num_classes default to None and if it is not None, we reinitialize the head with that number of classes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants