From 789ba05c0991a79987eb711e06d8e3ad1216ed45 Mon Sep 17 00:00:00 2001 From: Constantin Pape Date: Thu, 21 Mar 2024 09:10:25 +0100 Subject: [PATCH] Fix optional inputs for pytorch --- bioimageio/core/model_adapters/_pytorch_model_adapter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bioimageio/core/model_adapters/_pytorch_model_adapter.py b/bioimageio/core/model_adapters/_pytorch_model_adapter.py index 98af48b4..103af9bb 100644 --- a/bioimageio/core/model_adapters/_pytorch_model_adapter.py +++ b/bioimageio/core/model_adapters/_pytorch_model_adapter.py @@ -50,7 +50,7 @@ def forward(self, *input_tensors: Optional[Tensor]) -> List[Optional[Tensor]]: None if ipt is None else torch.from_numpy(ipt.data) for ipt in input_tensors ] - tensors = [t.to(self._devices[0]) for t in tensors] + tensors = [None if t is None else t.to(self._devices[0]) for t in tensors] result: Union[Tuple[Any, ...], List[Any], Any] = self._network(*tensors) if not isinstance(result, (tuple, list)): result = [result]