Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qwen2-vl-2b-instruct版本微调自己的数据集之后,训练正常,推理报错:IndexError: index 1 is out of bounds for dimension 0 with size 1 #599

Open
xgl0626 opened this issue Dec 16, 2024 · 2 comments

Comments

@xgl0626
Copy link

xgl0626 commented Dec 16, 2024

IndexError Traceback (most recent call last)
Cell In[1], line 41
37 text = processor.apply_chat_template(
38 messages, tokenize=False, add_generation_prompt=True
39 )
40 image_inputs, video_inputs = process_vision_info(messages)
---> 41 inputs = processor(
42 text=[text],
43 images=image_inputs,
44 videos=video_inputs,
45 padding=True,
46 return_tensors="pt",
47 )
48 inputs = inputs.to("cuda")
49 # Inference: Generation of the output

File ~/miniconda3/lib/python3.12/site-packages/transformers/models/qwen2_vl/processing_qwen2_vl.py:137, in Qwen2VLProcessor.call(self, images, text, videos, **kwargs)
134 for i in range(len(text)):
135 while "<|image_pad|>" in text[i]:
136 text[i] = text[i].replace(
--> 137 "<|image_pad|>", "<|placeholder|>" * (image_grid_thw[index].prod() // merge_length), 1
138 )
139 index = 1
140 text[i] = text[i].replace("<|placeholder|>", "<|image_pad|>")

IndexError: index 1 is out of bounds for dimension 0 with size 1

@xgl0626
Copy link
Author

xgl0626 commented Dec 16, 2024

将设置的prompt改成这句prompt,Describe this image. 就正常了,感觉很奇怪

@JingbiaoMei
Copy link

JingbiaoMei commented Dec 29, 2024

I got this similar issue:

anaconda3/envs/llamafact/lib/python3.10/site-packages/transformers/models/qwen2_vl/processing_qwen2_vl.py", line 143, in __call__
    "<|image_pad|>", "<|placeholder|>" * (image_grid_thw[index].prod() // merge_length), 1
IndexError: index 1 is out of bounds for dimension 0 with size 1

However, this is due to the wrong batching setting, i.e., the bz of image and text are inconsistent. By fixing the batching setting, the error can be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants