How to create image with class <fastai.vision.core.PILImage>

Hello,

I’ve been trying to convert my .jpg image into a format accessible by the learner.predict() function. I’ve tried PILImage.create() and load_image, both do not seem to work (create PIL.PIL object instead).

I am trying to use the Image() function but it gives an error that module is not callable

The load_image function is also not working. How can I proceed to make predictions in my code?

The notebook link is https://www.kaggle.com/namansood/fastai-image-channel

Did you ever get this figured out? I have been working on this for days with no success. It’s getting old.

For me tensor(img_pil) worked just fine for prediction

PILImage.create(...)

is your friend.
To make predictions you should just do:

img = load_image(fname)
leanr.predict(img)
1 Like

Thanks for the responses. In the mean time I just saved the images and that worked. Obviously I can just delete those images but your suggestions are much cleaner (and faster).