Get Started

Anchor generator

Your team is developing object detection models based on the Faster R-CNN architecture and using pre-trained backbones. Your task is to create anchor boxes to serve as reference bounding boxes for proposing potential object regions.

You will create 9 standard anchors (3 box sizes and 3 aspect ratios).

torch has been import for you.

This is a part of the course

“Deep Learning for Images with PyTorch”

View Course

Exercise instructions

  • Import AnchorGenerator from torchvision.models.detection.rpn.
  • Configure anchor sizes with 3 values: ((32, 64, 128),).
  • Configure aspect ratio with 3 values `((0.5, 1.0, 2.0),).
  • Instantiate AnchorGenerator with anchor_sizes and aspect_ratios.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Import AnchorGenerator
____

# Configure anchor size
anchor_sizes = ____

# Configure aspect ratio
aspect_ratios = ____

# Instantiate AnchorGenerator
rpn_anchor_generator = ____

This exercise is part of the course

Deep Learning for Images with PyTorch

AdvancedSkill Level
4.6+
5 reviews

Apply PyTorch to images and use deep learning models for object detection with bounding boxes and image segmentation generation.

Detect objects in images by predicting bounding boxes around them and evaluate the performance of object recognition models.

Exercise 1: Bounding boxesExercise 2: Object recognitionExercise 3: Image tensorsExercise 4: Drawing a bounding boxExercise 5: Evaluating object recognition modelsExercise 6: Calculate IoUExercise 7: Bounding boxes predictionExercise 8: Calculate NMSExercise 9: Object detection using R-CNNExercise 10: Pre-trained model backboneExercise 11: Classifier blockExercise 12: Box regressor blockExercise 13: Region network proposals with Faster R-CNNExercise 14: Anchor generator
Exercise 15: Faster R-CNN modelExercise 16: Define losses for RPN and R-CNN

What is DataCamp?

Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.

Start Learning for Free