VGG16 image classification code example

The Keras Applications module has pre-trained neural network models, along with its pre-trained weights trained on ImageNet. These models can be used directly for prediction, feature extraction, and fine-tuning:

#import VGG16 network model and other necessary libraries from keras.applications.vgg16 import VGG16from keras.preprocessing import imagefrom keras.applications.vgg16 import preprocess_inputimport numpy as np#Instantiate VGG16 and returns a vgg16 model instance vgg16_model = VGG16(weights='imagenet', include_top=False) #include_top: whether to include the 3 fully-connected layers at the top of the network.#This has to be True for classification and False for feature extraction. Returns a model ...

Get Practical Convolutional Neural Networks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.