Skip to content
New issue

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

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

Already on GitHub? # to your account

transformer推理代码报错提示设置padding=True #625

Open
kusen-okawa opened this issue Dec 30, 2024 · 1 comment
Open

transformer推理代码报错提示设置padding=True #625

kusen-okawa opened this issue Dec 30, 2024 · 1 comment

Comments

@kusen-okawa
Copy link

Traceback (most recent call last):
File "/mnt/lustre/GPU4/home/zhangchuanyu/miniconda3/envs/cuda118_llama_factory/lib/python3.10/site-packages/transformers/feature_extraction_utils.py", line 193, in convert_to_tensors
tensor = as_tensor(value)
File "/mnt/lustre/GPU4/home/zhangchuanyu/miniconda3/envs/cuda118_llama_factory/lib/python3.10/site-packages/transformers/feature_extraction_utils.py", line 150, in as_tensor
return torch.from_numpy(value)
TypeError: expected np.ndarray (got numpy.ndarray)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/mnt/lustre/GPU4/home/zhangchuanyu/jiedi/LLaMA-Factory/qwen2vl/main.py", line 50, in
inputs = processor(
File "/mnt/lustre/GPU4/home/zhangchuanyu/miniconda3/envs/cuda118_llama_factory/lib/python3.10/site-packages/transformers/models/qwen2_vl/processing_qwen2_vl.py", line 115, in call
image_inputs = self.image_processor(images=images, videos=None, **output_kwargs["images_kwargs"])
File "/mnt/lustre/GPU4/home/zhangchuanyu/miniconda3/envs/cuda118_llama_factory/lib/python3.10/site-packages/transformers/image_processing_utils.py", line 41, in call
return self.preprocess(images, **kwargs)
File "/mnt/lustre/GPU4/home/zhangchuanyu/miniconda3/envs/cuda118_llama_factory/lib/python3.10/site-packages/transformers/models/qwen2_vl/image_processing_qwen2_vl.py", line 458, in preprocess
return BatchFeature(data=data, tensor_type=return_tensors)
File "/mnt/lustre/GPU4/home/zhangchuanyu/miniconda3/envs/cuda118_llama_factory/lib/python3.10/site-packages/transformers/feature_extraction_utils.py", line 79, in init
self.convert_to_tensors(tensor_type=tensor_type)
File "/mnt/lustre/GPU4/home/zhangchuanyu/miniconda3/envs/cuda118_llama_factory/lib/python3.10/site-packages/transformers/feature_extraction_utils.py", line 199, in convert_to_tensors
raise ValueError(
ValueError: Unable to create tensor, you should probably activate padding with 'padding=True' to have batched tensors with the same length.

完全复制的测试代码,padding设置为True,但报错了

@awei669
Copy link

awei669 commented Jan 22, 2025

降低numpy的版本到1.x应该就不会报错了

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

No branches or pull requests

2 participants