you should use a fastai version loss function to avoid these errors,in your case when you creating the learner replace F.crossentropy with loss_func=CrossEntropyLossFlat(),dont forget the parenthesis.
Furthermore you should pass a PILImage data to the predict() method,one approach to create one is:
img = PILImage.create(filename)
or use a upload widge:
from fastai.vision.widgets import *
btn_upload = widgets.FileUpload()
btn_upload
img = PILImage.create(btn_upload.data[-1])
then you can pass img to the learn_inf.predict():
learn_inf.predict(img)