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

"list index out of range" when taking single-image input #3

Open
Claber opened this issue Jun 5, 2023 · 1 comment
Open

"list index out of range" when taking single-image input #3

Claber opened this issue Jun 5, 2023 · 1 comment

Comments

@Claber
Copy link
Collaborator

Claber commented Jun 5, 2023

@lonestar234028
code position:
https://github.com/lonestar234028/modelscope/blob/master/modelscope/preprocessors/ofa/visual_question_answering.py#L113

call stack log lines:
/root/code/nlvr/modelscope/reason_step_huge/test_ok_vqa_with_rationals_retri │
│ eval.py:157 in │
│ │
│ 154 │ │ │ │ q_and_a.update({"question_id":int(q.question_id)}) │
│ 155 │ │ │ │ input_batch.append(input_from_question(q)) │
│ 156 │ │ │ │ output_batch.append(q_and_a) │
│ ❱ 157 │ │ │ answer_batch = ofa_pipe(input_batch) │
│ 158 │ │ │ for a, p in zip(answer_batch, output_batch): │
│ 159 │ │ │ │ p.update({"answer" :a[OutputKeys.TEXT][0]}) │
│ 160 │ │ │ │ res.append(p) │
│ │
│ /opt/conda/lib/python3.7/site-packages/modelscope/pipelines/base.py:189 in │
call
│ │
│ 186 │ │ │ if batch_size is None: │
│ 187 │ │ │ │ output = [] │
│ 188 │ │ │ │ for ele in input: │
│ ❱ 189 │ │ │ │ │ output.append(self._process_single(ele, *args, **k │
│ 190 │ │ │ else: │
│ 191 │ │ │ │ output = self._process_batch(input, batch_size, **kwar │
│ 192 │
│ │
│ /opt/conda/lib/python3.7/site-packages/modelscope/pipelines/base.py:228 in │
│ _process_single │
│ │
│ 225 │ │ import copy │
│ 226 │ │ │
│ 227 │ │ all_text_encoders_input = [] │
│ ❱ 228 │ │ out = self.preprocess(input, **preprocess_params) │
│ 229 │ │ if isinstance(input['text'], list): │
│ 230 │ │ │ for item in input['text']: │
│ 231 │ │ │ │ tmp_e = copy.deepcopy(input) │
│ │
│ /opt/conda/lib/python3.7/site-packages/modelscope/pipelines/base.py:365 in │
│ preprocess │
│ │
│ 362 │ │ assert self.preprocessor is not None, 'preprocess method shoul │
│ 363 │ │ assert not isinstance(self.preprocessor, List),\ │
│ 364 │ │ │ 'default implementation does not support using multiple pr │
│ ❱ 365 │ │ return self.preprocessor(inputs, **preprocess_params) │
│ 366 │ │
│ 367 │ def forward(self, inputs: Dict[str, Any], │
│ 368 │ │ │ │ **forward_params) -> Dict[str, Any]: │
│ │
│ /opt/conda/lib/python3.7/site-packages/modelscope/preprocessors/multi_modal. │
│ py:147 in call
│ │
│ 144 │ │ │ data = input │
│ 145 │ │ else: │
│ 146 │ │ │ data = self._build_dict(input) │
│ ❱ 147 │ │ sample = self.preprocess(data) │
│ 148 │ │ str_data = dict() │
│ 149 │ │ for k, v in data.items(): │
│ 150 │ │ │ str_data[k] = str(v) │
│ │
│ /opt/conda/lib/python3.7/site-packages/modelscope/preprocessors/ofa/visual_q │
│ uestion_answering.py:47 in call
│ │
│ 44 │ │ if self.mode == ModeKeys.TRAIN: │
│ 45 │ │ │ return self._build_train_sample(data) │
│ 46 │ │ else: │
│ ❱ 47 │ │ │ return self._build_infer_sample(data) │
│ 48 │ │
│ 49 │ def _build_train_sample(self, data: Dict[str, Any]) -> Dict[str, A │
│ 50 │ │ r""" │
│ │
│ /opt/conda/lib/python3.7/site-packages/modelscope/preprocessors/ofa/visual_q │
│ uestion_answering.py:140 in _build_infer_sample │
│ │
│ 137 │ def _build_infer_sample(self, data: Dict[str, Any]) -> Dict[str, A │
│ 138 │ │ img_info = data[self.column_map['image']] │
│ 139 │ │ if isinstance(img_info, list): │
│ ❱ 140 │ │ │ return self._build_infer_sample_list(data) │
│ 141 │ │ image = self.get_img_pil(img_info) │
│ 142 │ │ │
│ 143 │ │ patch_image = self.patch_resize_transform(image) │
│ │
│ /opt/conda/lib/python3.7/site-packages/modelscope/preprocessors/ofa/visual_q │
│ uestion_answering.py:113 in _build_infer_sample_list │
│ │
│ 110 │ │
│ 111 │ def _build_infer_sample_list(self, data: Dict[str, Any]) -> Dict[s │
│ 112 │ │ image0 = self.get_img_pil(data[self.column_map['image']][0]) │
│ ❱ 113 │ │ image1 = self.get_img_pil(data[self.column_map['image']][1]) │
│ 114 │ │ patch_image = self.patch_resize_transform(image0) │
│ 115 │ │ patch_image_2 = self.patch_resize_transform(image1) │
│ 116 │ │ text = ' {}'.format(data[self.column_map['text']])

@Claber
Copy link
Collaborator Author

Claber commented Jun 5, 2023

if input just contains 'image' as non-list but text as a list, it runs without errors but the to-be-tokenized text will be '{}'.format(data[self.column_map['text']]). Is it supposed to be so?

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

1 participant