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

hunflair2 model is not found #3547

Closed
YashotharaS opened this issue Sep 24, 2024 · 14 comments
Closed

hunflair2 model is not found #3547

YashotharaS opened this issue Sep 24, 2024 · 14 comments
Assignees

Comments

@YashotharaS
Copy link

Dear all,
I'm encountering the error "ValueError: Could not find any model with name 'hunflair2'" when trying to run the code tagger = Classifier.load("hunflair2") as mentioned on the GitHub page. I'm using Flair version 0.14.0, and while hunflair v1 works without issues, the code is unable to find hunflair2. Could you please help me resolve this issue?

@helpmefindaname
Copy link
Collaborator

@sg-wbi @WangXII
it looks like https://huggingface.co/hunflair/hunflair2-ner has pickeled a PosixPath and therefore cannot be loaded in Windows.
The flair trainer doesn't save paths anymore, see https://github.com/flairNLP/flair/blob/master/flair/trainers/trainer.py#L894

Can one of you execute

model = Classifier.load("hunflair2")
model.model_card["training_parameters"]["base_path"] = str(model.model_card["training_parameters"]["base_path"])
model.save("pytorch_model.bin")

and commit the new model on the HF-Hub?

@WangXII
Copy link
Collaborator

WangXII commented Sep 27, 2024

Thanks @helpmefindaname, I've committed the new model according this to hf-hub!

@helpmefindaname
Copy link
Collaborator

helpmefindaname commented Sep 28, 2024

@WangXII thank you!

@YashotharaS can you try out if it works now? You might have to delete the %HOME%\.flair\models\hunflair2-ner folder first, so that you download the right version

@YashotharaS
Copy link
Author

Thanks a lot @WangXII and @helpmefindaname

I tried it, and it works fine now. Thanks again for your help :)

@tecosaur
Copy link

I've just tried Classifier.load("hunflair2") (Linux, Python 3.12, Flair 0.14), and I'm seeing

ERROR: The key 'hunflair2' was neither found on the ModelHub nor is this a valid path to a file on your system!

ValueError: Could not find any model with name 'hunflair2'

I'd appreciate any help getting this working.

@WangXII
Copy link
Collaborator

WangXII commented Dec 12, 2024

I created a new conda environment with python==3.12.8 and only flair==0.14.0 installed via pip on openSUSE 15.5 and could not replicate the error.

Did you try out installing flair in a new environment and could you replicate the error? If yes, could you provide some information about your Linux version?

@tecosaur
Copy link

Well this is interesting, I'm running Python 3.12.8 on openSUSE Tumbleweed with a fresh environment.

I did install this in a conda environment, but that shouldn't make a difference should it?

@WangXII
Copy link
Collaborator

WangXII commented Dec 12, 2024

Hmm, yeah, this should not make any difference. Can you try out whether loading the model via its HuggingfacePath works?

model = Classifier.load("hunflair/hunflair2-ner") https://huggingface.co/hunflair/hunflair2-ner

@tecosaur
Copy link

tecosaur commented Dec 12, 2024

Ok, this is a bit weird. I tried it and it worked once, but then calling it again I got the error??

Attempt 1:

>>> Classifier.load("hunflair/hunflair2-ner")
2024-12-12 19:01:30,166 SequenceTagger predicts: Dictionary with 21 tags: O, S-Chemical, B-Chemical, E-Chemical, I-Chemical, S-Gene, B-Gene, E-Gene, I-Gene, S-Disease, B-Disease, E-Disease, I-Disease, S-Species, B-Species, E-Species, I-Species, S-CellLine, B-CellLine, E-CellLine, I-CellLine

Attempt 2:

>>> Classifier.load("hunflair/hunflair2-ner")
2024-12-12 19:02:10,892 --------------------------------------------------------------------------------
2024-12-12 19:02:10,892 ERROR: The key 'hunflair/hunflair2-ner' was neither found on the ModelHub nor is this a valid path to a file on your system!
2024-12-12 19:02:10,892  -> Please check https://huggingface.co/models?filter=flair for all available models.
2024-12-12 19:02:10,892  -> Alternatively, point to a model file on your local drive.
2024-12-12 19:02:10,892 --------------------------------------------------------------------------------

This is without restarting the process in between.

@WangXII
Copy link
Collaborator

WangXII commented Dec 12, 2024

Indeed, sounds weird. I guess this is also why the default "hunflair2" model now returns the error. Can you check your flair model cache at ~/.flair/models whether it stored any models successfully?

@tecosaur
Copy link

How does this look?

~$ tree ~/.flair/models/hunflair2-ner/models--hunflair--hunflair2-ner/
/home/tec/.flair/models/hunflair2-ner/models--hunflair--hunflair2-ner/
├── blobs/
│  └── 245a099b660c1e2b682e0a1216feac140d5be36c4c6ca8c715af682efa685de6
├── refs/
│  └── main
└── snapshots/
   └── 3af2b8972f7af2910ce8d9ae724da09b3d7a166c/
      └── pytorch_model.bin -> ../../blobs/245a099b660c1e2b682e0a1216feac140d5be36c4c6ca8c715af682efa685de6

@WangXII
Copy link
Collaborator

WangXII commented Dec 12, 2024

This looks fine-ish, so the model should be cached. If you are restarting the process, does it work again?

I would link this to @helpmefindaname , not sure whether something goes wrong internally

@tecosaur
Copy link

If I restart the process, it seems to work exactly once then fail again. I guess there's some state that's being a bit funky in the background?

@WangXII
Copy link
Collaborator

WangXII commented Dec 12, 2024

Yeah, I guess so. Let's see whether @helpmefindaname knows something about this

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

5 participants