Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions torchvision/models/detection/anchor_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,25 @@ class AnchorGenerator(nn.Module):
per feature map. This module assumes aspect ratio = height / width for
each anchor.

sizes and aspect_ratios should have the same number of elements, and it should
correspond to the number of feature maps.
For ``N`` feature maps, ``sizes`` and ``aspect_ratios`` should each contain
``N`` tuples. The values in ``sizes[i]`` and ``aspect_ratios[i]`` are used
only for feature map ``i``; they are not distributed across feature maps.
``AnchorGenerator`` outputs ``len(sizes[i]) * len(aspect_ratios[i])`` anchors
per spatial location on that feature map.

sizes[i] and aspect_ratios[i] can have an arbitrary number of elements,
and AnchorGenerator will output a set of sizes[i] * aspect_ratios[i] anchors
per spatial location for feature map i.
``AnchorGenerator`` itself supports a different number of anchors per location
on each feature map. However, detection heads that share prediction layers
across feature maps, such as :class:`~torchvision.models.detection.rpn.RPNHead`,
require the number of anchors per location to be the same for every feature map.

Args:
sizes (Tuple[Tuple[int]]):
aspect_ratios (Tuple[Tuple[float]]):
sizes (Tuple[Tuple[int]]): Anchor sizes for each feature map. For example,
``((32, 64, 128),)`` applies all three sizes to a single feature map,
while ``((32,), (64,), (128,))`` applies one size to each of three
feature maps.
aspect_ratios (Tuple[Tuple[float]]): Anchor aspect ratios for each feature
map, expressed as height divided by width. The outer tuple follows the
same one-to-one feature-map mapping as ``sizes``.
"""

__annotations__ = {
Expand Down