-
Notifications
You must be signed in to change notification settings - Fork 283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
horse or human inceptionv3 miscatagorizing #8
Comments
Hey I was having a similar issue. I realized that the images of horses and humans used to train the model on the first iteration of chapter 3 were 300 x 300 and later in the chapter when we arrive at transfer learning the inputs were 150 x 150. So I altered the code given and put it back to 300 x 300 and that seems to work for me. Maybe the reason behind it is because the input needs to match the shape of the data (in this case 300× 300). |
I had been trying it the opposite way of setting the training, validation, and test images to 150,150. I went ahead and tested with 300,300 in both the model training and test and receive the same result: running the validation images against the model always returns human and 1. for the class. So still no luck but thanks for the reply. My code: weights_url = "https://storage.googleapis.com/mledu-datasets/inception_v3_weights_tf_dim_ordering_tf_kernels_notop.h5" pre_trained_model = InceptionV3(input_shape=(300, 300, 3), pre_trained_model.load_weights(weights_file) for layer in pre_trained_model.layers: last_layer = pre_trained_model.get_layer('mixed7') x = layers.Flatten()(last_output) x = layers.Dense(1024, activation='relu')(x) x = layers.Dropout(0.2)(x) x = layers.Dense(1, activation='sigmoid')(x) model = Model(pre_trained_model.input, x) model.compile(optimizer=RMSprop(lr=0.001), training_url = "https://storage.googleapis.com/laurencemoroney-blog.appspot.com/horse-or-human.zip" validation_url = "https://storage.googleapis.com/laurencemoroney-blog.appspot.com/validation-horse-or-human.zip" zip_ref = zipfile.ZipFile(validation_file_name, 'r') train_datagen = ImageDataGenerator(rescale=1./255., #Note that the validation data should not be augmented! #Flow training images in batches of 20 using train_datagen generator #Flow validation images in batches of 20 using test_datagen generator history = model.fit_generator( model.save('horse_or_human.h5') #Test script
|
yes, I've the same problem as well. Using 300 adjustment didn't work either. I don't know the issue, considering I've started with this book to my ML journey, I'd like to know what's wrong with this. |
@tameyer1 Hey, I know your question is one year old but I encountered same issue. The reason is we were not normalizing when using a test image. |
I hit the exact same issue. It looks like this might be a bug in: https://github.com/lmoroney/tfbook/blob/master/chapter3/transfer_learning.ipynb where rather than:
it should be:
However, difference that might explain why i needed to add
I think the next step to figure out if this is an error in https://github.com/lmoroney/tfbook/blob/master/chapter3/transfer_learning.ipynb is to run that code on colab code to see if |
I ran the https://github.com/lmoroney/tfbook/blob/master/chapter3/transfer_learning.ipynb on colab, and needed to make these following changes: added:
Changes:
After these changes, things ran correctly and images I uploaded were identified correctly |
@lmoroney looks like people can't just raise PRs against this repo. What is the correct to get this issue fixed? |
Ah i just realised what i was doing wrong - leave this with me and i will raise a PR |
Hello
I was working on the horse or human transfer learning section. I am using the datasets for training and validation from the urls you supply. No matter what horse image I try the model classifies it as human. I figured my local setup might have issues so I opened and ran the colab file for transfer learning in the chapter 3 folder. I received the same incorrect results using a random horse picture from the web as well as when I uploaded some of the validation horse images from the colab project.
The text was updated successfully, but these errors were encountered: