nateraw / huggingpics

🤗🖼️ HuggingPics: Fine-tune Vision Transformers for anything using images found on the web.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't instantiate abstract class Classifier with abstract methods forward

e-choness opened this issue · comments

Hi

Thank you for this straight forward codes for us to practice fine-tuning models with ViT. I'm on a project that classifying book covers. Everything goes well on my own dataset until trying to define classifier. An error message popped up "Can't instantiate abstract class Classifier with abstract methods forward". As I looked up the pytorch lightning code about forward(), it is indeed an abstract class. No idea why the error since the method was initiated in the init() method.

image

Has anyone run into this issue yet?

If I were you I would create a new environment, reinstall latest pypi of pytorch-lightning, and see if that solves your issue. I just re-ran the colab notebook and its fine, so there's got to be something wrong with your local environment.

If I were you I would create a new environment, reinstall latest pypi of pytorch-lightning, and see if that solves your issue. I just re-ran the colab notebook and its fine, so there's got to be something wrong with your local environment.

Thank you for the quick reply. I installed pytorch-lightning just a few days ago. The issue might be my outdated transformer package. I will try it out and return with the results.

sounds good! I do think its lightning, though. My guess is a pip install -U pytorch-lightning would fix this.

sounds good! I do think its lightning, though. My guess is a pip install -U pytorch-lightning would fix this.

Thank you! Updated both transformer and pytorch-lightning package. It's no longer an issue. Tuning local environment is a bit of a chore. Also some parameters such as GPU index needs to be adjusted.

Great! glad it worked out for you. And yea, the gpu stuff should be updated to whatever the latest syntax is. Closing this now - cheers.