Use a Pre-trained Model

In this lesson, we are going to use the first strategy of transfer learning i.e. using pre-trained models. We will use ResNet50 to build a classifier.

Here, we will use the ResNet50 Model. The pre-trained model can classify images into 1000 object categories, such as keyboard, mouse, pencil, animals, etc.

Note that 50 means that the network is 50 layers deep. You can also have a 101 or a 152 layers deep network.

Importing the required libraries

We will import the ResNet50 model from the Keras library. There are many other pre-trained models in the keras.applications module. Check them out here.

Press + to interact
from tensorflow.python.keras.applications.resnet50 import ResNet50
from tensorflow.python.keras.applications.resnet50 import preprocess_input, decode_predictions
from tensorflow.python.keras.preprocessing import image
import numpy as np
print('Imported Successfully!')

Explanation:

  • The preprocess_input function is used to preprocess the input image to the
...