How to get an empty ConvLearner for single image prediction?

Yes, that’s correct @MicPie :smiley: Thank you. Now I think I need to learn more seriously Pytorch. There are many basic things that I don’t know. I have just started with Udacity Pytorch course for that

1 Like

Be sure to have a look in this thread: https://forums.fast.ai/t/getting-comfortable-with-pytorch-projects/28371 :smiley:

1 Like

Hi, Jeremy,
In the dev_nb/104c_single_image_pred.ipynb file
img = open_image(get_image_files(path)[0]) learn.predict(img)
The "img: is a original image.Do I need to transform and normalize that image?

Thanks

When I run

img = open(path_single)
loses = img.predict(learn)
learn.data.classes[losses.arg()]

I get the error

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-45-2f5879725775> in <module>()
      1 img = open(path_single)
----> 2 loses = img.predict(learn)
      3 learn.data.classes[losses.arg()]

AttributeError: '_io.TextIOWrapper' object has no attribute 'predict'

I got an “AttributeError: ‘Image’ object has no attribute ‘tfm’” running your code snippet

It seems that you have mixed up method calls

you should call predict on your learn object and pass it Image

so 2nd line should be
loses = learn.predict(img)