0
0
PyTorchml~20 mins

torchvision detection models in PyTorch - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Torchvision Detection Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Model Choice
intermediate
2:00remaining
Choosing the right torchvision detection model for small objects

You want to detect very small objects in images using torchvision detection models. Which model is generally best suited for this task?

ARetinaNet without FPN
BSSD with a VGG16 backbone
CFaster R-CNN with a ResNet-50 backbone and Feature Pyramid Network (FPN)
DMask R-CNN without any backbone network
Attempts:
2 left
💡 Hint

Think about models that use multi-scale features to detect objects of different sizes.

Predict Output
intermediate
2:00remaining
Output shape of torchvision Faster R-CNN predictions

Given a batch of 2 images passed through a pretrained Faster R-CNN model from torchvision, what is the type and length of the output?

PyTorch
import torch
import torchvision
model = torchvision.models.detection.fasterrcnn_resnet50_fpn(pretrained=True)
model.eval()
inputs = [torch.randn(3, 300, 400), torch.randn(3, 500, 600)]
outputs = model(inputs)
print(type(outputs), len(outputs))
A<class 'list'> 2
B<class 'torch.Tensor'> 2
C<class 'dict'> 2
D<class 'list'> 1
Attempts:
2 left
💡 Hint

Check the model's documentation for output format when passing a list of images.

Hyperparameter
advanced
2:00remaining
Effect of changing the IoU threshold in torchvision detection models

In torchvision's Faster R-CNN, what is the effect of increasing the IoU threshold used in the Non-Maximum Suppression (NMS) step during inference?

AMore overlapping boxes are kept, potentially increasing duplicate detections
BFewer boxes are kept, reducing duplicate detections but possibly missing objects
CThe model trains faster but with lower accuracy
DThe backbone network changes its feature extraction layers
Attempts:
2 left
💡 Hint

Think about what happens when the threshold for overlap to suppress boxes is higher.

🔧 Debug
advanced
2:00remaining
Debugging a runtime error in torchvision Mask R-CNN training

You get the error: 'TypeError: forward() missing 1 required positional argument: "targets"' when training Mask R-CNN from torchvision. What is the most likely cause?

AThe input images are not normalized correctly
BYou forgot to pass the target annotations (bounding boxes and masks) to the model during training
CThe model backbone is not pretrained
DYou passed the targets as a list instead of a dictionary
Attempts:
2 left
💡 Hint

Check the model's forward method signature for training mode.

Metrics
expert
3:00remaining
Interpreting mAP metric for torchvision detection models

You evaluate a torchvision Faster R-CNN model on a test set and get a mean Average Precision (mAP) of 0.75 at IoU=0.5. What does this number mean?

AThe model detects 75% of objects but with no overlap requirement
BThe model's classification accuracy is 75% on detected objects
CThe model's loss during training was 0.75 at IoU=0.5
DOn average, the model correctly detects 75% of objects with at least 50% overlap with ground truth
Attempts:
2 left
💡 Hint

Recall what mAP and IoU thresholds represent in object detection evaluation.