diff --git a/bioimageio/core/VERSION b/bioimageio/core/VERSION index f8786a07..a6275ed8 100644 --- a/bioimageio/core/VERSION +++ b/bioimageio/core/VERSION @@ -1,3 +1,3 @@ { - "version": "0.5.3post2" + "version": "0.5.4" } diff --git a/bioimageio/core/__init__.py b/bioimageio/core/__init__.py index cc725b18..b47ac27d 100644 --- a/bioimageio/core/__init__.py +++ b/bioimageio/core/__init__.py @@ -11,4 +11,5 @@ serialize_raw_resource_description, ) from .prediction_pipeline import create_prediction_pipeline -from .prediction import predict_image, predict_images +from .prediction import predict_image, predict_images, predict_with_padding, predict_with_tiling +from .resource_tests import check_input_shape, check_output_shape, test_resource diff --git a/bioimageio/core/prediction.py b/bioimageio/core/prediction.py index 14ab11e5..847fb0e1 100644 --- a/bioimageio/core/prediction.py +++ b/bioimageio/core/prediction.py @@ -183,7 +183,7 @@ def check_padding(padding): def predict_with_padding( prediction_pipeline: PredictionPipeline, inputs: Union[xr.DataArray, List[xr.DataArray], Tuple[xr.DataArray]], - padding: Union[bool, Dict[str, int]], + padding: Union[bool, Dict[str, int]] = True, pad_right: bool = True, ) -> List[xr.DataArray]: """Run prediction with padding for a single set of input(s) with a bioimage.io model. @@ -305,7 +305,7 @@ def check_tiling(tiling): def predict_with_tiling( prediction_pipeline: PredictionPipeline, inputs: Union[xr.DataArray, List[xr.DataArray], Tuple[xr.DataArray]], - tiling: Union[bool, Dict[str, Dict[str, int]]], + tiling: Union[bool, Dict[str, Dict[str, int]]] = True, verbose: bool = False, ) -> List[xr.DataArray]: """Run prediction with tiling for a single set of input(s) with a bioimage.io model. diff --git a/bioimageio/core/resource_tests.py b/bioimageio/core/resource_tests.py index 9da654df..fa4b9ffb 100644 --- a/bioimageio/core/resource_tests.py +++ b/bioimageio/core/resource_tests.py @@ -60,7 +60,7 @@ def test_model( ) -def _validate_input_shape(shape: Tuple[int, ...], shape_spec) -> bool: +def check_input_shape(shape: Tuple[int, ...], shape_spec) -> bool: if isinstance(shape_spec, list): if shape != tuple(shape_spec): return False @@ -81,7 +81,7 @@ def _validate_input_shape(shape: Tuple[int, ...], shape_spec) -> bool: return True -def _validate_output_shape(shape: Tuple[int, ...], shape_spec, input_shapes) -> bool: +def check_output_shape(shape: Tuple[int, ...], shape_spec, input_shapes) -> bool: if isinstance(shape_spec, list): return shape == tuple(shape_spec) elif isinstance(shape_spec, ImplicitOutputShape): @@ -129,7 +129,7 @@ def test_resource( assert len(inputs) == len(model.inputs) # should be checked by validation input_shapes = {} for idx, (ipt, ipt_spec) in enumerate(zip(inputs, model.inputs)): - if not _validate_input_shape(tuple(ipt.shape), ipt_spec.shape): + if not check_input_shape(tuple(ipt.shape), ipt_spec.shape): raise ValidationError( f"Shape {tuple(ipt.shape)} of test input {idx} '{ipt_spec.name}' does not match " f"input shape description: {ipt_spec.shape}." @@ -138,7 +138,7 @@ def test_resource( assert len(expected) == len(model.outputs) # should be checked by validation for idx, (out, out_spec) in enumerate(zip(expected, model.outputs)): - if not _validate_output_shape(tuple(out.shape), out_spec.shape, input_shapes): + if not check_output_shape(tuple(out.shape), out_spec.shape, input_shapes): error = (error or "") + ( f"Shape {tuple(out.shape)} of test output {idx} '{out_spec.name}' does not match " f"output shape description: {out_spec.shape}."