open-mmlab/mmdetection · info
'num_dn_queries' should be set when using dynamic dn groups,
Error message
'num_dn_queries' should be set when using dynamic dn groups, use 100 as default.
What it means
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.
Source
Thrown at mmdet/models/layers/transformer/dino_layers.py:166
num_classes: int,
embed_dims: int,
num_matching_queries: int,
label_noise_scale: float = 0.5,
box_noise_scale: float = 1.0,
group_cfg: OptConfigType = None) -> None:
super().__init__()
self.num_classes = num_classes
self.embed_dims = embed_dims
self.num_matching_queries = num_matching_queries
self.label_noise_scale = label_noise_scale
self.box_noise_scale = box_noise_scale
# prepare grouping strategy
group_cfg = {} if group_cfg is None else group_cfg
self.dynamic_dn_groups = group_cfg.get('dynamic', True)
if self.dynamic_dn_groups:
if 'num_dn_queries' not in group_cfg:
warnings.warn("'num_dn_queries' should be set when using "
'dynamic dn groups, use 100 as default.')
self.num_dn_queries = group_cfg.get('num_dn_queries', 100)
assert isinstance(self.num_dn_queries, int), \
f'Expected the num_dn_queries to have type int, but got ' \
f'{self.num_dn_queries}({type(self.num_dn_queries)}). '
else:
assert 'num_groups' in group_cfg, \
'num_groups should be set when using static dn groups'
self.num_groups = group_cfg['num_groups']
assert isinstance(self.num_groups, int), \
f'Expected the num_groups to have type int, but got ' \
f'{self.num_groups}({type(self.num_groups)}). '
# NOTE The original repo of DINO set the num_embeddings 92 for coco,
# 91 (0~90) of which represents target classes and the 92 (91)
# indicates `Unknown` class. However, the embedding of `unknown` class
# is not used in the original DINO.
# TODO: num_classes + 1 or num_classes ?View on GitHub (pinned to cfd5d3a985)
Solutions
- Add num_dn_queries (e.g. 100) to group_cfg explicitly
- Or set dynamic=False to use static num_groups behavior
Example fix
# before dn_cfg=dict(group_cfg=dict(dynamic=True, num_groups=5)) # after dn_cfg=dict(group_cfg=dict(dynamic=True, num_dn_queries=100, num_groups=5))
Defensive patterns
Strategy: validation
Validate before calling
group_cfg = cfg.setdefault('group_cfg', {})
if group_cfg.get('dynamic', True):
group_cfg.setdefault('num_dn_queries', 100) # set explicitly to silence Prevention
- Always specify num_dn_queries when dynamic dn groups are enabled
- Copy group_cfg blocks verbatim from official DINO configs
When it happens
Trigger: Configuring DINO/Deformable-DETR-with-DINO with group_cfg=dict(dynamic=True) but no num_dn_queries key.
Common situations: Custom DINO configs copied from docs where group_cfg only sets num_groups; porting configs across mmdet versions.
Related errors
- DETR do not build sampler.
- Invalid text mode "{self.text_mode}".
- The type of frame_range must be int or list.
- results does not contain masks.
- {metric} is not in results
AI-assisted analysis of open-mmlab/mmdetection@cfd5d3a985 (2026-08-27).
Data as JSON: /api/errors/dc9e03740849790f.
Report an issue: GitHub.