Error with Learn.predict("Some text")

Hi,

I am loading the exported learner and trying to predict
learn = load_learner(path, fname='trained_model.pkl')

but I am getting the below error when using

Learn.predict("Some text")

C:\Users\mannegow\AppData\Local\Continuum\anaconda3\envs\ForFastai2\lib\site-packages\fastai\torch_core.py:73: UserWarning: Tensor is int32: upgrading to int64; for better performance use int64 input
      warn('Tensor is int32: upgrading to int64; for better performance use int64 input')
    ---------------------------------------------------------------------------
    TypeError                                 Traceback (most recent call last)
    <ipython-input-8-1c491a584317> in <module>
    ----> 1 learn.predict('RELAY INTERMENT START. UNIT FAILED')

    ~\AppData\Local\Continuum\anaconda3\envs\ForFastai2\lib\site-packages\fastai\basic_train.py in predict(self, item, **kwargs)
        312         ds = self.data.single_ds
        313         pred = ds.y.analyze_pred(pred, **kwargs)
    --> 314         out = ds.y.reconstruct(pred, ds.x.reconstruct(x[0])) if has_arg(ds.y.reconstruct, 'x') else ds.y.reconstruct(pred)
        315         return out, pred, res[0]
        316 

    ~\AppData\Local\Continuum\anaconda3\envs\ForFastai2\lib\site-packages\fastai\data_block.py in reconstruct(self, t)
        333 
        334     def reconstruct(self, t):
    --> 335         return Category(t, self.classes[t])
        336 
        337 class MultiCategoryProcessor(CategoryProcessor):

    TypeError: 'NoneType' object is not subscriptable

Please advise

The learner is missing the classes list. There seems to be a bug either in the export-function or in load_learner. Either way, as a workaround you can insert the classes list manually after load_learner.

learn.single_ds.y.classes = ['class_1', 'class_2', ...]

See also here:

I tried Cloning fastai from github. But I ran into some different errors…

Created a new environment with fastai == 1.0.51 ( earlier i was using 1.0.43Post1) and the error is gone.
By the way This all started with updating the fastai to 1.0.50Post1 which lead to
Broken Process Pool Error for TextLMDataBunch.from_df

So rolled back to 1.0.43Post1 leading to Error with Learn.predict