April 2017
Intermediate to advanced
318 pages
7h 40m
English
Now let us test the image of a
:
im = cv2.resize(cv2.imread('cat.jpg'), (224, 224)).astype(np.float32)im = im.transpose((2,0,1))im = np.expand_dims(im, axis=0)# Test pretrained modelmodel = VGG_16('/Users/gulli/Keras/codeBook/code/data/vgg16_weights.h5')optimizer = SGD()model.compile(optimizer=optimizer, loss='categorical_crossentropy')out = model.predict(im)print np.argmax(out)
When the code is executed, the class 285 is returned, which corresponds (for more information refer to: https://gist.github.com/yrevar/942d3a0ac09ec9e5eb3a) to Egyptian cat: