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

ImportError: cannot import name 'get_num_classes' from 'torchmetrics.utilities.data' #13

Open
Schnei1811 opened this issue Aug 9, 2022 · 3 comments

Comments

@Schnei1811
Copy link

Schnei1811 commented Aug 9, 2022

Getting the following error following the instructions

python scripts/txt2img.py --prompt "a virus monster is playing guitar, oil on canvas" --ddim_eta 0.0 --n_samples 4 --n_iter 4 --scale 5.0 --ddim_steps 50
Traceback (most recent call last):
File "scripts/txt2img.py", line 11, in
from pytorch_lightning import seed_everything
File "usr\anaconda3\envs\ldm\lib\site-packages\pytorch_lightning_init_.py", line 20, in
from pytorch_lightning import metrics # noqa: E402
File "usr\anaconda3\envs\ldm\lib\site-packages\pytorch_lightning\metrics_init_.py", line 15, in
from pytorch_lightning.metrics.classification import ( # noqa: F401
File "usr\anaconda3\envs\ldm\lib\site-packages\pytorch_lightning\metrics\classification_init_.py", line 14, in
from pytorch_lightning.metrics.classification.accuracy import Accuracy # noqa: F401
File "usr\anaconda3\envs\ldm\lib\site-packages\pytorch_lightning\metrics\classification\accuracy.py", line 18, in
from pytorch_lightning.metrics.utils import deprecated_metrics, void
File "usr\anaconda3\envs\ldm\lib\site-packages\pytorch_lightning\metrics\utils.py", line 22, in
from torchmetrics.utilities.data import get_num_classes as _get_num_classes
ImportError: cannot import name 'get_num_classes' from 'torchmetrics.utilities.data' (usr\anaconda3\envs\ldm\lib\site-packages\torchmetrics\utilities\data.py)

@Tariq195
Copy link

Tariq195 commented Aug 9, 2022

conda uninstall torchmetrics
conda install torchmetrics=0.5

@micahsgilbert
Copy link

Got an error doing just conda install torchmetrics=0.5.
According to https://anaconda.org/conda-forge/torchmetrics the correct command is:
conda install -c conda-forge torchmetrics=0.5

@sixtyspam
Copy link

torchmetrics 0.7 worked for me, had same problem

pip uninstall torchmetrics
pip install torchmetrics==0.7

Don't forget to activate conda environment in case you're using conda

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

4 participants