Search⌘ K
AI Features

Pretrained Classification CNNs

Explore the use of pretrained convolutional neural networks such as GoogLeNet and ResNet50 for image classification in automated inspection. Understand how to transform images, run predictions, and interpret results using PyTorch’s pretrained models and ImageNet classes.

We'll cover the following...

Deep convolutional neural networks often require considerable computation resources to train. The good news is some deep CNNs trained on the ImageNet database (a large image dataset) are freely available for download. Their value in the context of automated inspection will become evident when we discuss transfer learning.

Let’s see what we can do with pretrained classification CNNs.

GoogLeNet

GoogLeNet is an architecture developed by Google, that won the ImageNet Large-Scale Visual Recognition Challenge 2014. It can be downloaded and cached with the following code:

C++
import torch
import torchvision # The specialized PyTorch module for computer vision
# Load a pre-trained GoogLeNet CNN
googlenet = torchvision.models.googlenet(weights='DEFAULT', progress=False)
googlenet.eval() # Set the CNN to inference mode
# Load the transformation pipeline that we need to prepare the input tensors
transform = torchvision.models.GoogLeNet_Weights.IMAGENET1K_V1.transforms()

In line 5, ...