yeandy commented on code in PR #21810:
URL: https://github.com/apache/beam/pull/21810#discussion_r896925697
##########
sdks/python/apache_beam/ml/inference/pytorch_inference.py:
##########
@@ -67,67 +84,114 @@ def __init__(
def load_model(self) -> torch.nn.Module:
"""Loads and initializes a Pytorch model for processing."""
- model = self._model_class(**self._model_params)
- model.to(self._device)
- file = FileSystems.open(self._state_dict_path, 'rb')
- model.load_state_dict(torch.load(file))
- model.eval()
- return model
-
- def _convert_to_device(self, examples: torch.Tensor) -> torch.Tensor:
+ return _load_model(
+ self._model_class,
+ self._state_dict_path,
+ self._device,
+ **self._model_params)
Review Comment:
are you referring to something like this?
https://github.com/apache/beam/pull/21806
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]