And because self.logger is None, the code fails with the following exception (paths redacted):
File "/.../bert_model.py", line 192, in classify
pred = self.model.predict(text)
File "/.../fast_bert/prediction.py", line 79, in predict
predictions = self.predict_batch([text])[0]
File "/.../fast_bert/prediction.py", line 76, in predict_batch
return self.learner.predict_batch(texts)
File "/.../fast_bert/learner_cls.py", line 553, in predict_batch
self.logger.info("---PROGRESS-STATUS---: Tokenizing input texts...")
AttributeError: 'NoneType' object has no attribute 'info'
As a workaround, I am currently manually setting a logger:
I believe I found a bug in the
predict
code for theBertClassificationPredictor
class.I am loading a trained model like this:
and then generating predictions like this:
Looking at the source code, the first code sample creates a BertClassificationPredictor object that calls
self.get_learner
. This function then calls BertLearner.from_pretrained_model with the parameterlogger=None
.When I then call
predict
, I am eventually led to BertLearner.predict_batch, which starts like this:And because
self.logger
isNone
, the code fails with the following exception (paths redacted):As a workaround, I am currently manually setting a logger:
But I am wondering whether this is truly a bug or whether I'm skipping an important step somewhere.