Closed LilCong closed 1 year ago
/home/jgzn/anaconda/envs/XrayGpt/lib/python3.9/site-packages/transformers/generation/utils.py:1255: UserWarning: You have modified the pretrained model configuration to control generation. This is a deprecated strategy to control generation and will be removed soon, in a future version. Please use a generation configuration file (see https://huggingface.co/docs/transformers/main_classes/text_generation) warnings.warn( ╭───────────────────── Traceback (most recent call last) ──────────────────────╮ │ /home/jgzn/PycharmProjects/Xray/XrayGPT-main/demo1.py:69 in │ │ │ │ 66 │ │ 67 question = "Could you provide a detailed description of the given x-ray │ │ 68 chat.ask(question, chat_state) │ │ ❱ 69 answer, output_token = chat.answer(chat_state, img_list, num_beams=1, │ │ 70 │ │ │ │ │ │ │ │ temperature=1, │ │ 71 │ │ │ │ │ │ │ │ max_new_tokens=300, │ │ 72 │ │ │ │ │ │ │ │ max_length=2000) │ │ │ │ /home/jgzn/PycharmProjects/Xray/XrayGPT-main/xraygpt/conversation/conversati │ │ on.py:163 in answer │ │ │ │ 160 │ │ │ │ 161 │ │ embs = embs[:, begin_idx:] │ │ 162 │ │ │ │ ❱ 163 │ │ outputs = self.model.llama_model.generate( │ │ 164 │ │ │ inputs_embeds=embs, │ │ 165 │ │ │ max_new_tokens=max_new_tokens, │ │ 166 │ │ │ stopping_criteria=self.stopping_criteria, │ │ │ │ /home/jgzn/anaconda/envs/XrayGpt/lib/python3.9/site-packages/torch/utils/_co │ │ ntextlib.py:115 in decorate_context │ │ │ │ 112 │ @functools.wraps(func) │ │ 113 │ def decorate_context(*args, kwargs): │ │ 114 │ │ with ctx_factory(): │ │ ❱ 115 │ │ │ return func(args, kwargs) │ │ 116 │ │ │ 117 │ return decorate_context │ │ 118 │ │ │ │ /home/jgzn/anaconda/envs/XrayGpt/lib/python3.9/site-packages/transformers/ge │ │ neration/utils.py:1565 in generate │ │ │ │ 1562 │ │ │ ) │ │ 1563 │ │ │ │ │ 1564 │ │ │ # 13. run sample │ │ ❱ 1565 │ │ │ return self.sample( │ │ 1566 │ │ │ │ input_ids, │ │ 1567 │ │ │ │ logits_processor=logits_processor, │ │ 1568 │ │ │ │ logits_warper=logits_warper, │ │ │ │ /home/jgzn/anaconda/envs/XrayGpt/lib/python3.9/site-packages/transformers/ge │ │ neration/utils.py:2612 in sample │ │ │ │ 2609 │ │ │ model_inputs = self.prepare_inputs_for_generation(input_i │ │ 2610 │ │ │ │ │ 2611 │ │ │ # forward pass to get next token │ │ ❱ 2612 │ │ │ outputs = self( │ │ 2613 │ │ │ │ model_inputs, │ │ 2614 │ │ │ │ return_dict=True, │ │ 2615 │ │ │ │ output_attentions=output_attentions, │ │ │ │ /home/jgzn/anaconda/envs/XrayGpt/lib/python3.9/site-packages/torch/nn/module │ │ s/module.py:1501 in _call_impl │ │ │ │ 1498 │ │ if not (self._backward_hooks or self._backward_pre_hooks or s │ │ 1499 │ │ │ │ or _global_backward_pre_hooks or _global_backward_hoo │ │ 1500 │ │ │ │ or _global_forward_hooks or _global_forward_pre_hooks │ │ ❱ 1501 │ │ │ return forward_call(args, kwargs) │ │ 1502 │ │ # Do not call functions when jit is used │ │ 1503 │ │ full_backward_hooks, non_full_backward_hooks = [], [] │ │ 1504 │ │ backward_pre_hooks = [] │ │ │ │ /home/jgzn/anaconda/envs/XrayGpt/lib/python3.9/site-packages/accelerate/hook │ │ s.py:156 in new_forward │ │ │ │ 153 │ │ │ with torch.no_grad(): │ │ 154 │ │ │ │ output = old_forward(*args, kwargs) │ │ 155 │ │ else: │ │ ❱ 156 │ │ │ output = old_forward(*args, *kwargs) │ │ 157 │ │ return module._hf_hook.post_forward(module, output) │ │ 158 │ │ │ 159 │ module.forward = new_forward │ │ │ │ /home/jgzn/PycharmProjects/Xray/XrayGPT-main/xraygpt/models/modeling_llama.p │ │ y:676 in forward │ │ │ │ 673 │ │ return_dict = return_dict if return_dict is not None else self │ │ 674 │ │ │ │ 675 │ │ # decoder outputs consists of (dec_features, layerstate, dec │ │ ❱ 676 │ │ outputs = self.model( │ │ 677 │ │ │ input_ids=input_ids, │ │ 678 │ │ │ attention_mask=attention_mask, │ │ 679 │ │ │ position_ids=position_ids, │ │ │ │ /home/jgzn/anaconda/envs/XrayGpt/lib/python3.9/site-packages/torch/nn/module │ │ s/module.py:1501 in _call_impl │ │ │ │ 1498 │ │ if not (self._backward_hooks or self._backward_pre_hooks or s │ │ 1499 │ │ │ │ or _global_backward_pre_hooks or _global_backward_hoo │ │ 1500 │ │ │ │ or _global_forward_hooks or _global_forward_pre_hooks │ │ ❱ 1501 │ │ │ return forward_call(args, kwargs) │ │ 1502 │ │ # Do not call functions when jit is used │ │ 1503 │ │ full_backward_hooks, non_full_backward_hooks = [], [] │ │ 1504 │ │ backward_pre_hooks = [] │ │ │ │ /home/jgzn/anaconda/envs/XrayGpt/lib/python3.9/site-packages/accelerate/hook │ │ s.py:156 in new_forward │ │ │ │ 153 │ │ │ with torch.no_grad(): │ │ 154 │ │ │ │ output = old_forward(*args, *kwargs) │ │ 155 │ │ else: │ │ ❱ 156 │ │ │ output = old_forward(args, **kwargs) │ │ 157 │ │ return module._hf_hook.post_forward(module, output) │ │ 158 │ │ │ 159 │ module.forward = new_forward │ │ │ │ /home/jgzn/PycharmProjects/Xray/XrayGPT-main/xraygpt/models/modeling_llama.p │ │ y:517 in forward │ │ │ │ 514 │ │ │ ) │ │ 515 │ │ │ position_ids = position_ids.unsqueeze(0).view(-1, seq_leng │ │ 516 │ │ else: │ │ ❱ 517 │ │ │ position_ids = position_ids.view(-1, seq_length).long() │ │ 518 │ │ │ │ 519 │ │ # embed positions │ │ 520 │ │ if attention_mask is None: │ ╰──────────────────────────────────────────────────────────────────────────────╯ RuntimeError: shape '[-1, 104]' is invalid for input of size 105
/home/jgzn/anaconda/envs/XrayGpt/lib/python3.9/site-packages/transformers/generation/utils.py:1255: UserWarning: You have modified the pretrained model configuration to control generation. This is a deprecated strategy to control generation and will be removed soon, in a future version. Please use a generation configuration file (see https://huggingface.co/docs/transformers/main_classes/text_generation) warnings.warn( ╭───────────────────── Traceback (most recent call last) ──────────────────────╮ │ /home/jgzn/PycharmProjects/Xray/XrayGPT-main/demo1.py:69 in │
│ │
│ 66 │
│ 67 question = "Could you provide a detailed description of the given x-ray │
│ 68 chat.ask(question, chat_state) │
│ ❱ 69 answer, output_token = chat.answer(chat_state, img_list, num_beams=1, │
│ 70 │ │ │ │ │ │ │ │ temperature=1, │
│ 71 │ │ │ │ │ │ │ │ max_new_tokens=300, │
│ 72 │ │ │ │ │ │ │ │ max_length=2000) │
│ │
│ /home/jgzn/PycharmProjects/Xray/XrayGPT-main/xraygpt/conversation/conversati │
│ on.py:163 in answer │
│ │
│ 160 │ │ │
│ 161 │ │ embs = embs[:, begin_idx:] │
│ 162 │ │ │
│ ❱ 163 │ │ outputs = self.model.llama_model.generate( │
│ 164 │ │ │ inputs_embeds=embs, │
│ 165 │ │ │ max_new_tokens=max_new_tokens, │
│ 166 │ │ │ stopping_criteria=self.stopping_criteria, │
│ │
│ /home/jgzn/anaconda/envs/XrayGpt/lib/python3.9/site-packages/torch/utils/_co │
│ ntextlib.py:115 in decorate_context │
│ │
│ 112 │ @functools.wraps(func) │
│ 113 │ def decorate_context(*args, kwargs): │
│ 114 │ │ with ctx_factory(): │
│ ❱ 115 │ │ │ return func(args, kwargs) │
│ 116 │ │
│ 117 │ return decorate_context │
│ 118 │
│ │
│ /home/jgzn/anaconda/envs/XrayGpt/lib/python3.9/site-packages/transformers/ge │
│ neration/utils.py:1565 in generate │
│ │
│ 1562 │ │ │ ) │
│ 1563 │ │ │ │
│ 1564 │ │ │ # 13. run sample │
│ ❱ 1565 │ │ │ return self.sample( │
│ 1566 │ │ │ │ input_ids, │
│ 1567 │ │ │ │ logits_processor=logits_processor, │
│ 1568 │ │ │ │ logits_warper=logits_warper, │
│ │
│ /home/jgzn/anaconda/envs/XrayGpt/lib/python3.9/site-packages/transformers/ge │
│ neration/utils.py:2612 in sample │
│ │
│ 2609 │ │ │ model_inputs = self.prepare_inputs_for_generation(input_i │
│ 2610 │ │ │ │
│ 2611 │ │ │ # forward pass to get next token │
│ ❱ 2612 │ │ │ outputs = self( │
│ 2613 │ │ │ │ model_inputs, │
│ 2614 │ │ │ │ return_dict=True, │
│ 2615 │ │ │ │ output_attentions=output_attentions, │
│ │
│ /home/jgzn/anaconda/envs/XrayGpt/lib/python3.9/site-packages/torch/nn/module │
│ s/module.py:1501 in _call_impl │
│ │
│ 1498 │ │ if not (self._backward_hooks or self._backward_pre_hooks or s │
│ 1499 │ │ │ │ or _global_backward_pre_hooks or _global_backward_hoo │
│ 1500 │ │ │ │ or _global_forward_hooks or _global_forward_pre_hooks │
│ ❱ 1501 │ │ │ return forward_call(args, kwargs) │
│ 1502 │ │ # Do not call functions when jit is used │
│ 1503 │ │ full_backward_hooks, non_full_backward_hooks = [], [] │
│ 1504 │ │ backward_pre_hooks = [] │
│ │
│ /home/jgzn/anaconda/envs/XrayGpt/lib/python3.9/site-packages/accelerate/hook │
│ s.py:156 in new_forward │
│ │
│ 153 │ │ │ with torch.no_grad(): │
│ 154 │ │ │ │ output = old_forward(*args, kwargs) │
│ 155 │ │ else: │
│ ❱ 156 │ │ │ output = old_forward(*args, *kwargs) │
│ 157 │ │ return module._hf_hook.post_forward(module, output) │
│ 158 │ │
│ 159 │ module.forward = new_forward │
│ │
│ /home/jgzn/PycharmProjects/Xray/XrayGPT-main/xraygpt/models/modeling_llama.p │
│ y:676 in forward │
│ │
│ 673 │ │ return_dict = return_dict if return_dict is not None else self │
│ 674 │ │ │
│ 675 │ │ # decoder outputs consists of (dec_features, layerstate, dec │
│ ❱ 676 │ │ outputs = self.model( │
│ 677 │ │ │ input_ids=input_ids, │
│ 678 │ │ │ attention_mask=attention_mask, │
│ 679 │ │ │ position_ids=position_ids, │
│ │
│ /home/jgzn/anaconda/envs/XrayGpt/lib/python3.9/site-packages/torch/nn/module │
│ s/module.py:1501 in _call_impl │
│ │
│ 1498 │ │ if not (self._backward_hooks or self._backward_pre_hooks or s │
│ 1499 │ │ │ │ or _global_backward_pre_hooks or _global_backward_hoo │
│ 1500 │ │ │ │ or _global_forward_hooks or _global_forward_pre_hooks │
│ ❱ 1501 │ │ │ return forward_call(args, kwargs) │
│ 1502 │ │ # Do not call functions when jit is used │
│ 1503 │ │ full_backward_hooks, non_full_backward_hooks = [], [] │
│ 1504 │ │ backward_pre_hooks = [] │
│ │
│ /home/jgzn/anaconda/envs/XrayGpt/lib/python3.9/site-packages/accelerate/hook │
│ s.py:156 in new_forward │
│ │
│ 153 │ │ │ with torch.no_grad(): │
│ 154 │ │ │ │ output = old_forward(*args, *kwargs) │
│ 155 │ │ else: │
│ ❱ 156 │ │ │ output = old_forward(args, **kwargs) │
│ 157 │ │ return module._hf_hook.post_forward(module, output) │
│ 158 │ │
│ 159 │ module.forward = new_forward │
│ │
│ /home/jgzn/PycharmProjects/Xray/XrayGPT-main/xraygpt/models/modeling_llama.p │
│ y:517 in forward │
│ │
│ 514 │ │ │ ) │
│ 515 │ │ │ position_ids = position_ids.unsqueeze(0).view(-1, seq_leng │
│ 516 │ │ else: │
│ ❱ 517 │ │ │ position_ids = position_ids.view(-1, seq_length).long() │
│ 518 │ │ │
│ 519 │ │ # embed positions │
│ 520 │ │ if attention_mask is None: │
╰──────────────────────────────────────────────────────────────────────────────╯
RuntimeError: shape '[-1, 104]' is invalid for input of size 105