0
0
PyTorchml~20 mins

Faster R-CNN usage in PyTorch - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Faster R-CNN Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output shape of Faster R-CNN model predictions
Given the following PyTorch code snippet using a pretrained Faster R-CNN model, what is the type and structure of the output after running the model on a batch of images?
PyTorch
import torch
from torchvision.models.detection import fasterrcnn_resnet50_fpn

model = fasterrcnn_resnet50_fpn(pretrained=True)
model.eval()

images = [torch.rand(3, 300, 400), torch.rand(3, 500, 600)]
outputs = model(images)

print(type(outputs))
print(len(outputs))
print(outputs[0].keys())
Aoutputs is a list of length 2 (one per image), each element is a dict with keys 'boxes', 'labels', and 'scores'.
Boutputs is a tensor of shape (2, 100, 6) containing bounding boxes and labels for all images.
Coutputs is a dict with keys 'boxes', 'labels', and 'scores' containing tensors for all images combined.
Doutputs is a list of length 1 containing a dict with keys 'boxes', 'labels', and 'scores'.
Attempts:
2 left
💡 Hint
Think about how torchvision detection models return predictions for each image separately.
Model Choice
intermediate
1:30remaining
Choosing the right backbone for Faster R-CNN
You want to detect small objects in high-resolution images using Faster R-CNN. Which backbone architecture is generally better for capturing fine details?
AResNet-18 without FPN
BResNet-50 with Feature Pyramid Network (FPN)
CMobileNetV2 without FPN
DVGG16 without FPN
Attempts:
2 left
💡 Hint
Feature Pyramid Network helps detect objects at multiple scales.
Hyperparameter
advanced
2:00remaining
Adjusting Faster R-CNN training for fewer false positives
During training Faster R-CNN, you notice many false positive detections. Which hyperparameter adjustment is most likely to reduce false positives?
AIncrease the batch size to 64
BDecrease the number of proposals generated by RPN
CIncrease the score threshold for predicted boxes during inference
DLower the learning rate drastically
Attempts:
2 left
💡 Hint
False positives can be filtered by confidence score thresholds.
🔧 Debug
advanced
2:00remaining
Identifying error in Faster R-CNN input format
You run this code and get a runtime error: import torch from torchvision.models.detection import fasterrcnn_resnet50_fpn model = fasterrcnn_resnet50_fpn(pretrained=True) model.eval() image = torch.rand(3, 224, 224) output = model(image) What is the cause of the error?
AThe pretrained model cannot run in eval mode.
BThe image tensor must have shape (224, 224, 3) instead of (3, 224, 224).
CThe model requires images to be normalized before input.
DThe model expects a list of images, not a single tensor.
Attempts:
2 left
💡 Hint
Check the expected input type for torchvision detection models.
Metrics
expert
2:30remaining
Evaluating Faster R-CNN with mAP metric
You trained a Faster R-CNN model and want to evaluate its performance using mean Average Precision (mAP) at IoU=0.5. Which statement about mAP is correct?
AmAP@0.5 measures the average precision of detected boxes that have Intersection over Union (IoU) greater than 0.5 with ground truth boxes.
BmAP@0.5 is the average recall of all predicted boxes with confidence scores above 0.5.
CmAP@0.5 counts all predicted boxes regardless of IoU and averages their confidence scores.
DmAP@0.5 is the accuracy of classifying images as containing objects or not.
Attempts:
2 left
💡 Hint
mAP involves precision and IoU thresholds for matching predictions to ground truth.