Issue of vgg.test(...)


Finally I can run those 7 lines of simple vgg code to build a model for cat and dog data well in windows platform(Theano+CPU+win7 64bit OS).

Its accuracy is 0.97 on train data as expected. based on that, i save this final weights to a h5 file.

Now I’d like to predict the classification on test data using this model&weights. Its code is below.
from future import division,print_function
import os, json
from glob import glob
import numpy as np
np.set_printoptions(precision=4, linewidth=100)
from matplotlib import pyplot as plt
import utils; reload(utils)
from utils import plots

path = "D:\work\sw_tool\Anaconda3\practice\dogscats\"
batch_size = 4

from vgg16 import Vgg16

vgg = Vgg16()


batches, preds = vgg.test(path+‘test1’)


But it fails as below. I know it’s caused by get_batches in vgg.test(…), but don’t know why? BTW, I’m sure its path and batch_size are all right. can anyone help it? thanks.

as shown above, in my test1 folder, there are many images including cat and dog.

but the error log said that 0 images belonging to 0 classes.

actually in training part , the below code to fetch images works well.

path = "D:\work\sw_tool\Anaconda3\practice\dogscats\"
batch_size = 16
… …

batches = vgg.get_batches(path+‘train’, batch_size=batch_size)
val_batches = vgg.get_batches(path+‘valid’, batch_size=batch_size*2)

ok, its solution is easy. just create a new subfolder(just named dog_cat) under “test1” and move all of images under test1 to where under “dog_cat”.

actually I don’t why need create such a sub folder so that get_batches can work normally?