Skip to content

Commit

Permalink
Merge pull request #557 from bioimage-io/optional_inputs
Browse files Browse the repository at this point in the history
Optional input tensors
  • Loading branch information
FynnBe authored Mar 14, 2024
2 parents 34f08da + 82b90da commit bf71654
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ Made with [contrib.rocks](https://contrib.rocks).

### Resource Description Format Versions

#### model 0.5.1 (planned)

* Non-breaking changes
* added optional `inputs.i.optional` field to indicate that a tensor may be `None`

#### generic 0.3.0 / application 0.3.0 / collection 0.3.0 / dataset 0.3.0 / notebook 0.3.0

* Breaking canges that are fully auto-convertible
Expand Down
10 changes: 8 additions & 2 deletions bioimageio/spec/model/v0_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
from .._internal.io import BioimageioYamlContent as BioimageioYamlContent
from .._internal.io import FileDescr as FileDescr
from .._internal.io import Sha256 as Sha256
from .._internal.io import WithSuffix, download
from .._internal.io import WithSuffix, YamlValue, download
from .._internal.io_basics import AbsoluteFilePath as AbsoluteFilePath
from .._internal.io_utils import load_array
from .._internal.types import Datetime as Datetime
Expand Down Expand Up @@ -246,6 +246,9 @@ def get_size(self, n: ParameterizedSize.N) -> int:
return self.min + self.step * n


ARBITRARY_SIZE = ParameterizedSize(min=1, step=1)


class SizeReference(Node):
"""A tensor axis size (extent in pixels/frames) defined in relation to a reference axis.
Expand Down Expand Up @@ -1028,6 +1031,9 @@ class InputTensorDescr(TensorDescrBase[InputAxis]):
"""Input tensor id.
No duplicates are allowed across all inputs and outputs."""

optional: bool = False
"""indicates that this tensor may be `None`"""

preprocessing: List[PreprocessingDescr] = Field(default_factory=list)
"""Description of how this input should be preprocessed."""

Expand Down Expand Up @@ -1464,7 +1470,7 @@ class _ArchitectureCallableDescr(Node):
callable: Annotated[Identifier, Field(examples=["MyNetworkClass", "get_my_model"])]
"""Identifier of the callable that returns a torch.nn.Module instance."""

kwargs: Dict[str, Any] = Field(default_factory=dict)
kwargs: Dict[str, YamlValue] = Field(default_factory=dict)
"""key word arguments for the `callable`"""


Expand Down

0 comments on commit bf71654

Please sign in to comment.