From 88dfe489f014ad46898fb91861e3368ef990408c Mon Sep 17 00:00:00 2001 From: Jinhyung Park Date: Thu, 19 Oct 2023 22:18:15 -0400 Subject: [PATCH] Fix Grounding DINO nan when class tokens exceeds 256 (#11066) --- mmdet/models/detectors/grounding_dino.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mmdet/models/detectors/grounding_dino.py b/mmdet/models/detectors/grounding_dino.py index 69d398bec8f..24518e62edd 100644 --- a/mmdet/models/detectors/grounding_dino.py +++ b/mmdet/models/detectors/grounding_dino.py @@ -113,7 +113,11 @@ def get_tokens_and_prompts( return tokenized, caption_string, tokens_positive, entities def get_positive_map(self, tokenized, tokens_positive): - positive_map = create_positive_map(tokenized, tokens_positive) + positive_map = create_positive_map( + tokenized, + tokens_positive, + max_num_entities=self.bbox_head.cls_branches[ + self.decoder.num_layers].max_text_len) positive_map_label_to_token = create_positive_map_label_to_token( positive_map, plus=1) return positive_map_label_to_token, positive_map