Skip to content

Commit 46f6083

Browse files
authored
Changes to assert to ValueError in achor utils (#2960)
* changes to value error * fixes it :) * simpler fix
1 parent 7f7ff05 commit 46f6083

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

torchvision/models/detection/anchor_utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@ def grid_anchors(self, grid_sizes, strides):
100100
anchors = []
101101
cell_anchors = self.cell_anchors
102102
assert cell_anchors is not None
103-
assert len(grid_sizes) == len(strides) == len(cell_anchors)
103+
104+
if not (len(grid_sizes) == len(strides) == len(cell_anchors)):
105+
raise ValueError("Achors should be Tuple[Tuple[int]] because each feature "
106+
"map could potentially have different sizes and aspect ratios. "
107+
"There needs to be a match between the number of "
108+
"feature maps passed and the number of sizes / aspect ratios specified.")
104109

105110
for size, stride, base_anchors in zip(
106111
grid_sizes, strides, cell_anchors

0 commit comments

Comments
 (0)