jrieke / traingenerator

🧙 A web app to generate template code for machine learning
https://traingenerator.jrieke.com
MIT License
1.36k stars 181 forks source link

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

Closed murthy95 closed 3 years ago

murthy95 commented 3 years ago

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

jrieke commented 3 years ago

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:

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.

murthy95 commented 3 years ago

@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 commented 3 years ago

@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 commented 3 years ago

@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! ❤️