I was able to install flair successfully however when I tried to use tagger.predict() function it throw "TypeError: Can't instantiate abstract class SentenceDataset with abstract methods is_in_memory" error. When following the traceback call details I noticed that there is an issue with the execution of the typing.py file. Below I am pasting the executed run text.
2020-10-29 17:09:20,015 loading file C:\Users\admin.flair\models\en-ner-conll03-v0.4.pt
Traceback (most recent call last):
File "C:/Users/admin/PycharmProjects/flairNLP/test.py", line 6, in
tagger.predict(sentence)
File "C:\Users\admin\PycharmProjects\flairNLP\venv\lib\site-packages\flair\models\sequence_tagger_model.py", line 343, in predict
dataset=SentenceDataset(reordered_sentences), batch_size=mini_batch_size
File "C:\Users\admin\AppData\Local\Programs\Python\Python36\lib\typing.py", line 1249, in __new__
return _generic_new(cls.__next_in_mro__, cls, args, *kwds)
File "C:\Users\admin\AppData\Local\Programs\Python\Python36\lib\typing.py", line 1210, in _generic_new
return base_cls.__new__(cls)
TypeError: Can't instantiate abstract class SentenceDataset with abstract methods is_in_memory
Following was the code:
from flair.models import SequenceTagger
from flair.data import Sentence
tagger = SequenceTagger.load('ner')
sentence = Sentence('Giving a test run to the one of the latest NLP library- Flair')
tagger.predict(sentence)
print(sentence.to_tagged_string())
The system on which this code is executed don't have GPU and I have installed pytorch libraries following command 'pip install torch==1.7.0+cpu torchvision==0.8.1+cpu torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html'
Kindly help me out and provide me a solution about how to get rid of this issue.
Hello, I had the same Issue.
Using the version 1.6 of torch fixed the problem for me.
Hi,
Thanks you for your reply. It worked for me also. So does it make
incompatible with latest version of torch?
Thank you so much for the help!
Dhrupa patel
On Thu, 29 Oct 2020, 21:58 Basile Châtillon, notifications@github.com
wrote:
Hello, I had the same Issue.
Using the version 1.6 of torch fixed the problem for me.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/flairNLP/flair/issues/1924#issuecomment-718869285,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AFPTGFWR6PAPUSV4NW4V3U3SNGJZRANCNFSM4TDU3KOA
.
It seems so,
Torch 1.7 was just release two days ago. I don't know why though. ^^
This is probably also the issue that broke our unit tests (see #1923). Should be fixed now in master though I'll need to do more testing with torch 1.7.
@alanakbik
It seems like this torch 1.7 incompatibility only affects python < 3.7
Could be an argument for a python 3.7+ requirement without having to pin torch 1.6 or addressing too much of the flair source code
@aychang95 thanks for the details - we'll test a bit, maybe version requirements won't be necessary. The error that broke the unit tests was caused by the SentenceDataset object incorrectly marking up the method is_in_memory as abstract, which it isn't. Removing the incorrect decorator seems to fix this.
@aychang95 not facing this issue with pytorch 1.6 version. As pytorch recently upgraded to 1.7 there seems version compatibility issues.
Hi all, I've pushed a hotfix for the pytorch 1.7 version to pip. If you update your Flair version it should now work with 1.7.