0
0
Computer Visionml~10 mins

Pre-trained detection models 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 object detection model from torchvision.

Computer Vision
import torchvision.models as models
model = models.detection.[1](pretrained=True)
Drag options to blanks, or click blank then click option'
Afasterrcnn_resnet50_fpn
Bresnet50
Cvgg16
Dmobilenet_v2
Attempts:
3 left
💡 Hint
Common Mistakes
Using classification model names instead of detection model names.
Forgetting to set pretrained=True.
2fill in blank
medium

Complete the code to put the model in evaluation mode before inference.

Computer Vision
model = models.detection.fasterrcnn_resnet50_fpn(pretrained=True)
model.[1]()
Drag options to blanks, or click blank then click option'
Atrain
Bfit
Ceval
Dpredict
Attempts:
3 left
💡 Hint
Common Mistakes
Using model.train() which sets training mode.
Trying to call model.predict() which is not a PyTorch method.
3fill in blank
hard

Fix the error in the code to prepare an input image tensor for the detection model.

Computer Vision
from torchvision import transforms
transform = transforms.Compose([
    transforms.ToTensor(),
    transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[[1], 0.224, 0.225])
])
Drag options to blanks, or click blank then click option'
A0.5
B0.229
C1.0
D0.0
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect normalization values causing poor model performance.
Mixing mean and std values.
4fill in blank
hard

Fill both blanks to run inference and get predictions from the model.

Computer Vision
model.eval()
with torch.no_grad():
    predictions = model([[1]])
print(predictions[0][[2]])
Drag options to blanks, or click blank then click option'
Ainput_tensor
Bboxes
Clabels
Dscores
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a single tensor instead of a list.
Trying to print 'labels' instead of 'scores' when checking confidence.
5fill in blank
hard

Fill all three blanks to filter predictions by confidence threshold and extract bounding boxes.

Computer Vision
threshold = 0.8
pred = predictions[0]
scores = pred[[1]]
boxes = pred[[2]]
filtered_boxes = boxes[scores [3] threshold]
Drag options to blanks, or click blank then click option'
Ascores
Bboxes
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up keys 'scores' and 'boxes'.
Using '<' instead of '>' for filtering.