-
Notifications
You must be signed in to change notification settings - Fork 282
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
predict_generator cannot maintain image order #149
Comments
I don't see a way we can force this to behave differently from the R side (although if there is a way to do it from the Python side we could certainly facilitate users getting it right from the R side). I think for the time being you might just need to use straight predict. |
Many thanks for your answer. I guess I found the mistake I made: for flow_images_from_directory I need to set shuffle to FALSE. Then the order of predicition via predict_generator corresponds to the image order. At least for my test case using the two images 01.jpg and 02.jpg. I checked it via a loop of 1000 repetitions for predict_generator and the order is fix and fits image order. Important when using a larger number of test images:
Easy batch renaming via console: https://stackoverflow.com/questions/3211595/renaming-files-in-a-folder-to-sequential-numbers |
Excellent! So happy you got to the bottom of it. In case you are still curious, the way to manually pull from a generator is to call |
setting shuffle=false to evaluate_generator and predict_generator fixed the issue for me |
I tested image classification on two images (01.jpg and 02.jpg) via predict_generator. The predicition is correct and very good. However, the image order cannot be maintained and do not correspond to the order generated via the image_data_generator.
Example:
Therefore, the prediction of a large image batch is not possible since I do not know which prediction refers to the individual image. In addition, the order changes in each repetition of the predict_generator step.
A similar bug is reported here, but no solution is given: keras-team/keras#5048)
Is there any solution? Otherwise the results given via predict_generator are more or less useless for a large batch of images to be classified.
The text was updated successfully, but these errors were encountered: