MCPcopy Create free account
hub / github.com/modelscope/modelscope / __call__

Method __call__

modelscope/preprocessors/multi_modal.py:148–164  ·  view source on GitHub ↗
(self, input: Union[str, tuple, Dict[str, Any]], *args,
                 **kwargs)

Source from the content-addressed store, hash-verified

146 return data
147
148 def __call__(self, input: Union[str, tuple, Dict[str, Any]], *args,
149 **kwargs) -> Dict[str, Any]:
150 if isinstance(input, dict):
151 data = input
152 else:
153 data = self._build_dict(input)
154 sample = self.preprocess(data)
155 str_data = dict()
156 for k, v in data.items():
157 str_data[k] = str(v)
158 sample['sample'] = str_data
159 if self.no_collate:
160 return sample
161 else:
162 return collate_fn([sample],
163 pad_idx=self.tokenizer.pad_token_id,
164 eos_idx=self.tokenizer.eos_token_id)
165
166
167def _convert_to_rgb(image):

Callers

nothing calls this directly

Calls 4

_build_dictMethod · 0.95
collate_fnFunction · 0.50
preprocessMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected