{"record":{"id":"dc9e03740849790f","repo":"open-mmlab/mmdetection","slug":"num-dn-queries-should-be-set-when-using-dynamic","errorCode":null,"errorMessage":"'num_dn_queries' should be set when using dynamic dn groups, use 100 as default.","messagePattern":"'num_dn_queries' should be set when using dynamic dn groups, use 100 as default\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"mmdet/models/layers/transformer/dino_layers.py","lineNumber":166,"sourceCode":"                 num_classes: int,\n                 embed_dims: int,\n                 num_matching_queries: int,\n                 label_noise_scale: float = 0.5,\n                 box_noise_scale: float = 1.0,\n                 group_cfg: OptConfigType = None) -> None:\n        super().__init__()\n        self.num_classes = num_classes\n        self.embed_dims = embed_dims\n        self.num_matching_queries = num_matching_queries\n        self.label_noise_scale = label_noise_scale\n        self.box_noise_scale = box_noise_scale\n\n        # prepare grouping strategy\n        group_cfg = {} if group_cfg is None else group_cfg\n        self.dynamic_dn_groups = group_cfg.get('dynamic', True)\n        if self.dynamic_dn_groups:\n            if 'num_dn_queries' not in group_cfg:\n                warnings.warn(\"'num_dn_queries' should be set when using \"\n                              'dynamic dn groups, use 100 as default.')\n            self.num_dn_queries = group_cfg.get('num_dn_queries', 100)\n            assert isinstance(self.num_dn_queries, int), \\\n                f'Expected the num_dn_queries to have type int, but got ' \\\n                f'{self.num_dn_queries}({type(self.num_dn_queries)}). '\n        else:\n            assert 'num_groups' in group_cfg, \\\n                'num_groups should be set when using static dn groups'\n            self.num_groups = group_cfg['num_groups']\n            assert isinstance(self.num_groups, int), \\\n                f'Expected the num_groups to have type int, but got ' \\\n                f'{self.num_groups}({type(self.num_groups)}). '\n\n        # NOTE The original repo of DINO set the num_embeddings 92 for coco,\n        # 91 (0~90) of which represents target classes and the 92 (91)\n        # indicates `Unknown` class. However, the embedding of `unknown` class\n        # is not used in the original DINO.\n        # TODO: num_classes + 1 or num_classes ?","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/models/layers/transformer/dino_layers.py#L148-L184","documentation":"DINO's CdnQueryGenerator warns that dynamic denoising group config lacks num_dn_queries and falls back to 100 noised queries per image. With dynamic groups, num_dn_queries (rather than num_groups alone) controls how many DN queries are generated.","triggerScenarios":"Configuring DINO/Deformable-DETR-with-DINO with group_cfg=dict(dynamic=True) but no num_dn_queries key.","commonSituations":"Custom DINO configs copied from docs where group_cfg only sets num_groups; porting configs across mmdet versions.","solutions":["Add num_dn_queries (e.g. 100) to group_cfg explicitly","Or set dynamic=False to use static num_groups behavior"],"exampleFix":"# before\ndn_cfg=dict(group_cfg=dict(dynamic=True, num_groups=5))\n# after\ndn_cfg=dict(group_cfg=dict(dynamic=True, num_dn_queries=100, num_groups=5))","handlingStrategy":"validation","validationCode":"group_cfg = cfg.setdefault('group_cfg', {})\nif group_cfg.get('dynamic', True):\n    group_cfg.setdefault('num_dn_queries', 100)  # set explicitly to silence","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always specify num_dn_queries when dynamic dn groups are enabled","Copy group_cfg blocks verbatim from official DINO configs"],"tags":["mmdet","dino","detr","config"],"backgroundTag":"missing-config-field","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}