Loading a pre-trained model
You are building an application to label images from the social media. This task requires high accuracy and speed. You are going to use a pre-trained ResNet18 model to infer image classes.
Bu egzersiz
Deep Learning for Images with PyTorch
kursunun bir parçasıdırEgzersiz talimatları
- Import
resnet18andResNet18_Weightsfromtorchvision.models. - Instantiate the
modelusingresnet18(), setting the weights parameter toweights. - Set
modelto the evaluation mode. - Initialize the input transforms and assign them to
transform.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
# Import resnet18 model
from torchvision.models import ____
# Initialize model with default weights
weights = ResNet18_Weights.DEFAULT
model = ____
# Set model to evaluation mode
model.____
# Initialize the transforms
transform = ____