I am trying to modify lesson 1 to do predictions of some sample images I got off the internet and I get an error.
I tried doing a test on the test data set and that doesn’t work either.
I get the following error:
In : vgg.test(path+‘test1’, batch_size=4)
Found 0 images belonging to 0 classes.
Out: Exception in thread Thread-45:
Traceback (most recent call last):
File “c:\toolkits\anaconda2\lib\threading.py”, line 801, in __bootstrap_inner
File “c:\toolkits\anaconda2\lib\threading.py”, line 754, in run
File “c:\toolkits\keras-1.0.5\keras\engine\training.py”, line 409, in data_generator_task
generator_output = next(generator)
File “c:\toolkits\keras-1.0.5\keras\preprocessing\image.py”, line 682, in next
index_array, current_index, current_batch_size = next(self.index_generator)
File “c:\toolkits\keras-1.0.5\keras\preprocessing\image.py”, line 507, in _flow_index
current_index = (self.batch_index * batch_size) % N
ZeroDivisionError: integer division or modulo by zero
(<keras.preprocessing.image.DirectoryIterator at 0x4af4ef0>, )
It doesn’t see your images I think, try using double quotes on “test 1” or being very explicit about where your data is.
Remember that you need a directory structure that matches the structure that was setup for you, with train and valid folders, and labels in those folders…
(This directory struct isn’t perfect, but you should get the idea)
Oh, sorry, didn’t notice you were using test, my bad. Some better googling revealed that this problem has been encountered a few times before. I’m glad I ran into it now with you as I think I was about to run into it anyway.
Then something has gone wrong in your training, or you don’t have the right directory structure. You should review the dogs_cats_redux.ipynb or some of the earlier material, I feel you’re missing something basic.
I tested some random cat fotos from internet using this code. the images are copied into a folder called “unknown” inside the below directory. this runs after the model is fit and fine tuned. It doesnt give accurate results, maybe because not all the cat types that we test here were used in the training.