How to use your trained model – Deep Learning basics with Python, TensorFlow and Keras p.6




[ad_1]

In this part, we’re going to cover how to actually use your model. We will us our cats vs dogs neural network that we’ve been perfecting.

Text tutorial and sample code: https://pythonprogramming.net/using-trained-model-deep-learning-python-tensorflow-keras/

Dog example: https://pythonprogramming.net/static/images/machine-learning/dog.jpg

Cat Example: https://pythonprogramming.net/static/images/machine-learning/cat.jpg

Discord: https://discord.gg/sentdex
Support the content: https://pythonprogramming.net/support-donate/
Twitter: https://twitter.com/sentdex
Facebook: https://www.facebook.com/pythonprogramming.net/
Twitch: https://www.twitch.tv/sentdex
G+: https://plus.google.com/+sentdex

Source


[ad_2]

Comment List

  • sentdex
    November 25, 2020

    Magic-Man!

  • sentdex
    November 25, 2020

    Dear Sir,

    Am getting error in "X.Picke" how to rectify it i am trying this code in google colab

    FileNotFoundError Traceback (most recent call last)

    <ipython-input-2-ac49451e809a> in <module>()
    —-> 1 pickle_in = open("X.pickle","rb")
    2 X = pickle.load(pickle_in)
    3
    4 pickle_in = open("y.pickle","rb")
    5 y = pickle.load(pickle_in)

    FileNotFoundError: [Errno 2] No such file or directory: 'X.pickle'

  • sentdex
    November 25, 2020

    In short- Can I use model.predict_classes([prepare('tb6.JPG')]) to predict classes instead of the last line you showed?

  • sentdex
    November 25, 2020

    Hi, for my multiclassification problem, I have four class. In the prediction output, they are giving me four prediction.. but the prediction class category name doesn't match with that.
    the *print(prediction) * is printing different prediction and providing different name

    2nd concern is – *print(CATEGORIES[int(prediction[0][0])])* & the result I am getting with *model.predict_classes([prepare('tb6.JPG')])* does not match, do you know why?

  • sentdex
    November 25, 2020

    if i want to change my trained model(Sequential) shape(224,224,3) to (299,299,3) to train inceptionV3

    Please anyone helpme with this. thank you.
    You can also get back to me on shamshuddin7426@gmail.com

  • sentdex
    November 25, 2020

    For anyone getting two dogs or getting two cats, or something that is not what you were expecting–I initially had the same issue. What I did was reprocess my images with a larger image size of 100 (He did 50 in his video and 70 in his text tutorials). After retraining the model with a larger image size of 100, I was able to classify images correctly. That said, as he pointed out, this is about 80% accurate, so if misclassified–it doesn't necessarily mean your CNN is wrong–it might just meant you have to tweak your model to increase validation accuracy. Thanks again for sentdex for such informative tutorials. Really helps with comprehension.

  • sentdex
    November 25, 2020

    My tensorflow is not working

  • sentdex
    November 25, 2020

    I see you are writing IMG_SIZE in all caps. Is this a convention for variables with settings?

  • sentdex
    November 25, 2020

    How can apply to real camera
    Pls any suggestions

  • sentdex
    November 25, 2020

    The amount of random noises you make but yet I completely understand is very entertaining.

  • sentdex
    November 25, 2020

    Is this some kind of object detection?

  • sentdex
    November 25, 2020

    How does the model know where your image are?

  • sentdex
    November 25, 2020

    Can anybody notify me how to save this '64×3-CNN.model' model from google colab to google drive. Yes, my colab notebook is mounted to the google drive. But the model is not being saved after running the code.

  • sentdex
    November 25, 2020

    May you show some 'partially CNN' examples?

  • sentdex
    November 25, 2020

    Some models with lstm layers and stuff change on load_model(). They give different results.Any one has any fix?

  • sentdex
    November 25, 2020

    Every time it gives me the same classification

  • sentdex
    November 25, 2020

    Hi do you have the source code for training this model? Thanks.

  • sentdex
    November 25, 2020

    I am getting error because i also use SIFT algo and now error is ValueError: Error when checking input: expected dense_18_input to have shape (128,) but got array with shape (1,)

  • sentdex
    November 25, 2020

    awsome explanation ,thanks for clearing my doubts

  • sentdex
    November 25, 2020

    Unfortunately I couldn't make it work. Perhaps there is an issue in model. I guess, the code in this tutorial misses normalization by dividing 255. We need it because during the training we divided the pixel values by 255. But when I dont divide by 255 (as in this tutorial), ML randomly tells dog or cat. If I divide by 255 for the normalization, in this case the result is always dogs. So, in the video of this tutorial do we see the result correct just by chance? Because according to my experiment, the correct estimation ratio seem less than 30% (if we don't normalize as you did). Could you please check the model with other images, or could you explain why we don't need to normalize before prediction (although we did it during prediction)? Do you get more than 50% accuracy with this code ? What can be the problem for our case ? I saw that there are other people reporting the same issue, your help in this issue would be great. Thanks for your help.

  • sentdex
    November 25, 2020

    How do we use transfer learning and use sophisticated NN like ResNet50 to predict out images? please add part 7 of this tutorial series to show it and please add image augmentation step as well

  • sentdex
    November 25, 2020

    How do you pass a list of 15 images for prediction that you put in the Testing folder in part2 of this series?

  • sentdex
    November 25, 2020

    So, you have the categories, but now you need to do the opposite of what you did with that. Do you now need the dogetories?

  • sentdex
    November 25, 2020

    Me : (Passes a picture of a butterfly)
    Model : Is this a dog ?

  • sentdex
    November 25, 2020

    Discovered you right on time when I needed this kind of learning stuff. Great work Bro..

  • sentdex
    November 25, 2020

    love the title of the notebook

  • sentdex
    November 25, 2020

    Why is the output only 0 or 1? I thought it would be some number in the range [0,1]

  • sentdex
    November 25, 2020

    I am missing something, how did you load the dog image, how the program does know where the dog image is, did you specified filepath before?

  • sentdex
    November 25, 2020

    how to get prediction with 20 classes is it "print(CATEGORIES[int(prediction[0][0])])" ?

  • sentdex
    November 25, 2020

    ok i tried doing this same but with face recog instead cat vs dog and my accuracy is 100% still not giving right prediction -_-

  • sentdex
    November 25, 2020

    I wounder if anybody can tell me how to implement this code on raspberry Pi, I mean what modifications on we need to apply in this case?? many thanks in advance

  • sentdex
    November 25, 2020

    If we choose 'sigmoid' as activation function for output layer, we need to do sth like this:
    if probability > 0.5:

    plt.title("%.2f" % (probability[0]*100) + "% dog")

    else:

    plt.title("%.2f" % ((1-probability[0])*100) + "% cat")

    Since the out put of sigmoid is between 0~1, on the other hand in(num) for num between 0~1 constant equal to 0.

    Also why don't you divide the input data by using 255 while testing ? I think you did this while preparing the training dada. Confused.

  • sentdex
    November 25, 2020

    I learned from the p.1 until now. So far, everything works well, ultil I predict by using the model. It predicts everything as dog…

  • sentdex
    November 25, 2020

    This may be a silly question but if this stuff doable on a Mac? Working with tensorflow/keras + python

  • sentdex
    November 25, 2020

    Unfortunately i couldn't get mine to load an accurate prediction. I did the exact same thing as him. Only difference is that i took 2500 images from dog and cat each just to create separate folders for testing samples. There is about 12000 images left in Dog_train and Cat_train. Anyways i can't give this issue more hours. incase anyone faced the same issue please comment otherwise i have to move onto the next video and other material.
    Otherwise thanks @sentdex

  • sentdex
    November 25, 2020

    where to actually load the images to be tested?Didnt get that.

Write a comment