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

[Bug]: Loading task classifier from Classifier class not working #3445

Open
HallerPatrick opened this issue Apr 19, 2024 · 0 comments
Open
Assignees
Labels
bug Something isn't working candidate for next release

Comments

@HallerPatrick
Copy link
Collaborator

Describe the bug

Loading e.g the "sentiment" classifier with the Classifier class throws an error, that the folder or file cannot be found. Expected behavior should be, that the sentiment model from the HU model repo should be fetched. This seems to be a regression bug, as with flair==0.12.x it works

To Reproduce

from flair.nn import Classifier

classifier = Classifier.load("sentiment")

Expected behavior

The code should download the text classifiert model and the respective model object should be returns

Logs and Stack traces

Traceback (most recent call last):
  File "/home/folder/test.py", line 4, in <module>
    classifier = Classifier.load('sentiment')
  File "/home/folder/venv/lib/python3.9/site-packages/flair/nn/model.py", line 557, in load
    return cast("Classifier", super().load(model_path=model_path))
  File "/home/folder/venv/lib/python3.9/site-packages/flair/nn/model.py", line 149, in load
    return model_cls.load(new_model_path)
  File "/home/folder/venv/lib/python3.9/site-packages/flair/file_utils.py", line 351, in load_torch_state
    f = load_big_file(model_file)
  File "/home/folder/venv/lib/python3.9/site-packages/flair/file_utils.py", line 49, in load_big_file
    with open(f, "rb") as f_in:
FileNotFoundError: [Errno 2] No such file or directory: 'sentiment'

Screenshots

No response

Additional Context

No response

Environment

Versions:

Flair

0.13.1

Pytorch

2.2.2+cu121

Transformers

4.40.0

GPU

True

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working candidate for next release
Projects
None yet
Development

No branches or pull requests

2 participants