1. Learn
  2. /
  3. Courses
  4. /
  5. Deep Learning for Images with PyTorch

Connected

Exercise

Faster R-CNN model

Your next task is to build a Faster R-CNN model that can detect objects of different sizes in an image. For this task, you will be using a handy class MultiScaleRoIAlign() from torchvision.ops.

FasterRCNN class has been imported from torchvision.models.detection. Your anchor_generator from the last exercise is available in your workspace and torch, torch.nn as nn, and torchvision have been imported.

Instructions

100 XP
  • Import MultiScaleRoIAlign from torchvision.ops.
  • Instantiate the RoI pooler using MultiScaleRoIAlign with featmap_names set to ["0"], output_size to 7, and sampling_ratio to 2.
  • Create the Faster R-CNN model passing it the backbone, num_class for a binary classification, anchor_generator, and roi_pooler.