Skip to content
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

Feature : Image Classification model with arbitrary number of classes #5

Closed
murthy95 opened this issue Jan 2, 2021 · 4 comments
Closed
Labels
existing template Fix or enhance an existing template

Comments

@murthy95
Copy link
Contributor

murthy95 commented Jan 2, 2021

Hello!
I am planning to add an option to declare number of classes for image classification model. This also helps for transfer learning.

@jrieke
Copy link
Owner

jrieke commented Jan 2, 2021

Hey @murthy95, yes that would be great! I actually had this on my list but seems like I forgot to add it in the first version. For the pytorch template, that's fairly easy, you can just pass the number to the torchvision model, e.g. torchvision.models.alexnet(num_classes=10). For sklearn, I think it's impossible to set it manually, unfortunately (because it just infers the number of classes from the data), but if you find an option, let me know!

Some more thoughts:

  • probably best to add a parameter in the sidebar below the "Use pre-trained model" checkbox:
  • default value should be 1000 (as that's what torchvision uses)
  • if pre-trained is True, this needs to be fixed at 1000
  • in the code, this should be added as a hyperparameter below here:

image

Long-term it would also be great to infer this value automatically from the input data but for now manually setting it should be enough.

@jrieke jrieke added the existing template Fix or enhance an existing template label Jan 2, 2021
@murthy95
Copy link
Contributor Author

murthy95 commented Jan 2, 2021

@jrieke True for pytorch models its fairly easy but if we want to support pretrained imagenet weights for transfer learning we need to load weights and then change the final fc layer. At least this what I did in my PR if there is some better way please point it out.

@jrieke
Copy link
Owner

jrieke commented Jan 3, 2021

@murthy95 Good point, didn't think about that. Just had a brief look through your PR (#6), looks good so far. I'll try it out during the next days (bit busy right now) and get back.

jrieke added a commit that referenced this issue Jan 19, 2021
@jrieke
Copy link
Owner

jrieke commented Jan 19, 2021

@murthy95 Sorry for the long delay, I was busy with another projects the last 2 weeks. Anyway, I merged your PR and it's now live on the website! 🥳

Just adapted the fields in the sidebar a bit. Closing this for now but let me know if you have more thoughts. Thanks again for contributing! ❤️

@jrieke jrieke closed this as completed Jan 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
existing template Fix or enhance an existing template
Projects
None yet
Development

No branches or pull requests

2 participants