open-mmlab/mmdetection · warning
The unexpected output indicates an issue with named entity r
Error message
The unexpected output indicates an issue with named entity recognition. You can try setting custom_entities=True and running again to see if it helps.
What it means
Grounding DINO predict found predicted label indices >= len(entity): the NER-parsed entity list doesn't cover all class slots, so a prediction can't be mapped to a name and is labeled 'unobject'.
Source
Thrown at mmdet/models/detectors/grounding_dino.py:610
data_samples.token_positive_map = token_positive_maps[i]
head_inputs_dict = self.forward_transformer(
visual_feats, text_dict, batch_data_samples)
results_list = self.bbox_head.predict(
**head_inputs_dict,
rescale=rescale,
batch_data_samples=batch_data_samples)
for data_sample, pred_instances, entity, is_rec_task in zip(
batch_data_samples, results_list, entities, is_rec_tasks):
if len(pred_instances) > 0:
label_names = []
for labels in pred_instances.labels:
if is_rec_task:
label_names.append(entity)
continue
if labels >= len(entity):
warnings.warn(
'The unexpected output indicates an issue with '
'named entity recognition. You can try '
'setting custom_entities=True and running '
'again to see if it helps.')
label_names.append('unobject')
else:
label_names.append(entity[labels])
# for visualization
pred_instances.label_names = label_names
data_sample.pred_instances = pred_instances
return batch_data_samples
View on GitHub (pinned to cfd5d3a985)
Solutions
- Use custom_entities=True with an explicit entity list
- Rewrite the caption as period-separated phrases
Example fix
# before results = detector(inputs, texts=['red car and blue bus on street']) # after results = detector(inputs, texts=['red car . blue bus .'], custom_entities=True)
Defensive patterns
Strategy: validation
Validate before calling
entities = [e for e in my_categories] # explicit list caption = ' . '.join(my_categories) results = detector(inputs, texts=[caption], custom_entities=True)
Prevention
- Avoid free-form captions for grounding; use explicit entity lists
- Validate len(entities) covers expected class indices before predict
When it happens
Trigger: Predicting with a caption where entity parsing yields fewer entities than the positive map implies (re-caption task skips this; recognition task hits it).
Common situations: Free-form captions with unusual punctuation; captions not following the 'phrase . phrase .' convention.
Related errors
- The unexpected output indicates an issue with named entity r
- If you want to reduce GPU memory usage,
- There is not post_norm in {name}
- Inputting a text that is too long will result in poor predic
- The annotation file of Open Images Challenge should be a txt
AI-assisted analysis of open-mmlab/mmdetection@cfd5d3a985 (2026-08-27).
Data as JSON: /api/errors/3926cba7c25f16d7.
Report an issue: GitHub.