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 'F1' from 'torchmetrics' (/app/anaconda3/lib/python3.7/site-packages/torchmetrics/__init__.py) #23

Open
aiXia121 opened this issue Sep 4, 2022 · 1 comment

Comments

@aiXia121
Copy link

aiXia121 commented Sep 4, 2022

python ex_openmic.py
Traceback (most recent call last):
File "ex_openmic.py", line 5, in
from pytorch_lightning.callbacks import ModelCheckpoint
File "/root/work_project_2021/project_music2video/PaSST/src/pytorch-lightning/pytorch_lightning/init.py", line 65, in
from pytorch_lightning import metrics
File "/root/work_project_2021/project_music2video/PaSST/src/pytorch-lightning/pytorch_lightning/metrics/init.py", line 16, in
from pytorch_lightning.metrics.classification import ( # noqa: F401
File "/root/work_project_2021/project_music2video/PaSST/src/pytorch-lightning/pytorch_lightning/metrics/classification/init.py", line 19, in
from pytorch_lightning.metrics.classification.f_beta import F1, FBeta # noqa: F401
File "/root/work_project_2021/project_music2video/PaSST/src/pytorch-lightning/pytorch_lightning/metrics/classification/f_beta.py", line 16, in
from torchmetrics import F1 as _F1
ImportError: cannot import name 'F1' from 'torchmetrics' (/app/anaconda3/lib/python3.7/site-packages/torchmetrics/init.py)

envs:
Name: torch
Version: 1.12.1
Summary: Tensors and Dynamic neural networks in Python with strong GPU acceleration
Home-page: https://pytorch.org/
Author: PyTorch Team
Author-email: [email protected]
License: BSD-3
Location: /app/anaconda3/lib/python3.7/site-packages
Requires: typing-extensions
Required-by: torchvision, torchmetrics, torchaudio, timm, test-tube, Ba3l, pytorch-lightning

@Ludvig-Joborn
Copy link

I was able to solve this issue by downgrading Torchmetrics to version 0.6.2:

pip install torchmetrics==0.6.2

In torchmetrics 0.7.0, some metrics were renamed. For example, F1 was changed to F1Score. The authors haven't updated piplist.txt to reflect this, using version 0.9.3 instead.

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