Closed ykwongaq closed 3 months ago
same erro. have you fix it?
Nope, I guess I need to wait for the author to fix it.
@ykwongaq Hello, I have a solution here: In transformers/models/bert/modeling_bert.py, I replaced lines 1104-1106 with extended_attention_mask = self.get_extended_attention_mask(attention_mask, input_shape)
After that, the program runs fine and the results seem to be correct. But I'm not sure this is the right answer. Maybe you can try it.
I also have the same problem, thanks for your solution!
same issue......issue occurs with all of the grounding-dino model that use Bert as a language model (all of them do i think).........problems seems to be in mmdet/models/language_models/bert.py.......generate_masks_with_special_tokens_and_transfer_map( tokenized, special_tokens_list): function
# generate attention mask and positional ids
attention_mask = (
torch.eye(num_token,
device=input_ids.device).bool().unsqueeze(0).repeat(
bs, 1, 1))
position_ids = torch.zeros((bs, num_token), device=input_ids.device)
previous_col = 0
for i in range(idxs.shape[0]):
row, col = idxs[i]
if (col == 0) or (col == num_token - 1):
attention_mask[row, col, col] = True
position_ids[row, col] = 0
else:
attention_mask[row, previous_col + 1:col + 1,
previous_col + 1:col + 1] = True
position_ids[row, previous_col + 1:col + 1] = torch.arange(
0, col - previous_col, device=input_ids.device)
previous_col = col
return attention_mask, position_ids.to(torch.long)l
this generates a 3-D attention mask whereas File "/usr/local/lib/python3.10/dist-packages/transformers/models/bert/modeling_bert.py", line 1118, in forward extended_attention_mask = _prepare_4d_attention_mask_for_sdpa( File "/usr/local/lib/python3.10/dist-packages/transformers/modeling_attn_mask_utils.py", line 439, in _prepare_4d_attention_mask_for_sdpa batch_size, key_value_length = mask.shape ValueError: too many values to unpack (expected 2)............./transformers/modeling_attn_mask_utils.py _prepare_4d_attention_mask_for_sdpa expects a 2-D Tensor..........problem with version i guess plz help Thank you
just try to lower the Transformers version.
just try to lower the Transformers version.
any specific version i should downgrade to i am using 4.41.1
just try to lower the Transformers version.
any specific version i should downgrade to i am using 4.41.1
4.38.0 works for me.
@ykwongaq Hello, I have a solution here: In transformers/models/bert/modeling_bert.py, I replaced lines 1104-1106 with
extended_attention_mask = self.get_extended_attention_mask(attention_mask, input_shape)
After that, the program runs fine and the results seem to be correct. But I'm not sure this is the right answer. Maybe you can try it.
Great thanks! It work for me.
Dear mmdetection team,
First of all, thank you so much for creating such a great work for model training. I really apperciated this.
I want to test the Grounding DINO and following the instruction here https://github.com/open-mmlab/mmdetection/blob/main/configs/mm_grounding_dino/usage.md
When I try to execute the inference code for close-set object detection:
I got the following error:
when executing
bsz, scr_len = mask.size()
at anaconda3/envs/openmmlab/lib/python3.8/site-packages/transformers/modeling_attn_mask_utils.py, line 173 in _expand_mask.I checked that
mask.size()
is a 3-dimension value.May I ask which part goes wrong?
Thank you.
Not sure will this be helpful or not but here is my environment: