Browse Source

fix 不必要的init和优化vqa的preprocessor

Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/10868091
master^2
yichang.zyc yingda.chen 2 years ago
parent
commit
ebb9636179
3 changed files with 4 additions and 4 deletions
  1. +0
    -1
      modelscope/pipelines/base.py
  2. +4
    -2
      modelscope/preprocessors/ofa/visual_question_answering.py
  3. +0
    -1
      requirements/multi-modal.txt

+ 0
- 1
modelscope/pipelines/base.py View File

@@ -168,7 +168,6 @@ class Pipeline(ABC):
kwargs['preprocess_params'] = preprocess_params
kwargs['forward_params'] = forward_params
kwargs['postprocess_params'] = postprocess_params

if isinstance(input, list):
if batch_size is None:
output = []


+ 4
- 2
modelscope/preprocessors/ofa/visual_question_answering.py View File

@@ -83,8 +83,10 @@ class OfaVisualQuestionAnsweringPreprocessor(OfaBasePreprocessor):
def _build_infer_sample(self, data: Dict[str, Any]) -> Dict[str, Any]:
image = self.get_img_pil(data[self.column_map['image']])
patch_image = self.patch_resize_transform(image)
text = ' {}'.format(data[self.column_map['text']])
inputs = self.tokenize_text(text)
text = data[self.column_map['text']]
text = self.pre_question(text, self.max_src_length)
text = text + '?' if not text.endswith('?') else text
inputs = self.tokenize_text(f' {text}')
if self.prompt_type == 'none':
decoder_prompt = self.bos_item
elif self.prompt_type == 'src':


+ 0
- 1
requirements/multi-modal.txt View File

@@ -1,6 +1,5 @@
ftfy>=6.0.3
librosa
ofa>=0.0.2
pycocoevalcap>=1.2
pycocotools>=2.0.4
# compatible with taming-transformers-rom1504


Loading…
Cancel
Save