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

Method _process_single

modelscope/pipelines/base.py:272–290  ·  view source on GitHub ↗
(self, input: Input, *args, **kwargs)

Source from the content-addressed store, hash-verified

270 return collate_fn(data, self.device)
271
272 def _process_single(self, input: Input, *args, **kwargs) -> Dict[str, Any]:
273 preprocess_params = kwargs.get('preprocess_params', {})
274 forward_params = kwargs.get('forward_params', {})
275 postprocess_params = kwargs.get('postprocess_params', {})
276 self._check_input(input)
277 out = self.preprocess(input, **preprocess_params)
278
279 with device_placement(self.framework, self.device_name):
280 if self.framework == Frameworks.torch:
281 with torch.no_grad():
282 if self._auto_collate:
283 out = self._collate_fn(out)
284 out = self.forward(out, **forward_params)
285 else:
286 out = self.forward(out, **forward_params)
287
288 out = self.postprocess(out, **postprocess_params)
289 self._check_output(out)
290 return out
291
292 def _batch(self, data_list):
293 batch_data = {}

Callers 2

__call__Method · 0.95
_process_iteratorMethod · 0.95

Calls 8

_check_inputMethod · 0.95
preprocessMethod · 0.95
_collate_fnMethod · 0.95
forwardMethod · 0.95
postprocessMethod · 0.95
_check_outputMethod · 0.95
device_placementFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected