Stanford-AIMI / CheXagent

[Arxiv-2024] CheXagent: Towards a Foundation Model for Chest X-Ray Interpretation
https://stanford-aimi.github.io/chexagent.html
118 stars 9 forks source link

RuntimeError: Input type (torch.cuda.HalfTensor) and weight type (torch.HalfTensor) should be the same #9

Open milky-FatJay opened 11 hours ago

milky-FatJay commented 11 hours ago

Traceback (most recent call last): File "/home/yanghaofeng/Models/CheXagent/start.py", line 28, in output = model.generate(inputs, generation_config=generation_config)[0] File "/home/yanghaofeng/anaconda3/envs/llava-med/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context return func(*args, *kwargs) File "/home/yanghaofeng/.cache/huggingface/modules/transformers_modules/CheXagent/modeling_chexagent.py", line 1252, in generate vision_outputs = self.vision_model(pixel_values[image_mask], return_dict=True) File "/home/yanghaofeng/anaconda3/envs/llava-med/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl return self._call_impl(args, kwargs) File "/home/yanghaofeng/anaconda3/envs/llava-med/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl return forward_call(*args, kwargs) File "/home/yanghaofeng/.cache/huggingface/modules/transformers_modules/CheXagent/modeling_chexagent.py", line 334, in forward hidden_states = self.embeddings(pixel_values) File "/home/yanghaofeng/anaconda3/envs/llava-med/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "/home/yanghaofeng/anaconda3/envs/llava-med/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl return forward_call(args, kwargs) File "/home/yanghaofeng/.cache/huggingface/modules/transformers_modules/CheXagent/modeling_chexagent.py", line 81, in forward patch_embeds = self.patch_embedding(pixel_values.to(dtype=target_dtype)) # shape = [, width, grid, grid] File "/home/yanghaofeng/anaconda3/envs/llava-med/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl return self._call_impl(args, *kwargs) File "/home/yanghaofeng/anaconda3/envs/llava-med/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl return forward_call(args, **kwargs) File "/home/yanghaofeng/anaconda3/envs/llava-med/lib/python3.10/site-packages/torch/nn/modules/conv.py", line 554, in forward return self._conv_forward(input, self.weight, self.bias) File "/home/yanghaofeng/anaconda3/envs/llava-med/lib/python3.10/site-packages/torch/nn/modules/conv.py", line 549, in _conv_forward return F.conv2d( RuntimeError: Input type (torch.cuda.HalfTensor) and weight type (torch.HalfTensor) should be the same What is the reason for this error,it is strange

milky-FatJay commented 11 hours ago

Traceback (most recent call last): File "/home/yanghaofeng/Models/CheXagent/start.py", line 28, in output = model.generate(inputs, generation_config=generation_config)[0] File "/home/yanghaofeng/anaconda3/envs/llava-med/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context return func(*args, *kwargs) File "/home/yanghaofeng/.cache/huggingface/modules/transformers_modules/CheXagent/modeling_chexagent.py", line 1252, in generate vision_outputs = self.vision_model(pixel_values[image_mask], return_dict=True) File "/home/yanghaofeng/anaconda3/envs/llava-med/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl return self._call_impl(args, kwargs) File "/home/yanghaofeng/anaconda3/envs/llava-med/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl return forward_call(*args, kwargs) File "/home/yanghaofeng/.cache/huggingface/modules/transformers_modules/CheXagent/modeling_chexagent.py", line 334, in forward hidden_states = self.embeddings(pixel_values) File "/home/yanghaofeng/anaconda3/envs/llava-med/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl return self._call_impl(args, kwargs) File "/home/yanghaofeng/anaconda3/envs/llava-med/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl return forward_call(_args, kwargs) File "/home/yanghaofeng/.cache/huggingface/modules/transformers_modules/CheXagent/modeling_chexagent.py", line 81, in forward patch_embeds = self.patch_embedding(pixel_values.to(dtype=targetdtype)) # shape = [, width, grid, grid] File "/home/yanghaofeng/anaconda3/envs/llava-med/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1736, in _wrapped_call_impl return self._call_impl(args, kwargs) File "/home/yanghaofeng/anaconda3/envs/llava-med/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1747, in _call_impl return forward_call(*args, **kwargs) File "/home/yanghaofeng/anaconda3/envs/llava-med/lib/python3.10/site-packages/torch/nn/modules/conv.py", line 554, in forward return self._conv_forward(input, self.weight, self.bias) File "/home/yanghaofeng/anaconda3/envs/llava-med/lib/python3.10/site-packages/torch/nn/modules/conv.py", line 549, in _conv_forward return F.conv2d( RuntimeError: Input type (torch.cuda.HalfTensor) and weight type (torch.HalfTensor) should be the same What is the reason for this error,it is strange

I have solved the problem