0
0
Computer Visionml~10 mins

Jetson Nano deployment in Computer Vision - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to load a pre-trained model on Jetson Nano using PyTorch.

Computer Vision
import torch
model = torch.load('[1]')
Drag options to blanks, or click blank then click option'
A'model.pth'
B'model.txt'
C'data.csv'
D'image.jpg'
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to load a non-model file like a CSV or image.
Using incorrect file extensions.
2fill in blank
medium

Complete the code to move the model to the Jetson Nano GPU device.

Computer Vision
device = torch.device('[1]' if torch.cuda.is_available() else 'cpu')
model.to(device)
Drag options to blanks, or click blank then click option'
A'cpu'
B'cuda'
C'gpu'
D'tpu'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'gpu' or 'tpu' which are not valid device strings in PyTorch.
Not checking if CUDA is available before moving the model.
3fill in blank
hard

Fix the error in the code to preprocess an image for Jetson Nano model inference.

Computer Vision
from torchvision import transforms
preprocess = transforms.Compose([
    transforms.Resize(256),
    transforms.CenterCrop(224),
    transforms.ToTensor(),
    transforms.Normalize(mean=[1], std=[0.229, 0.224, 0.225])
])
Drag options to blanks, or click blank then click option'
A[0.5, 0.5, 0.5]
B[0.229, 0.224, 0.225]
C[0.485, 0.456, 0.406]
D[1.0, 1.0, 1.0]
Attempts:
3 left
💡 Hint
Common Mistakes
Using the std values as mean.
Using incorrect normalization values causing poor model performance.
4fill in blank
hard

Fill both blanks to run inference on Jetson Nano and get the predicted class index.

Computer Vision
with torch.no_grad():
    input_tensor = preprocess(image).unsqueeze(0).to(device)
    output = model([1])
    _, predicted = torch.max(output, [2])
Drag options to blanks, or click blank then click option'
Ainput_tensor
Bdim=1
Cdim=0
Dimage
Attempts:
3 left
💡 Hint
Common Mistakes
Passing raw image instead of tensor to model.
Using wrong dimension in torch.max causing wrong prediction.
5fill in blank
hard

Fill all three blanks to convert model output to probabilities and get top 3 predictions.

Computer Vision
probabilities = torch.nn.functional.[1](output[0])
top_probs, top_idxs = torch.topk(probabilities, [2])
top_probs = top_probs.[3]()
Drag options to blanks, or click blank then click option'
Asoftmax
B3
Ctolist
Dsigmoid
Attempts:
3 left
💡 Hint
Common Mistakes
Using sigmoid instead of softmax for multi-class probabilities.
Forgetting to convert tensor to list for easier use.