jrosebr1/simple-keras-rest-api

Hello, there is a mistake in the operation code. I would like to ask you for advice.

lianqingsong opened this issue · 10 comments

Run your code, I just change the imported model into my own training.

1
1

Then you run this error according to your method. How do I change it, please?
5

It looks like you're using your own custom model. Swapping out the ImageNet weights is just the first step. You now need to remove the code that decodes the ImageNet predictions and instead returns whatever your own custom predictions are.

@jrosebr1 Thank you very much for your reply. I am a beginner and I am a little childish. So do I need to change this part of the code?
20181019174936
I looked at it, feeling that there was something wrong with this part. I would like to ask you how to change it. Be deeply grateful.
20181019175019

You need to replace imagenet_utils.decode_predictions with whatever function/method you are using to decode the predictions from your model. I assume you've already tested your model on single images and examined the output to ensure it's correct. Do the same thing here only your results need to go into the results dictionary.

Take your time, work slow, and include debug print statements to help you out along the way.

@jrosebr1
Ok, thank you very much. My model is classified into 10, and the label is 0 to 9. Has been tested, input a single image, the prediction is correct.

I still don't know what to change the part of imagenet_utils.decode_predictions.

0.0

I would suggest reading my deep learning blog posts on my blog, pyimagesearch.com. In particular, this one on training your own custom CNN with Keras will help you:

https://www.pyimagesearch.com/2018/04/16/keras-and-convolutional-neural-networks-cnns/

Notice how I am able to predict actual labels and their probabilities. You should be able to do the same with your code. Like I said, take your time, go slow, and debug every step of the way.

@jrosebr1
Thank you very much for your reply again. I have the complete prediction code, and can successfully execute and predict correctly. The problem is that I don't know how to modify the part of imagenet_utils.decode_predictions you said to fit my model.

My model is a simple number 10 classification, I hope you can tell me more details about this novice.

Thank you very much

Hey @Qsongl, please refer to my previous reply. Be sure to go through my tutorials. They are meant to help you get started, even as a novice. Learn how to make predictions on your own data. If you can make predictions on your own data, you'll see that you don't need the imagenet_utils.decode_predictions.

Again, go through my tutorials and take the time to learn. It's okay if you are a novice but you need to learn how to walk before you run. You're taking too many steps at once and what is what is tripping you up. Take the time to educate yourself on the steps in between.

@jrosebr1 ,Ok, thank you very much

Hey @jrosebr1 ,I have new puzzles。
If the server is running remotely or on a different machine.How can I run simple_reruest.py on another computer to get the predicted results?
Just modify this code?
1
Or you want to configure other files and change the code in other places.

You will need to change localhost to be the IP address of the machine the server is running on.