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.
Bu egzersiz
Deep Learning for Images with PyTorch
kursunun bir parçasıdırEgzersiz talimatları
- Import
MultiScaleRoIAlignfromtorchvision.ops. - Instantiate the RoI pooler using
MultiScaleRoIAlignwithfeatmap_namesset to["0"],output_sizeto7, andsampling_ratioto2. - Create the Faster R-CNN model passing it the
backbone,num_classfor a binary classification,anchor_generator, androi_pooler.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
# Import MultiScaleRoIAlign
____
# Instantiate RoI pooler
roi_pooler = ____(
____,
____,
____,
)
mobilenet = torchvision.models.mobilenet_v2(weights="DEFAULT")
backbone = nn.Sequential(*list(mobilenet.features.children()))
backbone.out_channels = 1280
# Create Faster R-CNN model
model = ____(
backbone=____
num_classes=____,
anchor_generator=____,
box_roi_pool=____,
)