I still don't understand how to predict after 3rd lecture

Hi, this is my first post on the forum, and hopefully not the last one :slight_smile: so I hope I’m doing everything right

I like the idea of Top-Down teaching. You show what I can do with the tool from the beginning and then, when I’m interested and when I’m hooked - you show all the details.

Great idea, but after reviewing from the top side I still don’t know how to predict is this a cat on picture or a dog. (I’m not a newbie in Python at all)

What I expected. I teach NN and the I can give any picture to it and get prediction from the NN is this a cat or dog.

Maybe something like

learn.predict_one(path_to_pic) == 0.999 

I don’t know :slight_smile:

But for know I just saw how good model that we taught by just level of prediction like 0.999 which is good, I would see more practical part of that.

I hope my question doesn’t sound too stupid.

Thank you

1 Like

Hi there, welcome!

The first thing you would have to do is to load your picture into an array, by using the function open_image.
Then you can use the method learn.predict_array to have the predictions of your model on it. Beware though, this function expects an array of four dimensions: mini_batch by channels by height by width, so you will have to add one dimension at the beginning to make the shape of your picture array1x3xhxw.

4 Likes

To add/remove dimensions in pytorch use either view or squeeze/unsqueeze.

1 Like

Hi, welcome to the forum.

What sgugger said was pretty much what you should do to achieve what you are looking for. But, if you are still not clear, you can refer to this thread, “How do we use our model against a specific image?”. This was discussed at length there together with Jeremy’s replies.

It’s a bit tricky to get this all to works. Fret not, if you are looking for the latest codes to get this working, here’s the direct link to my reply in the same thread. I hope it helps in some ways.

1 Like

thanks a lot, guys!

Now I really enjoy of what is going on here :slight_smile:

4 Likes