{"record":{"id":"786bde9a424d0c50","repo":"open-mmlab/mmdetection","slug":"grid-anchors-would-be-deprecated-soon-please","errorCode":null,"errorMessage":"``grid_anchors`` would be deprecated soon. Please use ``grid_priors`` ","messagePattern":"``grid_anchors`` would be deprecated soon\\. Please use ``grid_priors`` ","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"mmdet/models/task_modules/prior_generators/anchor_generator.py","lineNumber":356,"sourceCode":"    def grid_anchors(self,\n                     featmap_sizes: List[Tuple],\n                     device: DeviceType = 'cuda') -> List[Tensor]:\n        \"\"\"Generate grid anchors in multiple feature levels.\n\n        Args:\n            featmap_sizes (list[tuple]): List of feature map sizes in\n                multiple feature levels.\n            device (str | torch.device): Device where the anchors will be\n                put on.\n\n        Return:\n            list[torch.Tensor]: Anchors in multiple feature levels. \\\n                The sizes of each tensor should be [N, 4], where \\\n                N = width * height * num_base_anchors, width and height \\\n                are the sizes of the corresponding feature level, \\\n                num_base_anchors is the number of anchors for that level.\n        \"\"\"\n        warnings.warn('``grid_anchors`` would be deprecated soon. '\n                      'Please use ``grid_priors`` ')\n\n        assert self.num_levels == len(featmap_sizes)\n        multi_level_anchors = []\n        for i in range(self.num_levels):\n            anchors = self.single_level_grid_anchors(\n                self.base_anchors[i].to(device),\n                featmap_sizes[i],\n                self.strides[i],\n                device=device)\n            multi_level_anchors.append(anchors)\n        return multi_level_anchors\n\n    def single_level_grid_anchors(self,\n                                  base_anchors: Tensor,\n                                  featmap_size: Tuple[int, int],\n                                  stride: Tuple[int, int] = (16, 16),\n                                  device: DeviceType = 'cuda') -> Tensor:","sourceCodeStart":338,"sourceCodeEnd":374,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/models/task_modules/prior_generators/anchor_generator.py#L338-L374","documentation":"Deprecation warning from AnchorGenerator.grid_anchors: the anchors-named API is being replaced by the priors API. grid_anchors(featmap_sizes, device) still works (delegating to single_level_grid_anchors) but grid_priors should be used instead.","triggerScenarios":"Calling anchor_generator.grid_anchors(featmap_sizes, device=...); many old unit tests (test_sparse_prior, test_strides, test_retina_anchor, SSD/YOLO anchor tests) and legacy dense heads call it.","commonSituations":"Custom dense heads or tests written against the pre-rename API; mmdet refactored 'anchors' to generic 'priors' to cover non-anchor detectors.","solutions":["Replace grid_anchors(...) with grid_priors(...) (same signature semantics)","Rename any cached attribute usage (e.g. prior caching) accordingly","Update tests referencing grid_anchors"],"exampleFix":"# before\nanchors = self.anchor_generator.grid_anchors(featmap_sizes, device=device)\n# after\npriors = self.prior_generator.grid_priors(featmap_sizes, device=device)","handlingStrategy":"type-guard","validationCode":"assert hasattr(gen, 'grid_priors'), 'generator lacks grid_priors; upgrade mmdet'","typeGuard":"def has_priors_api(gen) -> bool:\n    return hasattr(gen, 'grid_priors') and callable(gen.grid_priors)","tryCatchPattern":null,"preventionTips":["Feature-detect grid_priors before calling","Write heads against the priors API, not anchors"],"tags":["mmdet","deprecation","anchor-generator","priors"],"backgroundTag":"deprecated-api-renamed","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}