utterworks / fast-bert

Super easy library for BERT based NLP models
Apache License 2.0
1.86k stars 341 forks source link

Error during `predict_batch()` #131

Closed zampierimatteo91 closed 4 years ago

zampierimatteo91 commented 4 years ago

Hi, After fixing some minor issues, I was able to run the DataBunch and the Learner, but not the predicting methods. The error is the following:

Traceback (most recent call last):
  File "run_classification.py", line 122, in <module>
    main()
  File "run_classification.py", line 107, in main
    predictions = learner.predict_batch(texts=texts)
  File "/content/drive/My Drive/fast-bert/fast_bert/learner_cls.py", line 356, in predict_batch
    dl = self.data.get_dl_from_texts(texts)
  File "/content/drive/My Drive/fast-bert/fast_bert/data_cls.py", line 417, in get_dl_from_texts
    test_examples, 'test', is_test=True, no_cache=True)
  File "/content/drive/My Drive/fast-bert/fast_bert/data_cls.py", line 436, in get_dataset_from_examples
    os.path.basename(file_name)))
  File "/usr/lib/python3.6/posixpath.py", line 146, in basename
    p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType

I double-checked that my texts variable is a list of strings (I repeated the operation a number of times with different pipelines).

Could you direct me to a solution? Thanks

P.S. The error is present even whith predict_batch(texts) alone, the aforementioned syntax is just another try.

aaronbriel commented 4 years ago

I'm not seeing this issue, using an existing learner or a BertClassificationPredictor. I'm guessing this has to do with how your learner was defined.

zampierimatteo91 commented 4 years ago

Hi @aaronbriel ,

Thanks for your reply. Yeah, I thought it was an issue of mine. I just reproduced line by line the code provided in the notebooks with the same data I was providing before and it worked.

I will check more thoroughly later.

Cheers