Search⌘ K
AI Features

Use a Pre-trained Model

Explore how to use the ResNet50 pre-trained model to classify images into numerous categories. Learn how to preprocess input images properly, load the model with ImageNet weights, and interpret prediction outputs. This lesson sets the foundation for building custom classifiers using transfer learning.

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.

Python 3.5
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 format that the ResNet50 accepts and has
...