VGG16 in Keras
You can follow along with the code in the Jupyter notebook ch-12a_VGG16_Keras
.
Now let us do the same classification and retraining with Keras. You will see how easily we can use the VGG16 pre-trained model in Keras with the lesser amount of code.
Image classification using pre-trained VGG16 in Keras
Loading the model is a one-line operation:
from keras.applications import VGG16 model=VGG16(weights='imagenet')
We can use this model to predict the probabilities of classes:
probs = model.predict(images_test)
Here are the results of this classification:
Input image | Output probabilities |
![]() | Probability 99.41% of [zebra] Probability 0.19% of [tiger cat] Probability 0.13% of [goose] Probability 0.09% of [tiger, Panthera tigris] Probability 0.02% of [mushroom] |
![]() | Probability 87.50% of [horse cart, horse-cart] Probability 5.58% of [Arabian camel, dromedary, Camelus dromedarius] Probability 4.72% of [plow, plough] Probability 1.03% of [dogsled, dog sled, dog sleigh] Probability 0.31% of [wreck] |
![]() | Probability... |