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

During GLIP predict, a predicted label index is >= the number of parsed entities, meaning the label-to-entity mapping from named entity recognition (NER) is inconsistent with the detector's class outputs. The unmatched label is named 'unobject'.

Source

Thrown at mmdet/models/detectors/glip.py:579

        else:
            language_dict_features = self.language_model(list(text_prompts))

            for i, data_samples in enumerate(batch_data_samples):
                data_samples.token_positive_map = token_positive_maps[i]

            results_list = self.bbox_head.predict(
                visual_features,
                language_dict_features,
                batch_data_samples,
                rescale=rescale)

        for data_sample, pred_instances, entity in zip(batch_data_samples,
                                                       results_list, entities):
            if len(pred_instances) > 0:
                label_names = []
                for labels in pred_instances.labels:
                    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

  1. Set custom_entities=True and pass an explicit entity list matching your categories
  2. Format the caption as period-separated phrases ('person . dog .') which GLIP parses reliably

Example fix

# before
results = glip_detector(inputs, texts=['a person walking a dog'])
# after
results = glip_detector(inputs, texts=['person . dog .'], custom_entities=True)
Defensive patterns

Strategy: validation

Validate before calling

_, _, _, entities = detector.get_tokens_and_prompts(caption, custom_entities=True)
assert entities and len(entities) >= 1
# pass custom_entities=True with an explicit list matching categories

Prevention

When it happens

Trigger: Predicting with a caption whose NER-parsed entity list is shorter than the positive map classes — often with punctuation-heavy or oddly formatted captions.

Common situations: Zero-shot grounding with free-form captions; captions where spaCy NER mis-splits phrases.

Related errors


AI-assisted analysis of open-mmlab/mmdetection@cfd5d3a985 (2026-08-27). Data as JSON: /api/errors/3ce2ab645faf3539. Report an issue: GitHub.